diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 7ec27538010..31ecd294e57 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -434,4 +434,5 @@ erpnext.patches.v8_6.set_write_permission_for_quotation_for_sales_manager erpnext.patches.v8_5.remove_project_type_property_setter erpnext.patches.v8_7.add_more_gst_fields erpnext.patches.v8_7.fix_purchase_receipt_status -erpnext.patches.v8_6.rename_bom_update_tool \ No newline at end of file +erpnext.patches.v8_6.rename_bom_update_tool +erpnext.patches.v8_9.set_default_customer_group diff --git a/erpnext/patches/v8_9/__init__.py b/erpnext/patches/v8_9/__init__.py new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/erpnext/patches/v8_9/__init__.py @@ -0,0 +1 @@ + diff --git a/erpnext/patches/v8_9/set_default_customer_group.py b/erpnext/patches/v8_9/set_default_customer_group.py new file mode 100644 index 00000000000..b121998b2bc --- /dev/null +++ b/erpnext/patches/v8_9/set_default_customer_group.py @@ -0,0 +1,6 @@ +import frappe + +def execute(): + selling_settings = frappe.get_single('Selling Settings') + selling_settings.set_default_customer_group_and_territory() + selling_settings.save() diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.py b/erpnext/selling/doctype/selling_settings/selling_settings.py index ee7d203d007..d2978838763 100644 --- a/erpnext/selling/doctype/selling_settings/selling_settings.py +++ b/erpnext/selling/doctype/selling_settings/selling_settings.py @@ -8,6 +8,7 @@ import frappe import frappe.defaults from frappe.utils import cint from frappe.custom.doctype.property_setter.property_setter import make_property_setter +from frappe.utils.nestedset import get_root_of from frappe.model.document import Document @@ -31,3 +32,9 @@ class SellingSettings(Document): for doctype in ("Sales Order", "Sales Invoice", "Delivery Note"): make_property_setter(doctype, "tax_id", "hidden", self.hide_tax_id, "Check") make_property_setter(doctype, "tax_id", "print_hide", self.hide_tax_id, "Check") + + def set_default_customer_group_and_territory(self): + if not self.customer_group: + self.customer_group = get_root_of('Customer Group') + if not self.territory: + self.territory = get_root_of('Territory') diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py index 4dec3d75f79..c40ad55f8bd 100644 --- a/erpnext/setup/setup_wizard/setup_wizard.py +++ b/erpnext/setup/setup_wizard/setup_wizard.py @@ -176,6 +176,7 @@ def set_defaults(args): selling_settings.so_required = "No" selling_settings.dn_required = "No" selling_settings.allow_multiple_items = 1 + selling_settings.set_default_customer_group_and_territory() selling_settings.save() buying_settings = frappe.get_doc("Buying Settings") diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py index 6b503b3eec2..31643061091 100644 --- a/erpnext/startup/boot.py +++ b/erpnext/startup/boot.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals import frappe -from frappe.utils.nestedset import get_root_of def boot_session(bootinfo): """boot session - send website info if guest""" @@ -17,9 +16,9 @@ def boot_session(bootinfo): load_country_and_currency(bootinfo) bootinfo.sysdefaults.territory = frappe.db.get_single_value('Selling Settings', - 'territory') or get_root_of('Territory') + 'territory') bootinfo.sysdefaults.customer_group = frappe.db.get_single_value('Selling Settings', - 'customer_group') or get_root_of('Customer Group') + 'customer_group') bootinfo.notification_settings = frappe.get_doc("Notification Control", "Notification Control")