[Fix] Error in sales invoice and POS if customer group not defined in the customer (#10160)
This commit is contained in:
parent
9d5b1b0e8f
commit
e2176b852e
@ -721,38 +721,6 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "tc_name",
|
|
||||||
"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": "Terms and Conditions",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "tc_name",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Terms and Conditions",
|
|
||||||
"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_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -782,39 +750,6 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"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": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -847,6 +782,38 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "tc_name",
|
||||||
|
"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": "Terms and Conditions",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "tc_name",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Terms and Conditions",
|
||||||
|
"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_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -910,6 +877,129 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "customer_details",
|
||||||
|
"fieldtype": "Section 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,
|
||||||
|
"label": "New Customer Details",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"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,
|
||||||
|
"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,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"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": "customer_group",
|
||||||
|
"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": "Customer Group",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "Customer Group",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"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_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -1201,7 +1291,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-06-16 17:04:33.165676",
|
"modified": "2017-07-28 03:40:03.253088",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "POS Profile",
|
"name": "POS Profile",
|
||||||
|
@ -14,6 +14,7 @@ class POSProfile(Document):
|
|||||||
self.check_for_duplicate()
|
self.check_for_duplicate()
|
||||||
self.validate_all_link_fields()
|
self.validate_all_link_fields()
|
||||||
self.validate_duplicate_groups()
|
self.validate_duplicate_groups()
|
||||||
|
self.validate_customer_territory_group()
|
||||||
|
|
||||||
def check_for_duplicate(self):
|
def check_for_duplicate(self):
|
||||||
res = frappe.db.sql("""select name, user from `tabPOS Profile`
|
res = frappe.db.sql("""select name, user from `tabPOS Profile`
|
||||||
@ -48,6 +49,13 @@ class POSProfile(Document):
|
|||||||
if len(customer_groups) != len(set(customer_groups)):
|
if len(customer_groups) != len(set(customer_groups)):
|
||||||
frappe.throw(_("Duplicate customer group found in the cutomer group table"), title = "Duplicate Customer Group")
|
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):
|
def before_save(self):
|
||||||
set_account_for_mode_of_payment(self)
|
set_account_for_mode_of_payment(self)
|
||||||
|
|
||||||
|
23
erpnext/accounts/doctype/pos_profile/test_pos_profile.js
Normal file
23
erpnext/accounts/doctype/pos_profile/test_pos_profile.js
Normal file
@ -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()
|
||||||
|
]);
|
||||||
|
|
||||||
|
});
|
@ -42,6 +42,7 @@ def make_pos_profile():
|
|||||||
"naming_series": "_T-POS Profile-",
|
"naming_series": "_T-POS Profile-",
|
||||||
"selling_price_list": "_Test Price List",
|
"selling_price_list": "_Test Price List",
|
||||||
"territory": "_Test Territory",
|
"territory": "_Test Territory",
|
||||||
|
"customer_group": frappe.db.get_value('Customer Group', {'is_group': 0}, 'name'),
|
||||||
"warehouse": "_Test Warehouse - _TC",
|
"warehouse": "_Test Warehouse - _TC",
|
||||||
"write_off_account": "_Test Write Off - _TC",
|
"write_off_account": "_Test Write Off - _TC",
|
||||||
"write_off_cost_center": "_Test Write Off Cost Center - _TC"
|
"write_off_cost_center": "_Test Write Off Cost Center - _TC"
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, json
|
import frappe, json
|
||||||
|
from frappe import _
|
||||||
from frappe.utils import nowdate
|
from frappe.utils import nowdate
|
||||||
from erpnext.setup.utils import get_exchange_rate
|
from erpnext.setup.utils import get_exchange_rate
|
||||||
from frappe.core.doctype.communication.email import make
|
from frappe.core.doctype.communication.email import make
|
||||||
@ -20,6 +21,7 @@ def get_pos_data():
|
|||||||
|
|
||||||
if pos_profile.get('name'):
|
if pos_profile.get('name'):
|
||||||
pos_profile = frappe.get_doc('POS Profile', 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)
|
company_data = get_company_data(doc.company)
|
||||||
update_pos_profile_data(doc, pos_profile, company_data)
|
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_name = data.get('full_name') or data.get('customer')
|
||||||
customer_doc.customer_pos_id = data.get('customer_pos_id')
|
customer_doc.customer_pos_id = data.get('customer_pos_id')
|
||||||
customer_doc.customer_type = 'Company'
|
customer_doc.customer_type = 'Company'
|
||||||
customer_doc.customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group')
|
customer_doc.customer_group = get_customer_group(data)
|
||||||
customer_doc.territory = frappe.db.get_single_value('Selling Settings', 'territory')
|
customer_doc.territory = get_territory(data)
|
||||||
customer_doc.flags.ignore_mandatory = True
|
customer_doc.flags.ignore_mandatory = True
|
||||||
customer_doc.save(ignore_permissions = True)
|
customer_doc.save(ignore_permissions = True)
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
return customer_doc.name
|
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):
|
def make_contact(args,customer):
|
||||||
if args.get('email_id') or args.get('phone'):
|
if args.get('email_id') or args.get('phone'):
|
||||||
name = frappe.db.get_value('Dynamic Link',
|
name = frappe.db.get_value('Dynamic Link',
|
||||||
|
@ -979,6 +979,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
get_prompt_details: function() {
|
get_prompt_details: function() {
|
||||||
this.prompt_details = this.customer_doc.get_values();
|
this.prompt_details = this.customer_doc.get_values();
|
||||||
this.prompt_details['country'] = this.pos_profile_data.country;
|
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;
|
this.prompt_details['customer_pos_id'] = this.customer_doc.fields_dict.customer_pos_id.value;
|
||||||
return JSON.stringify(this.prompt_details)
|
return JSON.stringify(this.prompt_details)
|
||||||
},
|
},
|
||||||
|
@ -273,6 +273,7 @@ def get_due_date(posting_date, party_type, party, company):
|
|||||||
return due_date
|
return due_date
|
||||||
|
|
||||||
def get_credit_days(party_type, party, company):
|
def get_credit_days(party_type, party, company):
|
||||||
|
credit_days = 0
|
||||||
if party_type and party:
|
if party_type and party:
|
||||||
if party_type == "Customer":
|
if party_type == "Customer":
|
||||||
credit_days_based_on, credit_days, customer_group = \
|
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"])
|
frappe.db.get_value(party_type, party, ["credit_days_based_on", "credit_days", "supplier_type"])
|
||||||
|
|
||||||
if not credit_days_based_on:
|
if not credit_days_based_on:
|
||||||
if party_type == "Customer":
|
if party_type == "Customer" and customer_group:
|
||||||
credit_days_based_on, credit_days = \
|
credit_days_based_on, credit_days = \
|
||||||
frappe.db.get_value("Customer Group", 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 = \
|
credit_days_based_on, credit_days = \
|
||||||
frappe.db.get_value("Supplier Type", supplier_type, ["credit_days_based_on", "credit_days"])
|
frappe.db.get_value("Supplier Type", supplier_type, ["credit_days_based_on", "credit_days"])
|
||||||
|
|
||||||
|
@ -424,3 +424,4 @@ erpnext.patches.v8_1.update_expense_claim_status
|
|||||||
erpnext.patches.v8_3.update_company_total_sales
|
erpnext.patches.v8_3.update_company_total_sales
|
||||||
erpnext.patches.v8_1.set_delivery_date_in_so_item
|
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.fix_tax_breakup_for_non_invoice_docs
|
||||||
|
erpnext.patches.v8_5.update_customer_group_in_POS_profile
|
@ -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))
|
Loading…
x
Reference in New Issue
Block a user