From 4ce38059aca818da540a6dd3a02940678f169e83 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 6 Sep 2019 14:33:10 +0530 Subject: [PATCH] feat: Company wise credit limit --- .../doctype/sales_invoice/sales_invoice.py | 2 +- ...e_credit_limit_to_customer_credit_limit.py | 44 +- .../selling/doctype/customer/customer.json | 6 +- erpnext/selling/doctype/customer/customer.py | 10 +- .../selling/doctype/customer/test_customer.py | 29 +- .../doctype/sales_order/sales_order.py | 4 +- ...es_order_with_bypass_credit_limit_check.js | 13 +- ...order_without_bypass_credit_limit_check.js | 18 +- .../customer_group/customer_group.json | 447 ++---------------- .../doctype/delivery_note/delivery_note.py | 2 +- 10 files changed, 122 insertions(+), 453 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 4f8d3bdd9af..abbac77783b 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -305,7 +305,7 @@ class SalesInvoice(SellingController): validate_against_credit_limit = False bypass_credit_limit_check_at_sales_order = frappe.db.get_value("Customer Credit Limit", - filters={'parent': self.customer, 'company': self.company}, + filters={'parent': self.customer, 'parenttype': 'Customer', 'company': self.company}, fieldname=["bypass_credit_limit_check"]) if bypass_credit_limit_check_at_sales_order: diff --git a/erpnext/patches/v12_0/move_credit_limit_to_customer_credit_limit.py b/erpnext/patches/v12_0/move_credit_limit_to_customer_credit_limit.py index 3bcdb8fc7f9..c9293b9b63c 100644 --- a/erpnext/patches/v12_0/move_credit_limit_to_customer_credit_limit.py +++ b/erpnext/patches/v12_0/move_credit_limit_to_customer_credit_limit.py @@ -8,6 +8,7 @@ def execute(): ''' Move credit limit and bypass credit limit to the child table of customer credit limit ''' frappe.reload_doc("Selling", "doctype", "Customer Credit Limit") frappe.reload_doc("Selling", "doctype", "Customer") + frappe.reload_doc("Setup", "doctype", "Customer Group") if frappe.db.a_row_exists("Customer Credit Limit"): return @@ -17,24 +18,29 @@ def execute(): def move_credit_limit_to_child_table(): ''' maps data from old field to the new field in the child table ''' - fields="" - if frappe.db.has_column('Customer', 'bypass_credit_limit_check_at_sales_order'): - fields = ", bypass_credit_limit_check_at_sales_order" - - credit_limit_record = frappe.db.sql(''' - SELECT name, credit_limit {0} - FROM `tabCustomer` where credit_limit > 0 - '''.format(fields), as_dict=1) #nosec - companies = frappe.get_all("Company", 'name') + for doctype in ("Customer", "Customer Group"): + fields = "" + if doctype == "Customer" \ + and frappe.db.has_column('Customer', 'bypass_credit_limit_check_at_sales_order'): + fields = ", bypass_credit_limit_check_at_sales_order" - for record in credit_limit_record: - customer = frappe.get_doc("Customer", record.name) - for company in companies: - customer.append("credit_limit_reference", { - 'credit_limit': record.credit_limit, - 'bypass_credit_limit_check': record.bypass_credit_limit_check_at_sales_order, - 'company': company.name - }) - for row in customer.credit_limit_reference: - row.db_insert() + credit_limit_records = frappe.db.sql(''' + SELECT name, credit_limit {0} + FROM `tab{1}` where credit_limit > 0 + '''.format(fields, doctype), as_dict=1) #nosec + + for record in credit_limit_records: + doc = frappe.get_doc(doctype, record.name) + for company in companies: + row = frappe._dict({ + 'credit_limit': record.credit_limit, + 'company': company.name + }) + if doctype == "Customer": + row.bypass_credit_limit_check = record.bypass_credit_limit_check_at_sales_order + + doc.append("credit_limits", row) + + for row in doc.credit_limits: + row.db_insert() diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json index b83e284697b..c2c8c1971a9 100644 --- a/erpnext/selling/doctype/customer/customer.json +++ b/erpnext/selling/doctype/customer/customer.json @@ -50,7 +50,7 @@ "accounts", "credit_limit_section", "payment_terms", - "credit_limit_reference", + "credit_limits", "more_info", "customer_details", "column_break_45", @@ -460,7 +460,7 @@ }, { "default": "0", - "fieldname": "credit_limit_reference", + "fieldname": "credit_limits", "fieldtype": "Table", "label": "Credit Limit", "options": "Customer Credit Limit" @@ -469,7 +469,7 @@ "icon": "fa fa-user", "idx": 363, "image_field": "image", - "modified": "2019-08-30 18:03:13.332934", + "modified": "2019-09-06 12:40:31.801424", "modified_by": "Administrator", "module": "Selling", "name": "Customer", diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 972a6102ae0..4ca5af51a4d 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -167,11 +167,11 @@ class Customer(TransactionBase): frappe.throw(_("A Customer Group exists with same name please change the Customer name or rename the Customer Group"), frappe.NameError) def validate_credit_limit_on_change(self): - if self.get("__islocal") or not self.credit_limit_reference: + if self.get("__islocal") or not self.credit_limits: return company_record = [] - for limit in self.credit_limit_reference: + for limit in self.credit_limits: if limit.company in company_record: frappe.throw(_("Credit limit is already defined for the Company {0}").format(limit.company, self.name)) else: @@ -327,11 +327,13 @@ def get_credit_limit(customer, company): credit_limit = None if customer: - credit_limit = frappe.db.get_value("Customer Credit Limit", {'parent': customer, 'company': company}, 'credit_limit') + credit_limit = frappe.db.get_value("Customer Credit Limit", + {'parent': customer, 'parenttype': 'Customer', 'company': company}, 'credit_limit') if not credit_limit: customer_group = frappe.get_cached_value("Customer", customer, 'customer_group') - credit_limit = frappe.get_cached_value("Customer Group", customer_group, "credit_limit") + credit_limit = frappe.db.get_value("Customer Credit Limit", + {'parent': customer_group, 'parenttype': 'Customer Group', 'company': company}, 'credit_limit') if not credit_limit: credit_limit = frappe.get_cached_value('Company', company, "credit_limit") diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index 35d1b2cf1c2..87fdaa366f1 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -25,7 +25,7 @@ class TestCustomer(unittest.TestCase): make_test_records('Item') def tearDown(self): - frappe.db.set_value("Customer Credit Limit", {'parent': '_Test Customer', 'company': '_Test Company'}, 'credit_limit', 0.0) + set_credit_limit('_Test Customer', '_Test Company', 0) def test_party_details(self): from erpnext.accounts.party import get_party_details @@ -225,8 +225,8 @@ class TestCustomer(unittest.TestCase): item_qty = int((abs(outstanding_amt) + 200)/100) make_sales_order(qty=item_qty) - if credit_limit == 0.0: - frappe.db.set_value("Customer Credit Limit", {'parent': '_Test Customer', 'company': '_Test Company'}, 'credit_limit', outstanding_amt - 50.0) + if not credit_limit: + set_credit_limit('_Test Customer', '_Test Company', outstanding_amt - 50) # Sales Order so = make_sales_order(do_not_submit=True) @@ -241,7 +241,7 @@ class TestCustomer(unittest.TestCase): self.assertRaises(frappe.ValidationError, si.submit) if credit_limit > outstanding_amt: - frappe.db.set_value("Customer", {'parent': '_Test Customer', 'company': '_Test Company'}, 'credit_limit', credit_limit) + set_credit_limit('_Test Customer', '_Test Company', credit_limit) # Makes Sales invoice from Sales Order so.save(ignore_permissions=True) @@ -252,10 +252,10 @@ class TestCustomer(unittest.TestCase): def test_customer_credit_limit_on_change(self): outstanding_amt = self.get_customer_outstanding_amount() customer = frappe.get_doc("Customer", '_Test Customer') - customer.append('credit_limit_reference', {'credit_limit': flt(outstanding_amt - 100), 'company': '_Test Company'}) + customer.append('credit_limits', {'credit_limit': flt(outstanding_amt - 100), 'company': '_Test Company'}) ''' define new credit limit for same company ''' - customer.append('credit_limit_reference', {'credit_limit': flt(outstanding_amt - 100), 'company': '_Test Company'}) + customer.append('credit_limits', {'credit_limit': flt(outstanding_amt - 100), 'company': '_Test Company'}) self.assertRaises(frappe.ValidationError, customer.save) def test_customer_payment_terms(self): @@ -295,3 +295,20 @@ def get_customer_dict(customer_name): "doctype": "Customer", "territory": "_Test Territory" } + +def set_credit_limit(customer, company, credit_limit): + customer = frappe.get_doc("Customer", customer) + existing_row = None + for d in customer.credit_limits: + if d.company == company: + existing_row = d + d.credit_limit = credit_limit + d.db_update() + break + + if not existing_row: + customer.append('credit_limits', { + 'company': company, + 'credit_limit': credit_limit + }) + customer.credit_limits[-1].db_insert() diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 7d2eaf599ed..12b9a8e96d2 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -208,7 +208,9 @@ class SalesOrder(SellingController): def check_credit_limit(self): # if bypass credit limit check is set to true (1) at sales order level, # then we need not to check credit limit and vise versa - if not cint(frappe.db.get_value("Customer Credit Limit", {'parent': self.customer, 'company': self.company}, "bypass_credit_limit_check")): + if not cint(frappe.db.get_value("Customer Credit Limit", + {'parent': self.customer, 'parenttype': 'Customer', 'company': self.company}, + "bypass_credit_limit_check")): check_credit_limit(self.customer, self.company) def check_nextdoc_docstatus(self): diff --git a/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_bypass_credit_limit_check.js b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_bypass_credit_limit_check.js index 1f73f91f613..79d798b9443 100644 --- a/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_bypass_credit_limit_check.js +++ b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_bypass_credit_limit_check.js @@ -1,7 +1,7 @@ QUnit.module('Sales Order'); QUnit.test("test_sales_order_with_bypass_credit_limit_check", function(assert) { -//#PR : 10861, Author : ashish-greycube & jigneshpshah, Email:mr.ashish.shah@gmail.com +//#PR : 10861, Author : ashish-greycube & jigneshpshah, Email:mr.ashish.shah@gmail.com assert.expect(2); let done = assert.async(); frappe.run_serially([ @@ -10,7 +10,8 @@ QUnit.test("test_sales_order_with_bypass_credit_limit_check", function(assert) { () => frappe.quick_entry.dialog.$wrapper.find('.edit-full').click(), () => frappe.timeout(1), () => cur_frm.set_value("customer_name", "Test Customer 10"), - () => cur_frm.add_child('credit_limit_reference', { + () => cur_frm.add_child('credit_limits', { + 'company': cur_frm.doc.company || '_Test Company' 'credit_limit': 1000, 'bypass_credit_limit_check': 1}), // save form @@ -23,10 +24,10 @@ QUnit.test("test_sales_order_with_bypass_credit_limit_check", function(assert) { () => frappe.timeout(1), () => cur_frm.set_value("item_code", "Test Product 10"), () => cur_frm.set_value("item_group", "Products"), - () => cur_frm.set_value("standard_rate", 100), + () => cur_frm.set_value("standard_rate", 100), // save form () => cur_frm.save(), - () => frappe.timeout(1), + () => frappe.timeout(1), () => { return frappe.tests.make('Sales Order', [ @@ -47,11 +48,11 @@ QUnit.test("test_sales_order_with_bypass_credit_limit_check", function(assert) { () => frappe.tests.click_button('Yes'), () => frappe.timeout(3), () => { - + assert.ok(cur_frm.doc.status=="To Deliver and Bill", "It is submited. Credit limit is NOT checked for sales order"); - }, + }, () => done() ]); }); diff --git a/erpnext/selling/doctype/sales_order/tests/test_sales_order_without_bypass_credit_limit_check.js b/erpnext/selling/doctype/sales_order/tests/test_sales_order_without_bypass_credit_limit_check.js index 34560b69000..8de39f9aa30 100644 --- a/erpnext/selling/doctype/sales_order/tests/test_sales_order_without_bypass_credit_limit_check.js +++ b/erpnext/selling/doctype/sales_order/tests/test_sales_order_without_bypass_credit_limit_check.js @@ -1,7 +1,7 @@ QUnit.module('Sales Order'); QUnit.test("test_sales_order_without_bypass_credit_limit_check", function(assert) { -//#PR : 10861, Author : ashish-greycube & jigneshpshah, Email:mr.ashish.shah@gmail.com +//#PR : 10861, Author : ashish-greycube & jigneshpshah, Email:mr.ashish.shah@gmail.com assert.expect(2); let done = assert.async(); frappe.run_serially([ @@ -10,7 +10,7 @@ QUnit.test("test_sales_order_without_bypass_credit_limit_check", function(assert () => frappe.quick_entry.dialog.$wrapper.find('.edit-full').click(), () => frappe.timeout(1), () => cur_frm.set_value("customer_name", "Test Customer 11"), - () => cur_frm.add_child('credit_limit_reference', { + () => cur_frm.add_child('credit_limits', { 'credit_limit': 1000, 'company': '_Test Company', 'bypass_credit_limit_check': 1}), @@ -23,10 +23,10 @@ QUnit.test("test_sales_order_without_bypass_credit_limit_check", function(assert () => frappe.click_link('Edit in full page'), () => cur_frm.set_value("item_code", "Test Product 11"), () => cur_frm.set_value("item_group", "Products"), - () => cur_frm.set_value("standard_rate", 100), + () => cur_frm.set_value("standard_rate", 100), // save form () => cur_frm.save(), - () => frappe.timeout(1), + () => frappe.timeout(1), () => { return frappe.tests.make('Sales Order', [ @@ -47,14 +47,14 @@ QUnit.test("test_sales_order_without_bypass_credit_limit_check", function(assert () => frappe.tests.click_button('Yes'), () => frappe.timeout(3), () => { - - if (cur_dialog.body.innerText.match(/^Credit limit has been crossed for customer.*$/)) - { + + if (cur_dialog.body.innerText.match(/^Credit limit has been crossed for customer.*$/)) + { /*Match found */ assert.ok(true, "Credit Limit crossed message received"); } - - + + }, () => cur_dialog.cancel(), () => done() diff --git a/erpnext/setup/doctype/customer_group/customer_group.json b/erpnext/setup/doctype/customer_group/customer_group.json index c130e795415..3565b4b38a9 100644 --- a/erpnext/setup/doctype/customer_group/customer_group.json +++ b/erpnext/setup/doctype/customer_group/customer_group.json @@ -1,553 +1,194 @@ { - "allow_copy": 0, - "allow_guest_to_view": 0, + "_comments": "[]", "allow_import": 1, "allow_rename": 1, "autoname": "field:customer_group_name", - "beta": 0, "creation": "2013-01-10 16:34:23", - "custom": 0, - "docstatus": 0, "doctype": "DocType", "document_type": "Setup", - "editable_grid": 0, + "field_order": [ + "customer_group_name", + "parent_customer_group", + "is_group", + "cb0", + "default_price_list", + "payment_terms", + "lft", + "rgt", + "old_parent", + "default_receivable_account", + "accounts", + "credit_limit_section", + "credit_limits" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "customer_group_name", "fieldtype": "Data", - "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": "Customer Group Name", - "length": 0, "no_copy": 1, "oldfieldname": "customer_group_name", "oldfieldtype": "Data", - "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, - "translatable": 0, "unique": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, "bold": 1, - "collapsible": 0, - "columns": 0, - "description": "", "fieldname": "parent_customer_group", "fieldtype": "Link", - "hidden": 0, "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, - "in_standard_filter": 0, "label": "Parent Customer Group", - "length": 0, - "no_copy": 0, "oldfieldname": "parent_customer_group", "oldfieldtype": "Link", - "options": "Customer Group", - "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, - "translatable": 0, - "unique": 0 + "options": "Customer Group" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, "bold": 1, - "collapsible": 0, - "columns": 0, + "default": "0", "description": "Only leaf nodes are allowed in transaction", "fieldname": "is_group", "fieldtype": "Check", - "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": "Is Group", - "length": 0, - "no_copy": 0, "oldfieldname": "is_group", - "oldfieldtype": "Select", - "options": "", - "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, - "translatable": 0, - "unique": 0 + "oldfieldtype": "Select" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "cb0", - "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, - "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, - "translatable": 0, - "unique": 0 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "default_price_list", "fieldtype": "Link", - "hidden": 0, "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Default Price List", - "length": 0, - "no_copy": 0, - "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, - "translatable": 0, - "unique": 0 + "options": "Price List" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", "fieldname": "payment_terms", "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": "Default Payment Terms Template", - "length": 0, - "no_copy": 0, - "options": "Payment Terms Template", - "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, - "translatable": 0, - "unique": 0 + "options": "Payment Terms Template" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "credit_limit", - "fieldtype": "Currency", - "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": "Credit Limit", - "length": 0, - "no_copy": 0, - "permlevel": 1, - "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, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "lft", "fieldtype": "Int", "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "lft", - "length": 0, "no_copy": 1, "oldfieldname": "lft", "oldfieldtype": "Int", - "permlevel": 0, "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, "report_hide": 1, - "reqd": 0, - "search_index": 1, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "search_index": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "rgt", "fieldtype": "Int", "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "rgt", - "length": 0, "no_copy": 1, "oldfieldname": "rgt", "oldfieldtype": "Int", - "permlevel": 0, "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, "report_hide": 1, - "reqd": 0, - "search_index": 1, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "search_index": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "description": "", "fieldname": "old_parent", "fieldtype": "Link", "hidden": 1, "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "old_parent", - "length": 0, "no_copy": 1, "oldfieldname": "old_parent", "oldfieldtype": "Data", "options": "Customer Group", - "permlevel": 0, "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 1, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "report_hide": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "default_receivable_account", "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": "Default Receivable Account", - "length": 0, - "no_copy": 0, - "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, - "translatable": 0, - "unique": 0 + "label": "Default Receivable Account" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "depends_on": "eval:!doc.__islocal", "description": "Mention if non-standard receivable account applicable", "fieldname": "accounts", "fieldtype": "Table", - "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": "Accounts", - "length": 0, - "no_copy": 0, - "options": "Party Account", - "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, - "translatable": 0, - "unique": 0 + "options": "Party Account" + }, + { + "fieldname": "credit_limit_section", + "fieldtype": "Section Break", + "label": "Credit Limits" + }, + { + "fieldname": "credit_limits", + "fieldtype": "Table", + "label": "Credit Limit", + "options": "Customer Credit Limit" } ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, "icon": "fa fa-sitemap", "idx": 1, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2018-08-29 06:26:05.935871", + "modified": "2019-09-06 12:40:14.954697", "modified_by": "Administrator", "module": "Setup", "name": "Customer Group", "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, "email": 1, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, - "role": "Sales Manager", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 + "role": "Sales Manager" }, { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, "email": 1, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, - "role": "Sales User", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 + "role": "Sales User" }, { - "amend": 0, - "cancel": 0, "create": 1, "delete": 1, "email": 1, "export": 1, - "if_owner": 0, "import": 1, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "Sales Master Manager", "set_user_permissions": 1, "share": 1, - "submit": 0, "write": 1 }, { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, "permlevel": 1, - "print": 0, "read": 1, - "report": 0, "role": "Sales Master Manager", - "set_user_permissions": 0, - "share": 0, - "submit": 0, "write": 1 }, { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, "permlevel": 1, - "print": 0, "read": 1, - "report": 0, - "role": "Sales User", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 + "role": "Sales User" }, { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, "permlevel": 1, - "print": 0, "read": 1, - "report": 0, - "role": "Sales Manager", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 + "role": "Sales Manager" } ], "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, "search_fields": "parent_customer_group", "show_name_in_global_search": 1, - "sort_order": "DESC", - "track_changes": 0, - "track_seen": 0, - "track_views": 0 + "sort_order": "DESC" } \ No newline at end of file diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index e29cd1b7929..bdb49e4919c 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -235,7 +235,7 @@ class DeliveryNote(SellingController): extra_amount = 0 validate_against_credit_limit = False bypass_credit_limit_check_at_sales_order = cint(frappe.db.get_value("Customer Credit Limit", - filters={'parent': self.customer, 'company': self.company}, + filters={'parent': self.customer, 'parenttype': 'Customer', 'company': self.company}, fieldname="bypass_credit_limit_check")) if bypass_credit_limit_check_at_sales_order: