From 4d2e782e42e9875429b5c55934c41dbc5d1d7b20 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Fri, 28 Jul 2017 15:21:22 +0530 Subject: [PATCH 1/4] [Fix] Error in sales invoice and POS if customer group not defined in the customer (#10148) --- .../doctype/pos_profile/pos_profile.json | 146 ++++++++++++++---- .../doctype/pos_profile/pos_profile.py | 8 + .../doctype/pos_profile/test_pos_profile.js | 23 +++ .../doctype/pos_profile/test_pos_profile.py | 1 + erpnext/accounts/doctype/sales_invoice/pos.py | 20 ++- erpnext/accounts/page/pos/pos.js | 2 + erpnext/accounts/party.py | 5 +- erpnext/patches.txt | 3 +- .../update_customer_group_in_POS_profile.py | 8 + 9 files changed, 183 insertions(+), 33 deletions(-) create mode 100644 erpnext/accounts/doctype/pos_profile/test_pos_profile.js create mode 100644 erpnext/patches/v8_5/update_customer_group_in_POS_profile.py diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json index 93aca1b36175..6991da2888ab 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.json +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json @@ -721,6 +721,67 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break0", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "selling_price_list", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Price List", + "length": 0, + "no_copy": 0, + "oldfieldname": "price_list_name", + "oldfieldtype": "Select", + "options": "Price List", + "permlevel": 0, + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -759,8 +820,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "column_break0", - "fieldtype": "Column Break", + "fieldname": "apply_discount", + "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -768,10 +829,11 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, + "label": "Apply Discount", "length": 0, "no_copy": 0, - "oldfieldtype": "Column Break", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -788,23 +850,23 @@ "bold": 0, "collapsible": 0, "columns": 0, - "description": "", - "fieldname": "territory", - "fieldtype": "Link", + "default": "Grand Total", + "depends_on": "apply_discount", + "fieldname": "apply_discount_on", + "fieldtype": "Select", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_global_search": 0, - "in_list_view": 1, + "in_list_view": 0, "in_standard_filter": 0, - "label": "Territory", + "label": "Apply Discount On", "length": 0, "no_copy": 0, - "oldfieldname": "territory", - "oldfieldtype": "Link", - "options": "Territory", + "options": "Grand Total\nNet Total", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -821,8 +883,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "selling_price_list", - "fieldtype": "Link", + "fieldname": "customer_details", + "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -830,13 +892,11 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Price List", + "label": "New Customer Details", "length": 0, "no_copy": 0, - "oldfieldname": "price_list_name", - "oldfieldtype": "Select", - "options": "Price List", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -853,8 +913,41 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "apply_discount", - "fieldtype": "Check", + "description": "", + "fieldname": "territory", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Territory", + "length": 0, + "no_copy": 0, + "oldfieldname": "territory", + "oldfieldtype": "Link", + "options": "Territory", + "permlevel": 0, + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_31", + "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -862,7 +955,6 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Apply Discount", "length": 0, "no_copy": 0, "permlevel": 0, @@ -883,10 +975,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "Grand Total", - "depends_on": "apply_discount", - "fieldname": "apply_discount_on", - "fieldtype": "Select", + "fieldname": "customer_group", + "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -894,10 +984,10 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Apply Discount On", + "label": "Customer Group", "length": 0, "no_copy": 0, - "options": "Grand Total\nNet Total", + "options": "Customer Group", "permlevel": 0, "precision": "", "print_hide": 0, @@ -905,7 +995,7 @@ "read_only": 0, "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 0, + "reqd": 1, "search_index": 0, "set_only_once": 0, "unique": 0 @@ -1201,7 +1291,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-06-16 17:04:33.165676", + "modified": "2017-07-28 03:40:03.253088", "modified_by": "Administrator", "module": "Accounts", "name": "POS Profile", diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py index ef497bfe29f4..86682d3c2a96 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py @@ -14,6 +14,7 @@ def validate(self): self.check_for_duplicate() self.validate_all_link_fields() self.validate_duplicate_groups() + self.validate_customer_territory_group() def check_for_duplicate(self): res = frappe.db.sql("""select name, user from `tabPOS Profile` @@ -48,6 +49,13 @@ def validate_duplicate_groups(self): if len(customer_groups) != len(set(customer_groups)): frappe.throw(_("Duplicate customer group found in the cutomer group table"), title = "Duplicate Customer Group") + def validate_customer_territory_group(self): + if not self.territory: + frappe.throw(_("Territory is Required in POS Profile"), title="Mandatory Field") + + if not self.customer_group: + frappe.throw(_("Customer Group is Required in POS Profile"), title="Mandatory Field") + def before_save(self): set_account_for_mode_of_payment(self) diff --git a/erpnext/accounts/doctype/pos_profile/test_pos_profile.js b/erpnext/accounts/doctype/pos_profile/test_pos_profile.js new file mode 100644 index 000000000000..42e5b7f92f11 --- /dev/null +++ b/erpnext/accounts/doctype/pos_profile/test_pos_profile.js @@ -0,0 +1,23 @@ +/* eslint-disable */ +// rename this file from _test_[name] to test_[name] to activate +// and remove above this line + +QUnit.test("test: POS Profile", function (assert) { + let done = assert.async(); + + // number of asserts + assert.expect(1); + + frappe.run_serially('POS Profile', [ + // insert a new POS Profile + () => frappe.tests.make([ + // values to be set + {key: 'value'} + ]), + () => { + assert.equal(cur_frm.doc.key, 'value'); + }, + () => done() + ]); + +}); diff --git a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py index 9c6a11487c5e..534abb65fa41 100644 --- a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py @@ -42,6 +42,7 @@ def make_pos_profile(): "naming_series": "_T-POS Profile-", "selling_price_list": "_Test Price List", "territory": "_Test Territory", + "customer_group": frappe.db.get_value('Customer Group', {'is_group': 0}, 'name'), "warehouse": "_Test Warehouse - _TC", "write_off_account": "_Test Write Off - _TC", "write_off_cost_center": "_Test Write Off Cost Center - _TC" diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index f61931a562b3..3c9de12fc012 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import frappe, json +from frappe import _ from frappe.utils import nowdate from erpnext.setup.utils import get_exchange_rate from frappe.core.doctype.communication.email import make @@ -20,6 +21,7 @@ def get_pos_data(): if pos_profile.get('name'): pos_profile = frappe.get_doc('POS Profile', pos_profile.get('name')) + pos_profile.validate() company_data = get_company_data(doc.company) update_pos_profile_data(doc, pos_profile, company_data) @@ -378,13 +380,27 @@ def add_customer(data): customer_doc.customer_name = data.get('full_name') or data.get('customer') customer_doc.customer_pos_id = data.get('customer_pos_id') customer_doc.customer_type = 'Company' - customer_doc.customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group') - customer_doc.territory = frappe.db.get_single_value('Selling Settings', 'territory') + customer_doc.customer_group = get_customer_group(data) + customer_doc.territory = get_territory(data) customer_doc.flags.ignore_mandatory = True customer_doc.save(ignore_permissions = True) frappe.db.commit() return customer_doc.name +def get_territory(data): + if data.get('territory'): + return data.get('territory') + + return frappe.db.get_single_value('Selling Settings', + 'territory') or _('All Territories') + +def get_customer_group(data): + if data.get('customer_group'): + return data.get('customer_group') + + return frappe.db.get_single_value('Selling Settings', + 'customer_group') or frappe.db.get_value('Customer Group', {'is_group': 0}, 'name') + def make_contact(args,customer): if args.get('email_id') or args.get('phone'): name = frappe.db.get_value('Dynamic Link', diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index a5f9b3c2863f..d69a30667069 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -979,6 +979,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ get_prompt_details: function() { this.prompt_details = this.customer_doc.get_values(); this.prompt_details['country'] = this.pos_profile_data.country; + this.prompt_details['territory'] = this.pos_profile_data["territory"]; + this.prompt_details['customer_group'] = this.pos_profile_data["customer_group"]; this.prompt_details['customer_pos_id'] = this.customer_doc.fields_dict.customer_pos_id.value; return JSON.stringify(this.prompt_details) }, diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 005abe646d3d..0f8b92ffc97e 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -273,6 +273,7 @@ def get_due_date(posting_date, party_type, party, company): return due_date def get_credit_days(party_type, party, company): + credit_days = 0 if party_type and party: if party_type == "Customer": credit_days_based_on, credit_days, customer_group = \ @@ -282,10 +283,10 @@ def get_credit_days(party_type, party, company): frappe.db.get_value(party_type, party, ["credit_days_based_on", "credit_days", "supplier_type"]) if not credit_days_based_on: - if party_type == "Customer": + if party_type == "Customer" and customer_group: credit_days_based_on, credit_days = \ frappe.db.get_value("Customer Group", customer_group, ["credit_days_based_on", "credit_days"]) - else: + elif party_type == "Supplier" and supplier_type: credit_days_based_on, credit_days = \ frappe.db.get_value("Supplier Type", supplier_type, ["credit_days_based_on", "credit_days"]) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index fb8f02e94b57..e3a2e58b277d 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -423,4 +423,5 @@ erpnext.patches.v8_3.set_restrict_to_domain_for_module_def erpnext.patches.v8_1.update_expense_claim_status erpnext.patches.v8_3.update_company_total_sales erpnext.patches.v8_1.set_delivery_date_in_so_item -erpnext.patches.v8_5.fix_tax_breakup_for_non_invoice_docs \ No newline at end of file +erpnext.patches.v8_5.fix_tax_breakup_for_non_invoice_docs +erpnext.patches.v8_5.update_customer_group_in_POS_profile \ No newline at end of file diff --git a/erpnext/patches/v8_5/update_customer_group_in_POS_profile.py b/erpnext/patches/v8_5/update_customer_group_in_POS_profile.py new file mode 100644 index 000000000000..9a5fef90c86a --- /dev/null +++ b/erpnext/patches/v8_5/update_customer_group_in_POS_profile.py @@ -0,0 +1,8 @@ +import frappe + +def execute(): + frappe.reload_doctype('POS Profile') + customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group') + if customer_group: + frappe.db.sql(""" update `tabPOS Profile` + set customer_group = %s where customer_group is null """, (customer_group)) \ No newline at end of file From 8bccaed35af93c8ef51666b0b851b26c7d32912b Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Fri, 28 Jul 2017 15:43:23 +0530 Subject: [PATCH 2/4] Revert "[Fix] Error in sales invoice and POS if customer group not defined in the customer (#10148)" (#10159) This reverts commit 4d2e782e42e9875429b5c55934c41dbc5d1d7b20. --- .../doctype/pos_profile/pos_profile.json | 146 ++++-------------- .../doctype/pos_profile/pos_profile.py | 8 - .../doctype/pos_profile/test_pos_profile.js | 23 --- .../doctype/pos_profile/test_pos_profile.py | 1 - erpnext/accounts/doctype/sales_invoice/pos.py | 20 +-- erpnext/accounts/page/pos/pos.js | 2 - erpnext/accounts/party.py | 5 +- erpnext/patches.txt | 3 +- .../update_customer_group_in_POS_profile.py | 8 - 9 files changed, 33 insertions(+), 183 deletions(-) delete mode 100644 erpnext/accounts/doctype/pos_profile/test_pos_profile.js delete mode 100644 erpnext/patches/v8_5/update_customer_group_in_POS_profile.py diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json index 6991da2888ab..93aca1b36175 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.json +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json @@ -721,67 +721,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break0", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "oldfieldtype": "Column Break", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "selling_price_list", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Price List", - "length": 0, - "no_copy": 0, - "oldfieldname": "price_list_name", - "oldfieldtype": "Select", - "options": "Price List", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -820,8 +759,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "apply_discount", - "fieldtype": "Check", + "fieldname": "column_break0", + "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -829,11 +768,10 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Apply Discount", "length": 0, "no_copy": 0, + "oldfieldtype": "Column Break", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -850,23 +788,23 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "Grand Total", - "depends_on": "apply_discount", - "fieldname": "apply_discount_on", - "fieldtype": "Select", + "description": "", + "fieldname": "territory", + "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_global_search": 0, - "in_list_view": 0, + "in_list_view": 1, "in_standard_filter": 0, - "label": "Apply Discount On", + "label": "Territory", "length": 0, "no_copy": 0, - "options": "Grand Total\nNet Total", + "oldfieldname": "territory", + "oldfieldtype": "Link", + "options": "Territory", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -883,8 +821,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "customer_details", - "fieldtype": "Section Break", + "fieldname": "selling_price_list", + "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -892,11 +830,13 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "New Customer Details", + "label": "Price List", "length": 0, "no_copy": 0, + "oldfieldname": "price_list_name", + "oldfieldtype": "Select", + "options": "Price List", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -913,41 +853,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "description": "", - "fieldname": "territory", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Territory", - "length": 0, - "no_copy": 0, - "oldfieldname": "territory", - "oldfieldtype": "Link", - "options": "Territory", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break_31", - "fieldtype": "Column Break", + "fieldname": "apply_discount", + "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -955,6 +862,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, + "label": "Apply Discount", "length": 0, "no_copy": 0, "permlevel": 0, @@ -975,8 +883,10 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "customer_group", - "fieldtype": "Link", + "default": "Grand Total", + "depends_on": "apply_discount", + "fieldname": "apply_discount_on", + "fieldtype": "Select", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -984,10 +894,10 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Customer Group", + "label": "Apply Discount On", "length": 0, "no_copy": 0, - "options": "Customer Group", + "options": "Grand Total\nNet Total", "permlevel": 0, "precision": "", "print_hide": 0, @@ -995,7 +905,7 @@ "read_only": 0, "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 1, + "reqd": 0, "search_index": 0, "set_only_once": 0, "unique": 0 @@ -1291,7 +1201,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-07-28 03:40:03.253088", + "modified": "2017-06-16 17:04:33.165676", "modified_by": "Administrator", "module": "Accounts", "name": "POS Profile", diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py index 86682d3c2a96..ef497bfe29f4 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py @@ -14,7 +14,6 @@ def validate(self): self.check_for_duplicate() self.validate_all_link_fields() self.validate_duplicate_groups() - self.validate_customer_territory_group() def check_for_duplicate(self): res = frappe.db.sql("""select name, user from `tabPOS Profile` @@ -49,13 +48,6 @@ def validate_duplicate_groups(self): if len(customer_groups) != len(set(customer_groups)): frappe.throw(_("Duplicate customer group found in the cutomer group table"), title = "Duplicate Customer Group") - def validate_customer_territory_group(self): - if not self.territory: - frappe.throw(_("Territory is Required in POS Profile"), title="Mandatory Field") - - if not self.customer_group: - frappe.throw(_("Customer Group is Required in POS Profile"), title="Mandatory Field") - def before_save(self): set_account_for_mode_of_payment(self) diff --git a/erpnext/accounts/doctype/pos_profile/test_pos_profile.js b/erpnext/accounts/doctype/pos_profile/test_pos_profile.js deleted file mode 100644 index 42e5b7f92f11..000000000000 --- a/erpnext/accounts/doctype/pos_profile/test_pos_profile.js +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable */ -// rename this file from _test_[name] to test_[name] to activate -// and remove above this line - -QUnit.test("test: POS Profile", function (assert) { - let done = assert.async(); - - // number of asserts - assert.expect(1); - - frappe.run_serially('POS Profile', [ - // insert a new POS Profile - () => frappe.tests.make([ - // values to be set - {key: 'value'} - ]), - () => { - assert.equal(cur_frm.doc.key, 'value'); - }, - () => done() - ]); - -}); diff --git a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py index 534abb65fa41..9c6a11487c5e 100644 --- a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py @@ -42,7 +42,6 @@ def make_pos_profile(): "naming_series": "_T-POS Profile-", "selling_price_list": "_Test Price List", "territory": "_Test Territory", - "customer_group": frappe.db.get_value('Customer Group', {'is_group': 0}, 'name'), "warehouse": "_Test Warehouse - _TC", "write_off_account": "_Test Write Off - _TC", "write_off_cost_center": "_Test Write Off Cost Center - _TC" diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index 3c9de12fc012..f61931a562b3 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import frappe, json -from frappe import _ from frappe.utils import nowdate from erpnext.setup.utils import get_exchange_rate from frappe.core.doctype.communication.email import make @@ -21,7 +20,6 @@ def get_pos_data(): if pos_profile.get('name'): pos_profile = frappe.get_doc('POS Profile', pos_profile.get('name')) - pos_profile.validate() company_data = get_company_data(doc.company) update_pos_profile_data(doc, pos_profile, company_data) @@ -380,27 +378,13 @@ def add_customer(data): customer_doc.customer_name = data.get('full_name') or data.get('customer') customer_doc.customer_pos_id = data.get('customer_pos_id') customer_doc.customer_type = 'Company' - customer_doc.customer_group = get_customer_group(data) - customer_doc.territory = get_territory(data) + customer_doc.customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group') + customer_doc.territory = frappe.db.get_single_value('Selling Settings', 'territory') customer_doc.flags.ignore_mandatory = True customer_doc.save(ignore_permissions = True) frappe.db.commit() return customer_doc.name -def get_territory(data): - if data.get('territory'): - return data.get('territory') - - return frappe.db.get_single_value('Selling Settings', - 'territory') or _('All Territories') - -def get_customer_group(data): - if data.get('customer_group'): - return data.get('customer_group') - - return frappe.db.get_single_value('Selling Settings', - 'customer_group') or frappe.db.get_value('Customer Group', {'is_group': 0}, 'name') - def make_contact(args,customer): if args.get('email_id') or args.get('phone'): name = frappe.db.get_value('Dynamic Link', diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index d69a30667069..a5f9b3c2863f 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -979,8 +979,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ get_prompt_details: function() { this.prompt_details = this.customer_doc.get_values(); this.prompt_details['country'] = this.pos_profile_data.country; - this.prompt_details['territory'] = this.pos_profile_data["territory"]; - this.prompt_details['customer_group'] = this.pos_profile_data["customer_group"]; this.prompt_details['customer_pos_id'] = this.customer_doc.fields_dict.customer_pos_id.value; return JSON.stringify(this.prompt_details) }, diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 0f8b92ffc97e..005abe646d3d 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -273,7 +273,6 @@ def get_due_date(posting_date, party_type, party, company): return due_date def get_credit_days(party_type, party, company): - credit_days = 0 if party_type and party: if party_type == "Customer": credit_days_based_on, credit_days, customer_group = \ @@ -283,10 +282,10 @@ def get_credit_days(party_type, party, company): frappe.db.get_value(party_type, party, ["credit_days_based_on", "credit_days", "supplier_type"]) if not credit_days_based_on: - if party_type == "Customer" and customer_group: + if party_type == "Customer": credit_days_based_on, credit_days = \ frappe.db.get_value("Customer Group", customer_group, ["credit_days_based_on", "credit_days"]) - elif party_type == "Supplier" and supplier_type: + else: credit_days_based_on, credit_days = \ frappe.db.get_value("Supplier Type", supplier_type, ["credit_days_based_on", "credit_days"]) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e3a2e58b277d..fb8f02e94b57 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -423,5 +423,4 @@ erpnext.patches.v8_3.set_restrict_to_domain_for_module_def erpnext.patches.v8_1.update_expense_claim_status erpnext.patches.v8_3.update_company_total_sales erpnext.patches.v8_1.set_delivery_date_in_so_item -erpnext.patches.v8_5.fix_tax_breakup_for_non_invoice_docs -erpnext.patches.v8_5.update_customer_group_in_POS_profile \ No newline at end of file +erpnext.patches.v8_5.fix_tax_breakup_for_non_invoice_docs \ No newline at end of file diff --git a/erpnext/patches/v8_5/update_customer_group_in_POS_profile.py b/erpnext/patches/v8_5/update_customer_group_in_POS_profile.py deleted file mode 100644 index 9a5fef90c86a..000000000000 --- a/erpnext/patches/v8_5/update_customer_group_in_POS_profile.py +++ /dev/null @@ -1,8 +0,0 @@ -import frappe - -def execute(): - frappe.reload_doctype('POS Profile') - customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group') - if customer_group: - frappe.db.sql(""" update `tabPOS Profile` - set customer_group = %s where customer_group is null """, (customer_group)) \ No newline at end of file From 353af64197675e431c6fa84b0624723dcc8667b3 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Fri, 28 Jul 2017 15:55:46 +0530 Subject: [PATCH 3/4] [Fix] Unable to save asset because of float error issue (#10157) --- erpnext/accounts/doctype/asset/asset.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/asset/asset.py b/erpnext/accounts/doctype/asset/asset.py index 986beb76a31d..dd1e4916803a 100644 --- a/erpnext/accounts/doctype/asset/asset.py +++ b/erpnext/accounts/doctype/asset/asset.py @@ -147,8 +147,9 @@ def validate_expected_value_after_useful_life(self): accumulated_depreciation_after_full_schedule = \ max([d.accumulated_depreciation_amount for d in self.get("schedules")]) - asset_value_after_full_schedule = (flt(self.gross_purchase_amount) - - flt(accumulated_depreciation_after_full_schedule)) + asset_value_after_full_schedule = flt(flt(self.gross_purchase_amount) - + flt(accumulated_depreciation_after_full_schedule), + self.precision('expected_value_after_useful_life')) if self.expected_value_after_useful_life < asset_value_after_full_schedule: frappe.throw(_("Expected value after useful life must be greater than or equal to {0}") From 2b420f7038de0887c485fa6638ae96b885bec562 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Fri, 28 Jul 2017 16:33:52 +0600 Subject: [PATCH 4/4] bumped to version 8.6.4 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index b0692038f8bd..7ee4dee416df 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -4,7 +4,7 @@ import frappe from erpnext.hooks import regional_overrides -__version__ = '8.6.3' +__version__ = '8.6.4' def get_default_company(user=None): '''Get default company for user'''