From d973c1606a28f510d14aa79ff0db3a14dda7ff45 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 16 Aug 2016 11:32:08 +0530 Subject: [PATCH] [revert] is_sales_item, is_purchase_item back --- .../purchase_invoice/purchase_invoice.js | 3 +- .../purchase_common/purchase_common.js | 3 +- .../crm/doctype/opportunity/opportunity.js | 3 +- .../v5_2/change_item_selects_to_checks.py | 3 +- erpnext/selling/sales_common.js | 3 +- erpnext/setup/setup_wizard/sample_data.py | 4 +- erpnext/setup/setup_wizard/setup_wizard.py | 2 + erpnext/stock/doctype/item/item.json | 81 ++++++++++++------- 8 files changed, 66 insertions(+), 36 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index c655626b86..c51231e881 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -232,7 +232,8 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) { cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { return { - query: "erpnext.controllers.queries.item_query" + query: "erpnext.controllers.queries.item_query", + filters: {'is_purchase_item': 1} } } diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 2e7651699b..6e27546cce 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -79,7 +79,8 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ } } else { return{ - query: "erpnext.controllers.queries.item_query" + query: "erpnext.controllers.queries.item_query", + filters: {'is_purchase_item': 1} } } }); diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index 21a7429be2..c9f1ffb1a5 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -51,7 +51,8 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({ this.frm.set_query("item_code", "items", function() { return { - query: "erpnext.controllers.queries.item_query" + query: "erpnext.controllers.queries.item_query", + filters: {'is_sales_item': 1} }; }); diff --git a/erpnext/patches/v5_2/change_item_selects_to_checks.py b/erpnext/patches/v5_2/change_item_selects_to_checks.py index dde0b56eeb..1ee8f6caa5 100644 --- a/erpnext/patches/v5_2/change_item_selects_to_checks.py +++ b/erpnext/patches/v5_2/change_item_selects_to_checks.py @@ -4,8 +4,7 @@ import frappe def execute(): fields = ("is_stock_item", "is_asset_item", "has_batch_no", "has_serial_no", - "inspection_required", "is_sub_contracted_item") - + "is_sales_item", "is_purchase_item", "inspection_required", "is_sub_contracted_item") # convert to 1 or 0 update_str = ", ".join(["`{0}`=if(`{0}`='Yes',1,0)".format(f) for f in fields]) diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index d58adce06f..402ff116ec 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -66,7 +66,8 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ if(this.frm.fields_dict["items"].grid.get_field('item_code')) { this.frm.set_query("item_code", "items", function() { return { - query: "erpnext.controllers.queries.item_query" + query: "erpnext.controllers.queries.item_query", + filters: {'is_sales_item': 1} } }); } diff --git a/erpnext/setup/setup_wizard/sample_data.py b/erpnext/setup/setup_wizard/sample_data.py index 8078ebca3a..955f6633ca 100644 --- a/erpnext/setup/setup_wizard/sample_data.py +++ b/erpnext/setup/setup_wizard/sample_data.py @@ -11,7 +11,7 @@ import random def make_sample_data(): """Create a few opportunities, quotes, material requests, issues, todos, projects to help the user get started""" - items = frappe.get_all("Item") + items = frappe.get_all("Item", {'is_sales_item': 1}) customers = frappe.get_all("Customer") warehouses = frappe.get_all("Warehouse") @@ -25,7 +25,7 @@ def make_sample_data(): make_projects() if items and warehouses: - make_material_request(items) + make_material_request(frappe.get_all("Item")) frappe.db.commit() diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py index c9679bd9a0..191f1699b2 100644 --- a/erpnext/setup/setup_wizard/setup_wizard.py +++ b/erpnext/setup/setup_wizard/setup_wizard.py @@ -318,6 +318,8 @@ def create_items(args): "item_name": item, "description": item, "show_in_website": 1, + "is_sales_item": is_sales_item, + "is_purchase_item": is_purchase_item, "is_stock_item": is_stock_item and 1 or 0, "item_group": item_group, "stock_uom": args.get("item_uom_" + str(i)), diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index b86378d1c6..a4e3470de8 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -705,33 +705,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "default": "Purchase", - "fieldname": "default_material_request_type", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "label": "Default Material Request Type", - "length": 0, - "no_copy": 0, - "options": "Purchase\nMaterial Transfer\nMaterial Issue\nManufacture", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, { "allow_on_submit": 0, "bold": 0, @@ -1054,6 +1027,32 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "default": "1", + "fieldname": "is_purchase_item", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Is Purchase Item", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -1483,6 +1482,32 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "default": "1", + "fieldname": "is_sales_item", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Is Sales Item", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -2335,7 +2360,7 @@ "issingle": 0, "istable": 0, "max_attachments": 1, - "modified": "2016-08-03 17:30:51.323382", + "modified": "2016-08-16 01:59:49.494629", "modified_by": "Administrator", "module": "Stock", "name": "Item",