From 5d965d3c0ddd6be55fdabc40a68a03395d21ca3c Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Tue, 31 Aug 2021 14:53:31 +0530 Subject: [PATCH 01/11] feat: add party specific items doctype, remove supplier item group --- erpnext/buying/doctype/supplier/supplier.json | 7 +- erpnext/controllers/queries.py | 30 +++++--- .../doctype/party_specific_items/__init__.py | 0 .../party_specific_items.js | 8 +++ .../party_specific_items.json | 71 +++++++++++++++++++ .../party_specific_items.py | 18 +++++ .../test_party_specific_items.py | 8 +++ erpnext/selling/sales_common.js | 2 +- 8 files changed, 130 insertions(+), 14 deletions(-) create mode 100644 erpnext/selling/doctype/party_specific_items/__init__.py create mode 100644 erpnext/selling/doctype/party_specific_items/party_specific_items.js create mode 100644 erpnext/selling/doctype/party_specific_items/party_specific_items.json create mode 100644 erpnext/selling/doctype/party_specific_items/party_specific_items.py create mode 100644 erpnext/selling/doctype/party_specific_items/test_party_specific_items.py diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json index 38b8dfdf48dd..4f5635285600 100644 --- a/erpnext/buying/doctype/supplier/supplier.json +++ b/erpnext/buying/doctype/supplier/supplier.json @@ -385,12 +385,11 @@ "image_field": "image", "links": [ { - "group": "Item Group", - "link_doctype": "Supplier Item Group", - "link_fieldname": "supplier" + "link_doctype": "Party Specific Items", + "link_fieldname": "party" } ], - "modified": "2021-05-18 15:10:11.087191", + "modified": "2021-08-31 14:39:15.658327", "modified_by": "Administrator", "module": "Buying", "name": "Supplier", diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 4b4c8befa532..d5170ab23692 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -5,6 +5,7 @@ import frappe import erpnext import json +from frappe import scrub from frappe.desk.reportview import get_match_cond, get_filters_cond from frappe.utils import nowdate, getdate from collections import defaultdict @@ -220,18 +221,29 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals if not field in searchfields] searchfields = " or ".join([field + " like %(txt)s" for field in searchfields]) - if filters and isinstance(filters, dict) and filters.get('supplier'): - item_group_list = frappe.get_all('Supplier Item Group', - filters = {'supplier': filters.get('supplier')}, fields = ['item_group']) + if filters and isinstance(filters, dict): + if filters.get('customer') or filters.get('supplier'): + party = filters.get('customer') or filters.get('supplier') + item_rules_list = frappe.get_all('Party Specific Items', + filters = {'party': party}, fields = ['restrict_based_on', 'based_on']) - item_groups = [] - for i in item_group_list: - item_groups.append(i.item_group) + filters_dict = {} + for rule in item_rules_list: + if rule['restrict_based_on'] == 'Item': + rule['restrict_based_on'] = 'name' + filters_dict[rule.restrict_based_on] = [] - del filters['supplier'] + for rule in item_rules_list: + filters_dict[rule.restrict_based_on].append(rule.based_on) + + for filter in filters_dict: + filters[scrub(filter)] = ['in', filters_dict[filter]] + + if filters.get('customer'): + del filters['customer'] + else: + del filters['supplier'] - if item_groups: - filters['item_group'] = ['in', item_groups] description_cond = '' if frappe.db.count('Item', cache=True) < 50000: diff --git a/erpnext/selling/doctype/party_specific_items/__init__.py b/erpnext/selling/doctype/party_specific_items/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/erpnext/selling/doctype/party_specific_items/party_specific_items.js b/erpnext/selling/doctype/party_specific_items/party_specific_items.js new file mode 100644 index 000000000000..3c4f5ad6a64f --- /dev/null +++ b/erpnext/selling/doctype/party_specific_items/party_specific_items.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Party Specific Items', { + // refresh: function(frm) { + + // } +}); diff --git a/erpnext/selling/doctype/party_specific_items/party_specific_items.json b/erpnext/selling/doctype/party_specific_items/party_specific_items.json new file mode 100644 index 000000000000..2f3e5226a4ca --- /dev/null +++ b/erpnext/selling/doctype/party_specific_items/party_specific_items.json @@ -0,0 +1,71 @@ +{ + "actions": [], + "creation": "2021-08-27 19:28:07.559978", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "party_type", + "party", + "restrict_based_on", + "based_on" + ], + "fields": [ + { + "fieldname": "party_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Party Type", + "options": "Customer\nSupplier", + "reqd": 1 + }, + { + "fieldname": "party", + "fieldtype": "Dynamic Link", + "in_list_view": 1, + "label": "Party", + "options": "party_type", + "reqd": 1 + }, + { + "fieldname": "restrict_based_on", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Restrict Based On", + "options": "Item\nItem Group\nBrand", + "reqd": 1 + }, + { + "fieldname": "based_on", + "fieldtype": "Dynamic Link", + "in_list_view": 1, + "label": "Based On", + "options": "restrict_based_on", + "reqd": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2021-08-31 13:29:32.273991", + "modified_by": "Administrator", + "module": "Selling", + "name": "Party Specific Items", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/selling/doctype/party_specific_items/party_specific_items.py b/erpnext/selling/doctype/party_specific_items/party_specific_items.py new file mode 100644 index 000000000000..4f7d7da67cd8 --- /dev/null +++ b/erpnext/selling/doctype/party_specific_items/party_specific_items.py @@ -0,0 +1,18 @@ +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +import frappe +from frappe import _ +from frappe.model.document import Document + +class PartySpecificItems(Document): + def validate(self): + exists = frappe.db.exists({ + 'doctype': 'Party Specific Items', + 'party_type': self.party_type, + 'party': self.party, + 'restrict_based_on': self.restrict_based_on, + 'based_on': self.based_on, + }) + if exists: + frappe.throw(_(f"This item filter has already been applied for the {self.party_type}")) diff --git a/erpnext/selling/doctype/party_specific_items/test_party_specific_items.py b/erpnext/selling/doctype/party_specific_items/test_party_specific_items.py new file mode 100644 index 000000000000..0796e49d8841 --- /dev/null +++ b/erpnext/selling/doctype/party_specific_items/test_party_specific_items.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +# import frappe +import unittest + +class TestPartySpecificItems(unittest.TestCase): + pass diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 2de57c87f186..4fb98454785b 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -63,7 +63,7 @@ erpnext.selling.SellingController = class SellingController extends erpnext.Tran this.frm.set_query("item_code", "items", function() { return { query: "erpnext.controllers.queries.item_query", - filters: {'is_sales_item': 1} + filters: {'is_sales_item': 1, 'customer': cur_frm.doc.customer} } }); } From 472f44ba6238f8442086a7b688bbc1fbfe213f25 Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Wed, 1 Sep 2021 11:32:41 +0530 Subject: [PATCH 02/11] add patch for removing supplier item group doctype --- erpnext/patches.txt | 3 ++- ...er_item_group_with_party_specific_items.py | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 0f6a606cb12b..da9822e52d82 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -299,4 +299,5 @@ erpnext.patches.v13_0.migrate_stripe_api erpnext.patches.v13_0.reset_clearance_date_for_intracompany_payment_entries erpnext.patches.v13_0.einvoicing_deprecation_warning erpnext.patches.v14_0.delete_einvoicing_doctypes -erpnext.patches.v13_0.set_operation_time_based_on_operating_cost \ No newline at end of file +erpnext.patches.v13_0.set_operation_time_based_on_operating_cost +erpnext.patches.v13_0.replace_supplier_item_group_with_party_specific_items \ No newline at end of file diff --git a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py new file mode 100644 index 000000000000..cbb8c800e8a3 --- /dev/null +++ b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py @@ -0,0 +1,25 @@ +# Copyright (c) 2019, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +import frappe + +def execute(): + sig = frappe.db.get_all("Supplier Item Group", fields=["name", "supplier", "item_group"]) + for item in sig: + psi = frappe.new_doc("Party Specific Items") + psi.party_type = "Supplier" + psi.party = item.supplier + psi.restrict_based_on = "Item Group" + psi.based_on = item.item_group + psi.insert() + + supplier_dt = frappe.get_doc("DocType", "Supplier") + for link in supplier_dt.links: + if link.link_doctype == "Supplier Item Group": + supplier_dt.links.remove(link) + frappe.delete_doc("Supplier Item Group", link.name, force=1) + supplier_dt.append('links', {'link_doctype': 'Party Specific Items', 'link_fieldname':'party'}) + supplier_dt.save() + frappe.delete_doc("DocType", "Supplier Item Group", force=1) From b15987f4a7dcc74831f5d797eec155a77abb6123 Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Tue, 31 Aug 2021 14:53:31 +0530 Subject: [PATCH 03/11] feat: add party specific items doctype, remove supplier item group --- erpnext/buying/doctype/supplier/supplier.json | 7 +- erpnext/controllers/queries.py | 30 +++++--- erpnext/patches.txt | 3 +- ...er_item_group_with_party_specific_items.py | 25 +++++++ .../doctype/party_specific_items/__init__.py | 0 .../party_specific_items.js | 8 +++ .../party_specific_items.json | 71 +++++++++++++++++++ .../party_specific_items.py | 18 +++++ .../test_party_specific_items.py | 8 +++ erpnext/selling/sales_common.js | 2 +- 10 files changed, 157 insertions(+), 15 deletions(-) create mode 100644 erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py create mode 100644 erpnext/selling/doctype/party_specific_items/__init__.py create mode 100644 erpnext/selling/doctype/party_specific_items/party_specific_items.js create mode 100644 erpnext/selling/doctype/party_specific_items/party_specific_items.json create mode 100644 erpnext/selling/doctype/party_specific_items/party_specific_items.py create mode 100644 erpnext/selling/doctype/party_specific_items/test_party_specific_items.py diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json index 38b8dfdf48dd..4f5635285600 100644 --- a/erpnext/buying/doctype/supplier/supplier.json +++ b/erpnext/buying/doctype/supplier/supplier.json @@ -385,12 +385,11 @@ "image_field": "image", "links": [ { - "group": "Item Group", - "link_doctype": "Supplier Item Group", - "link_fieldname": "supplier" + "link_doctype": "Party Specific Items", + "link_fieldname": "party" } ], - "modified": "2021-05-18 15:10:11.087191", + "modified": "2021-08-31 14:39:15.658327", "modified_by": "Administrator", "module": "Buying", "name": "Supplier", diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 4b4c8befa532..d5170ab23692 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -5,6 +5,7 @@ import frappe import erpnext import json +from frappe import scrub from frappe.desk.reportview import get_match_cond, get_filters_cond from frappe.utils import nowdate, getdate from collections import defaultdict @@ -220,18 +221,29 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals if not field in searchfields] searchfields = " or ".join([field + " like %(txt)s" for field in searchfields]) - if filters and isinstance(filters, dict) and filters.get('supplier'): - item_group_list = frappe.get_all('Supplier Item Group', - filters = {'supplier': filters.get('supplier')}, fields = ['item_group']) + if filters and isinstance(filters, dict): + if filters.get('customer') or filters.get('supplier'): + party = filters.get('customer') or filters.get('supplier') + item_rules_list = frappe.get_all('Party Specific Items', + filters = {'party': party}, fields = ['restrict_based_on', 'based_on']) - item_groups = [] - for i in item_group_list: - item_groups.append(i.item_group) + filters_dict = {} + for rule in item_rules_list: + if rule['restrict_based_on'] == 'Item': + rule['restrict_based_on'] = 'name' + filters_dict[rule.restrict_based_on] = [] - del filters['supplier'] + for rule in item_rules_list: + filters_dict[rule.restrict_based_on].append(rule.based_on) + + for filter in filters_dict: + filters[scrub(filter)] = ['in', filters_dict[filter]] + + if filters.get('customer'): + del filters['customer'] + else: + del filters['supplier'] - if item_groups: - filters['item_group'] = ['in', item_groups] description_cond = '' if frappe.db.count('Item', cache=True) < 50000: diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 0f6a606cb12b..da9822e52d82 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -299,4 +299,5 @@ erpnext.patches.v13_0.migrate_stripe_api erpnext.patches.v13_0.reset_clearance_date_for_intracompany_payment_entries erpnext.patches.v13_0.einvoicing_deprecation_warning erpnext.patches.v14_0.delete_einvoicing_doctypes -erpnext.patches.v13_0.set_operation_time_based_on_operating_cost \ No newline at end of file +erpnext.patches.v13_0.set_operation_time_based_on_operating_cost +erpnext.patches.v13_0.replace_supplier_item_group_with_party_specific_items \ No newline at end of file diff --git a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py new file mode 100644 index 000000000000..cbb8c800e8a3 --- /dev/null +++ b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py @@ -0,0 +1,25 @@ +# Copyright (c) 2019, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +import frappe + +def execute(): + sig = frappe.db.get_all("Supplier Item Group", fields=["name", "supplier", "item_group"]) + for item in sig: + psi = frappe.new_doc("Party Specific Items") + psi.party_type = "Supplier" + psi.party = item.supplier + psi.restrict_based_on = "Item Group" + psi.based_on = item.item_group + psi.insert() + + supplier_dt = frappe.get_doc("DocType", "Supplier") + for link in supplier_dt.links: + if link.link_doctype == "Supplier Item Group": + supplier_dt.links.remove(link) + frappe.delete_doc("Supplier Item Group", link.name, force=1) + supplier_dt.append('links', {'link_doctype': 'Party Specific Items', 'link_fieldname':'party'}) + supplier_dt.save() + frappe.delete_doc("DocType", "Supplier Item Group", force=1) diff --git a/erpnext/selling/doctype/party_specific_items/__init__.py b/erpnext/selling/doctype/party_specific_items/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/erpnext/selling/doctype/party_specific_items/party_specific_items.js b/erpnext/selling/doctype/party_specific_items/party_specific_items.js new file mode 100644 index 000000000000..3c4f5ad6a64f --- /dev/null +++ b/erpnext/selling/doctype/party_specific_items/party_specific_items.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Party Specific Items', { + // refresh: function(frm) { + + // } +}); diff --git a/erpnext/selling/doctype/party_specific_items/party_specific_items.json b/erpnext/selling/doctype/party_specific_items/party_specific_items.json new file mode 100644 index 000000000000..2f3e5226a4ca --- /dev/null +++ b/erpnext/selling/doctype/party_specific_items/party_specific_items.json @@ -0,0 +1,71 @@ +{ + "actions": [], + "creation": "2021-08-27 19:28:07.559978", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "party_type", + "party", + "restrict_based_on", + "based_on" + ], + "fields": [ + { + "fieldname": "party_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Party Type", + "options": "Customer\nSupplier", + "reqd": 1 + }, + { + "fieldname": "party", + "fieldtype": "Dynamic Link", + "in_list_view": 1, + "label": "Party", + "options": "party_type", + "reqd": 1 + }, + { + "fieldname": "restrict_based_on", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Restrict Based On", + "options": "Item\nItem Group\nBrand", + "reqd": 1 + }, + { + "fieldname": "based_on", + "fieldtype": "Dynamic Link", + "in_list_view": 1, + "label": "Based On", + "options": "restrict_based_on", + "reqd": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2021-08-31 13:29:32.273991", + "modified_by": "Administrator", + "module": "Selling", + "name": "Party Specific Items", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/selling/doctype/party_specific_items/party_specific_items.py b/erpnext/selling/doctype/party_specific_items/party_specific_items.py new file mode 100644 index 000000000000..4f7d7da67cd8 --- /dev/null +++ b/erpnext/selling/doctype/party_specific_items/party_specific_items.py @@ -0,0 +1,18 @@ +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +import frappe +from frappe import _ +from frappe.model.document import Document + +class PartySpecificItems(Document): + def validate(self): + exists = frappe.db.exists({ + 'doctype': 'Party Specific Items', + 'party_type': self.party_type, + 'party': self.party, + 'restrict_based_on': self.restrict_based_on, + 'based_on': self.based_on, + }) + if exists: + frappe.throw(_(f"This item filter has already been applied for the {self.party_type}")) diff --git a/erpnext/selling/doctype/party_specific_items/test_party_specific_items.py b/erpnext/selling/doctype/party_specific_items/test_party_specific_items.py new file mode 100644 index 000000000000..0796e49d8841 --- /dev/null +++ b/erpnext/selling/doctype/party_specific_items/test_party_specific_items.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +# import frappe +import unittest + +class TestPartySpecificItems(unittest.TestCase): + pass diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 2de57c87f186..4fb98454785b 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -63,7 +63,7 @@ erpnext.selling.SellingController = class SellingController extends erpnext.Tran this.frm.set_query("item_code", "items", function() { return { query: "erpnext.controllers.queries.item_query", - filters: {'is_sales_item': 1} + filters: {'is_sales_item': 1, 'customer': cur_frm.doc.customer} } }); } From d191cca53d04bffd3bca9c42e8a51871aea02d80 Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Wed, 1 Sep 2021 19:18:48 +0530 Subject: [PATCH 04/11] refactor: semgrep stuff --- .../replace_supplier_item_group_with_party_specific_items.py | 1 - .../doctype/party_specific_items/party_specific_items.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py index cbb8c800e8a3..f7cc6f03af53 100644 --- a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py +++ b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py @@ -19,7 +19,6 @@ def execute(): for link in supplier_dt.links: if link.link_doctype == "Supplier Item Group": supplier_dt.links.remove(link) - frappe.delete_doc("Supplier Item Group", link.name, force=1) supplier_dt.append('links', {'link_doctype': 'Party Specific Items', 'link_fieldname':'party'}) supplier_dt.save() frappe.delete_doc("DocType", "Supplier Item Group", force=1) diff --git a/erpnext/selling/doctype/party_specific_items/party_specific_items.py b/erpnext/selling/doctype/party_specific_items/party_specific_items.py index 4f7d7da67cd8..119e71590d39 100644 --- a/erpnext/selling/doctype/party_specific_items/party_specific_items.py +++ b/erpnext/selling/doctype/party_specific_items/party_specific_items.py @@ -15,4 +15,4 @@ def validate(self): 'based_on': self.based_on, }) if exists: - frappe.throw(_(f"This item filter has already been applied for the {self.party_type}")) + frappe.throw(_("This item filter has already been applied for the {0}").format(self.party_type)) From 694a2576d0cc1566c9a3f3391b587562b3a82708 Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Thu, 2 Sep 2021 17:41:45 +0530 Subject: [PATCH 05/11] refactor: refactor for party specific item --- .../supplier_item_group.json | 77 ------------------- .../supplier_item_group.py | 18 ----- .../test_supplier_item_group.py | 10 --- erpnext/controllers/queries.py | 6 +- erpnext/patches.txt | 2 +- ...ier_item_group_with_party_specific_item.py | 16 ++++ ...er_item_group_with_party_specific_items.py | 24 ------ .../doctype/party_specific_item}/__init__.py | 0 .../party_specific_item.js} | 2 +- .../party_specific_item.json} | 17 ++-- .../party_specific_item.py} | 4 +- .../test_party_specific_item.py | 16 ++++ .../doctype/party_specific_items/__init__.py | 0 .../party_specific_items.js | 8 -- .../test_party_specific_items.py | 8 -- 15 files changed, 50 insertions(+), 158 deletions(-) delete mode 100644 erpnext/buying/doctype/supplier_item_group/supplier_item_group.json delete mode 100644 erpnext/buying/doctype/supplier_item_group/supplier_item_group.py delete mode 100644 erpnext/buying/doctype/supplier_item_group/test_supplier_item_group.py create mode 100644 erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py delete mode 100644 erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py rename erpnext/{buying/doctype/supplier_item_group => selling/doctype/party_specific_item}/__init__.py (100%) rename erpnext/{buying/doctype/supplier_item_group/supplier_item_group.js => selling/doctype/party_specific_item/party_specific_item.js} (79%) rename erpnext/selling/doctype/{party_specific_items/party_specific_items.json => party_specific_item/party_specific_item.json} (80%) rename erpnext/selling/doctype/{party_specific_items/party_specific_items.py => party_specific_item/party_specific_item.py} (87%) create mode 100644 erpnext/selling/doctype/party_specific_item/test_party_specific_item.py delete mode 100644 erpnext/selling/doctype/party_specific_items/__init__.py delete mode 100644 erpnext/selling/doctype/party_specific_items/party_specific_items.js delete mode 100644 erpnext/selling/doctype/party_specific_items/test_party_specific_items.py diff --git a/erpnext/buying/doctype/supplier_item_group/supplier_item_group.json b/erpnext/buying/doctype/supplier_item_group/supplier_item_group.json deleted file mode 100644 index 1971458f61ea..000000000000 --- a/erpnext/buying/doctype/supplier_item_group/supplier_item_group.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "actions": [], - "creation": "2021-05-07 18:16:40.621421", - "doctype": "DocType", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "supplier", - "item_group" - ], - "fields": [ - { - "fieldname": "supplier", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Supplier", - "options": "Supplier", - "reqd": 1 - }, - { - "fieldname": "item_group", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Group", - "options": "Item Group", - "reqd": 1 - } - ], - "index_web_pages_for_search": 1, - "links": [], - "modified": "2021-05-19 13:48:16.742303", - "modified_by": "Administrator", - "module": "Buying", - "name": "Supplier Item Group", - "owner": "Administrator", - "permissions": [ - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "share": 1, - "write": 1 - }, - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "Purchase User", - "share": 1, - "write": 1 - }, - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "Purchase Manager", - "share": 1, - "write": 1 - } - ], - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 1 -} \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py b/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py deleted file mode 100644 index 4473ddea28e9..000000000000 --- a/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors -# For license information, please see license.txt - -from __future__ import unicode_literals -import frappe -from frappe import _ -from frappe.model.document import Document - -class SupplierItemGroup(Document): - def validate(self): - exists = frappe.db.exists({ - 'doctype': 'Supplier Item Group', - 'supplier': self.supplier, - 'item_group': self.item_group - }) - if exists: - frappe.throw(_("Item Group has already been linked to this supplier.")) diff --git a/erpnext/buying/doctype/supplier_item_group/test_supplier_item_group.py b/erpnext/buying/doctype/supplier_item_group/test_supplier_item_group.py deleted file mode 100644 index c75044d44eb7..000000000000 --- a/erpnext/buying/doctype/supplier_item_group/test_supplier_item_group.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors -# See license.txt -from __future__ import unicode_literals - -# import frappe -import unittest - -class TestSupplierItemGroup(unittest.TestCase): - pass diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index d5170ab23692..3d65163651d0 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -224,8 +224,8 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals if filters and isinstance(filters, dict): if filters.get('customer') or filters.get('supplier'): party = filters.get('customer') or filters.get('supplier') - item_rules_list = frappe.get_all('Party Specific Items', - filters = {'party': party}, fields = ['restrict_based_on', 'based_on']) + item_rules_list = frappe.get_all('Party Specific Item', + filters = {'party': party}, fields = ['restrict_based_on', 'based_on_value']) filters_dict = {} for rule in item_rules_list: @@ -234,7 +234,7 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals filters_dict[rule.restrict_based_on] = [] for rule in item_rules_list: - filters_dict[rule.restrict_based_on].append(rule.based_on) + filters_dict[rule.restrict_based_on].append(rule.based_on_value) for filter in filters_dict: filters[scrub(filter)] = ['in', filters_dict[filter]] diff --git a/erpnext/patches.txt b/erpnext/patches.txt index cc510feb5f24..54528b63836a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -301,5 +301,5 @@ erpnext.patches.v13_0.einvoicing_deprecation_warning erpnext.patches.v13_0.custom_fields_for_taxjar_integration erpnext.patches.v14_0.delete_einvoicing_doctypes erpnext.patches.v13_0.set_operation_time_based_on_operating_cost -erpnext.patches.v13_0.replace_supplier_item_group_with_party_specific_items +erpnext.patches.v13_0.replace_supplier_item_group_with_party_specific_item erpnext.patches.v13_0.validate_options_for_data_field diff --git a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py new file mode 100644 index 000000000000..be23566c4e88 --- /dev/null +++ b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py @@ -0,0 +1,16 @@ +# Copyright (c) 2019, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +import frappe + +def execute(): + if frappe.db.table_exists('Supplier Item Group'): + frappe.reload_doc("buying", "doctype", "supplier_item_group") + sig = frappe.db.get_all("Supplier Item Group", fields=["name", "supplier", "item_group"]) + for item in sig: + psi = frappe.new_doc("Party Specific Item") + psi.party_type = "Supplier" + psi.party = item.supplier + psi.restrict_based_on = "Item Group" + psi.based_on_value = item.item_group + psi.insert() diff --git a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py deleted file mode 100644 index f7cc6f03af53..000000000000 --- a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_items.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2019, Frappe and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals - -import frappe - -def execute(): - sig = frappe.db.get_all("Supplier Item Group", fields=["name", "supplier", "item_group"]) - for item in sig: - psi = frappe.new_doc("Party Specific Items") - psi.party_type = "Supplier" - psi.party = item.supplier - psi.restrict_based_on = "Item Group" - psi.based_on = item.item_group - psi.insert() - - supplier_dt = frappe.get_doc("DocType", "Supplier") - for link in supplier_dt.links: - if link.link_doctype == "Supplier Item Group": - supplier_dt.links.remove(link) - supplier_dt.append('links', {'link_doctype': 'Party Specific Items', 'link_fieldname':'party'}) - supplier_dt.save() - frappe.delete_doc("DocType", "Supplier Item Group", force=1) diff --git a/erpnext/buying/doctype/supplier_item_group/__init__.py b/erpnext/selling/doctype/party_specific_item/__init__.py similarity index 100% rename from erpnext/buying/doctype/supplier_item_group/__init__.py rename to erpnext/selling/doctype/party_specific_item/__init__.py diff --git a/erpnext/buying/doctype/supplier_item_group/supplier_item_group.js b/erpnext/selling/doctype/party_specific_item/party_specific_item.js similarity index 79% rename from erpnext/buying/doctype/supplier_item_group/supplier_item_group.js rename to erpnext/selling/doctype/party_specific_item/party_specific_item.js index f7da90d98d63..077b93631ecf 100644 --- a/erpnext/buying/doctype/supplier_item_group/supplier_item_group.js +++ b/erpnext/selling/doctype/party_specific_item/party_specific_item.js @@ -1,7 +1,7 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Supplier Item Group', { +frappe.ui.form.on('Party Specific Item', { // refresh: function(frm) { // } diff --git a/erpnext/selling/doctype/party_specific_items/party_specific_items.json b/erpnext/selling/doctype/party_specific_item/party_specific_item.json similarity index 80% rename from erpnext/selling/doctype/party_specific_items/party_specific_items.json rename to erpnext/selling/doctype/party_specific_item/party_specific_item.json index 2f3e5226a4ca..26413885de16 100644 --- a/erpnext/selling/doctype/party_specific_items/party_specific_items.json +++ b/erpnext/selling/doctype/party_specific_item/party_specific_item.json @@ -7,8 +7,9 @@ "field_order": [ "party_type", "party", + "column_break_3", "restrict_based_on", - "based_on" + "based_on_value" ], "fields": [ { @@ -31,25 +32,29 @@ "fieldname": "restrict_based_on", "fieldtype": "Select", "in_list_view": 1, - "label": "Restrict Based On", + "label": "Restrict Items Based On", "options": "Item\nItem Group\nBrand", "reqd": 1 }, { - "fieldname": "based_on", + "fieldname": "column_break_3", + "fieldtype": "Column Break" + }, + { + "fieldname": "based_on_value", "fieldtype": "Dynamic Link", "in_list_view": 1, - "label": "Based On", + "label": "Based On Value", "options": "restrict_based_on", "reqd": 1 } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-08-31 13:29:32.273991", + "modified": "2021-09-02 17:36:37.337094", "modified_by": "Administrator", "module": "Selling", - "name": "Party Specific Items", + "name": "Party Specific Item", "owner": "Administrator", "permissions": [ { diff --git a/erpnext/selling/doctype/party_specific_items/party_specific_items.py b/erpnext/selling/doctype/party_specific_item/party_specific_item.py similarity index 87% rename from erpnext/selling/doctype/party_specific_items/party_specific_items.py rename to erpnext/selling/doctype/party_specific_item/party_specific_item.py index 119e71590d39..8a88a40f4aae 100644 --- a/erpnext/selling/doctype/party_specific_items/party_specific_items.py +++ b/erpnext/selling/doctype/party_specific_item/party_specific_item.py @@ -5,14 +5,14 @@ from frappe import _ from frappe.model.document import Document -class PartySpecificItems(Document): +class PartySpecificItem(Document): def validate(self): exists = frappe.db.exists({ 'doctype': 'Party Specific Items', 'party_type': self.party_type, 'party': self.party, 'restrict_based_on': self.restrict_based_on, - 'based_on': self.based_on, + 'based_on': self.based_on_value, }) if exists: frappe.throw(_("This item filter has already been applied for the {0}").format(self.party_type)) diff --git a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py new file mode 100644 index 000000000000..c1876736efb6 --- /dev/null +++ b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py @@ -0,0 +1,16 @@ +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +import frappe +import unittest + + +def create_records(): + pass + +class TestPartySpecificItem(unittest.TestCase): + def setUp(self): + create_records() + + def tearDown(self): + frappe.set_user("Administrator") diff --git a/erpnext/selling/doctype/party_specific_items/__init__.py b/erpnext/selling/doctype/party_specific_items/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/erpnext/selling/doctype/party_specific_items/party_specific_items.js b/erpnext/selling/doctype/party_specific_items/party_specific_items.js deleted file mode 100644 index 3c4f5ad6a64f..000000000000 --- a/erpnext/selling/doctype/party_specific_items/party_specific_items.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors -// For license information, please see license.txt - -frappe.ui.form.on('Party Specific Items', { - // refresh: function(frm) { - - // } -}); diff --git a/erpnext/selling/doctype/party_specific_items/test_party_specific_items.py b/erpnext/selling/doctype/party_specific_items/test_party_specific_items.py deleted file mode 100644 index 0796e49d8841..000000000000 --- a/erpnext/selling/doctype/party_specific_items/test_party_specific_items.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors -# See license.txt - -# import frappe -import unittest - -class TestPartySpecificItems(unittest.TestCase): - pass From 0cdfdee9c4cf44b9afedc8471c50c40155a277fa Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Mon, 6 Sep 2021 11:25:08 +0530 Subject: [PATCH 06/11] add tests for party specific item feature --- .../test_party_specific_item.py | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py index c1876736efb6..5e49d263f59f 100644 --- a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py +++ b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py @@ -4,13 +4,49 @@ import frappe import unittest +from erpnext.controllers.queries import item_query -def create_records(): - pass + +item_records = frappe.get_test_records('Item') +customer_records = frappe.get_test_records('Customer') +supplier_records = frappe.get_test_records('Supplier') + +def create_party_specific_item(**args): + psi = frappe.new_doc("Party Specific Item") + psi.party_type = args.get('party_type') + psi.party = args.get('party') + psi.restrict_based_on = args.get('restrict_based_on') + psi.based_on_value = args.get('based_on_value') + psi.insert() class TestPartySpecificItem(unittest.TestCase): def setUp(self): - create_records() + frappe.db.delete("Party Specific Item") + frappe.db.delete("Item") + frappe.db.delete("Customer") + frappe.db.delete("Supplier") + + for i in range(5): + frappe.get_doc(item_records[i]).insert() + + self.item = frappe.get_last_doc("Item") + self.customer = frappe.get_doc(customer_records[0]).insert() + self.supplier = frappe.get_doc(supplier_records[0]).insert() + self.test_user = "test1@example.com" + + def test_item_query_for_customer(self): + create_party_specific_item(party_type='Customer', party=self.customer.name, restrict_based_on='Item', based_on_value=self.item.name) + filters = {'is_sales_item': 1, 'customer': self.customer.name} + items = item_query(doctype= 'Item', txt= '', searchfield= 'name', start= 0, page_len= 20,filters=filters, as_dict= False) + for item in items: + self.assertEqual(item[0], self.item.name) + + def test_item_query_for_supplier(self): + create_party_specific_item(party_type='Supplier', party=self.supplier.name, restrict_based_on='Item Group', based_on_value=self.item.item_group) + filters = {'supplier': self.supplier.name, 'is_purchase_item': 1} + items = item_query(doctype= 'Item', txt= '', searchfield= 'name', start= 0, page_len= 20,filters=filters, as_dict= False) + for item in items: + self.assertEqual(item[2], self.item.item_group) def tearDown(self): frappe.set_user("Administrator") From ba8899e13cdbc5c8950815200783a476cfa86885 Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Mon, 6 Sep 2021 17:39:51 +0530 Subject: [PATCH 07/11] link party specific item on supplier and customer doctype --- erpnext/buying/doctype/supplier/supplier.json | 10 ++++----- .../selling/doctype/customer/customer.json | 22 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json index bfae747425ec..12a09cdd0ec9 100644 --- a/erpnext/buying/doctype/supplier/supplier.json +++ b/erpnext/buying/doctype/supplier/supplier.json @@ -433,12 +433,12 @@ "image_field": "image", "links": [ { - "group": "Item Group", - "link_doctype": "Supplier Item Group", - "link_fieldname": "supplier" + "group": "Allowed Items", + "link_doctype": "Party Specific Item", + "link_fieldname": "party" } ], - "modified": "2021-08-27 18:02:44.314077", + "modified": "2021-09-06 17:37:56.522233", "modified_by": "Administrator", "module": "Buying", "name": "Supplier", @@ -504,4 +504,4 @@ "sort_order": "ASC", "title_field": "supplier_name", "track_changes": 1 -} +} \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json index 5913b849eb78..e811435e669c 100644 --- a/erpnext/selling/doctype/customer/customer.json +++ b/erpnext/selling/doctype/customer/customer.json @@ -20,7 +20,6 @@ "tax_withholding_category", "default_bank_account", "lead_name", - "prospect", "opportunity_name", "image", "column_break0", @@ -214,7 +213,8 @@ "fieldtype": "Link", "ignore_user_permissions": 1, "label": "Represents Company", - "options": "Company" + "options": "Company", + "unique": 1 }, { "depends_on": "represents_company", @@ -497,14 +497,6 @@ "label": "Tax Withholding Category", "options": "Tax Withholding Category" }, - { - "fieldname": "prospect", - "fieldtype": "Link", - "label": "Prospect", - "no_copy": 1, - "options": "Prospect", - "print_hide": 1 - }, { "fieldname": "opportunity_name", "fieldtype": "Link", @@ -518,8 +510,14 @@ "idx": 363, "image_field": "image", "index_web_pages_for_search": 1, - "links": [], - "modified": "2021-08-25 18:56:09.929905", + "links": [ + { + "group": "Allowed Items", + "link_doctype": "Party Specific Item", + "link_fieldname": "party" + } + ], + "modified": "2021-09-06 17:38:54.196663", "modified_by": "Administrator", "module": "Selling", "name": "Customer", From 23bb220f048a0cfd6b1073650b0b7a85dc675a61 Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Mon, 6 Sep 2021 17:58:03 +0530 Subject: [PATCH 08/11] fix imports order --- .../replace_supplier_item_group_with_party_specific_item.py | 1 + .../doctype/party_specific_item/party_specific_item.py | 1 + .../doctype/party_specific_item/test_party_specific_item.py | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py index be23566c4e88..c546cacfdfca 100644 --- a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py +++ b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py @@ -3,6 +3,7 @@ import frappe + def execute(): if frappe.db.table_exists('Supplier Item Group'): frappe.reload_doc("buying", "doctype", "supplier_item_group") diff --git a/erpnext/selling/doctype/party_specific_item/party_specific_item.py b/erpnext/selling/doctype/party_specific_item/party_specific_item.py index 8a88a40f4aae..aaa64d12c0fd 100644 --- a/erpnext/selling/doctype/party_specific_item/party_specific_item.py +++ b/erpnext/selling/doctype/party_specific_item/party_specific_item.py @@ -5,6 +5,7 @@ from frappe import _ from frappe.model.document import Document + class PartySpecificItem(Document): def validate(self): exists = frappe.db.exists({ diff --git a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py index 5e49d263f59f..f288c84a5b9e 100644 --- a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py +++ b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py @@ -1,11 +1,11 @@ # Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt -import frappe import unittest -from erpnext.controllers.queries import item_query +import frappe +from erpnext.controllers.queries import item_query item_records = frappe.get_test_records('Item') customer_records = frappe.get_test_records('Customer') From 8fe333f9295916e2072ecb81b924c1a3158bc530 Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Wed, 8 Sep 2021 01:02:02 +0530 Subject: [PATCH 09/11] fix tests --- .../test_party_specific_item.py | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py index f288c84a5b9e..874a36459294 100644 --- a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py +++ b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py @@ -7,9 +7,7 @@ from erpnext.controllers.queries import item_query -item_records = frappe.get_test_records('Item') -customer_records = frappe.get_test_records('Customer') -supplier_records = frappe.get_test_records('Supplier') +test_dependencies = ['Item', 'Customer', 'Supplier'] def create_party_specific_item(**args): psi = frappe.new_doc("Party Specific Item") @@ -21,18 +19,9 @@ def create_party_specific_item(**args): class TestPartySpecificItem(unittest.TestCase): def setUp(self): - frappe.db.delete("Party Specific Item") - frappe.db.delete("Item") - frappe.db.delete("Customer") - frappe.db.delete("Supplier") - - for i in range(5): - frappe.get_doc(item_records[i]).insert() - + self.customer = frappe.get_last_doc("Customer") + self.supplier = frappe.get_last_doc("Supplier") self.item = frappe.get_last_doc("Item") - self.customer = frappe.get_doc(customer_records[0]).insert() - self.supplier = frappe.get_doc(supplier_records[0]).insert() - self.test_user = "test1@example.com" def test_item_query_for_customer(self): create_party_specific_item(party_type='Customer', party=self.customer.name, restrict_based_on='Item', based_on_value=self.item.name) @@ -47,6 +36,3 @@ def test_item_query_for_supplier(self): items = item_query(doctype= 'Item', txt= '', searchfield= 'name', start= 0, page_len= 20,filters=filters, as_dict= False) for item in items: self.assertEqual(item[2], self.item.item_group) - - def tearDown(self): - frappe.set_user("Administrator") From 6dce933e15e688fe0dc62e3fdb47c70b102ed8fd Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Thu, 9 Sep 2021 19:08:34 +0530 Subject: [PATCH 10/11] damn rename --- .../selling/doctype/party_specific_item/party_specific_item.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/party_specific_item/party_specific_item.py b/erpnext/selling/doctype/party_specific_item/party_specific_item.py index aaa64d12c0fd..a408af564201 100644 --- a/erpnext/selling/doctype/party_specific_item/party_specific_item.py +++ b/erpnext/selling/doctype/party_specific_item/party_specific_item.py @@ -9,7 +9,7 @@ class PartySpecificItem(Document): def validate(self): exists = frappe.db.exists({ - 'doctype': 'Party Specific Items', + 'doctype': 'Party Specific Item', 'party_type': self.party_type, 'party': self.party, 'restrict_based_on': self.restrict_based_on, From 038518a764f90d88d02ada9d8eeb79315029a906 Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Tue, 14 Sep 2021 13:30:05 +0530 Subject: [PATCH 11/11] minor doctype changes for party specific item --- .../replace_supplier_item_group_with_party_specific_item.py | 2 +- .../doctype/party_specific_item/party_specific_item.json | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py index c546cacfdfca..ba96fdd22660 100644 --- a/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py +++ b/erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py @@ -6,7 +6,7 @@ def execute(): if frappe.db.table_exists('Supplier Item Group'): - frappe.reload_doc("buying", "doctype", "supplier_item_group") + frappe.reload_doc("selling", "doctype", "party_specific_item") sig = frappe.db.get_all("Supplier Item Group", fields=["name", "supplier", "item_group"]) for item in sig: psi = frappe.new_doc("Party Specific Item") diff --git a/erpnext/selling/doctype/party_specific_item/party_specific_item.json b/erpnext/selling/doctype/party_specific_item/party_specific_item.json index 26413885de16..32b5d478bb53 100644 --- a/erpnext/selling/doctype/party_specific_item/party_specific_item.json +++ b/erpnext/selling/doctype/party_specific_item/party_specific_item.json @@ -24,7 +24,7 @@ "fieldname": "party", "fieldtype": "Dynamic Link", "in_list_view": 1, - "label": "Party", + "label": "Party Name", "options": "party_type", "reqd": 1 }, @@ -51,7 +51,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-09-02 17:36:37.337094", + "modified": "2021-09-14 13:27:58.612334", "modified_by": "Administrator", "module": "Selling", "name": "Party Specific Item", @@ -72,5 +72,6 @@ ], "sort_field": "modified", "sort_order": "DESC", + "title_field": "party", "track_changes": 1 } \ No newline at end of file