feat: Company wise credit limit

This commit is contained in:
Nabin Hait
2019-09-06 14:33:10 +05:30
parent ac2b5ed84f
commit 4ce38059ac
10 changed files with 122 additions and 453 deletions

View File

@@ -305,7 +305,7 @@ class SalesInvoice(SellingController):
validate_against_credit_limit = False validate_against_credit_limit = False
bypass_credit_limit_check_at_sales_order = frappe.db.get_value("Customer Credit Limit", 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"]) fieldname=["bypass_credit_limit_check"])
if bypass_credit_limit_check_at_sales_order: if bypass_credit_limit_check_at_sales_order:

View File

@@ -8,6 +8,7 @@ def execute():
''' Move credit limit and bypass credit limit to the child table of customer credit limit ''' ''' 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 Credit Limit")
frappe.reload_doc("Selling", "doctype", "Customer") frappe.reload_doc("Selling", "doctype", "Customer")
frappe.reload_doc("Setup", "doctype", "Customer Group")
if frappe.db.a_row_exists("Customer Credit Limit"): if frappe.db.a_row_exists("Customer Credit Limit"):
return return
@@ -17,24 +18,29 @@ def execute():
def move_credit_limit_to_child_table(): def move_credit_limit_to_child_table():
''' maps data from old field to the new field in the 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') 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: credit_limit_records = frappe.db.sql('''
customer = frappe.get_doc("Customer", record.name) SELECT name, credit_limit {0}
for company in companies: FROM `tab{1}` where credit_limit > 0
customer.append("credit_limit_reference", { '''.format(fields, doctype), as_dict=1) #nosec
'credit_limit': record.credit_limit,
'bypass_credit_limit_check': record.bypass_credit_limit_check_at_sales_order, for record in credit_limit_records:
'company': company.name doc = frappe.get_doc(doctype, record.name)
}) for company in companies:
for row in customer.credit_limit_reference: row = frappe._dict({
row.db_insert() '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()

View File

@@ -50,7 +50,7 @@
"accounts", "accounts",
"credit_limit_section", "credit_limit_section",
"payment_terms", "payment_terms",
"credit_limit_reference", "credit_limits",
"more_info", "more_info",
"customer_details", "customer_details",
"column_break_45", "column_break_45",
@@ -460,7 +460,7 @@
}, },
{ {
"default": "0", "default": "0",
"fieldname": "credit_limit_reference", "fieldname": "credit_limits",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Credit Limit", "label": "Credit Limit",
"options": "Customer Credit Limit" "options": "Customer Credit Limit"
@@ -469,7 +469,7 @@
"icon": "fa fa-user", "icon": "fa fa-user",
"idx": 363, "idx": 363,
"image_field": "image", "image_field": "image",
"modified": "2019-08-30 18:03:13.332934", "modified": "2019-09-06 12:40:31.801424",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Customer", "name": "Customer",

View File

@@ -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) 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): 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 return
company_record = [] company_record = []
for limit in self.credit_limit_reference: for limit in self.credit_limits:
if limit.company in company_record: if limit.company in company_record:
frappe.throw(_("Credit limit is already defined for the Company {0}").format(limit.company, self.name)) frappe.throw(_("Credit limit is already defined for the Company {0}").format(limit.company, self.name))
else: else:
@@ -327,11 +327,13 @@ def get_credit_limit(customer, company):
credit_limit = None credit_limit = None
if customer: 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: if not credit_limit:
customer_group = frappe.get_cached_value("Customer", customer, 'customer_group') 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: if not credit_limit:
credit_limit = frappe.get_cached_value('Company', company, "credit_limit") credit_limit = frappe.get_cached_value('Company', company, "credit_limit")

View File

@@ -25,7 +25,7 @@ class TestCustomer(unittest.TestCase):
make_test_records('Item') make_test_records('Item')
def tearDown(self): 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): def test_party_details(self):
from erpnext.accounts.party import get_party_details from erpnext.accounts.party import get_party_details
@@ -225,8 +225,8 @@ class TestCustomer(unittest.TestCase):
item_qty = int((abs(outstanding_amt) + 200)/100) item_qty = int((abs(outstanding_amt) + 200)/100)
make_sales_order(qty=item_qty) make_sales_order(qty=item_qty)
if credit_limit == 0.0: if not credit_limit:
frappe.db.set_value("Customer Credit Limit", {'parent': '_Test Customer', 'company': '_Test Company'}, 'credit_limit', outstanding_amt - 50.0) set_credit_limit('_Test Customer', '_Test Company', outstanding_amt - 50)
# Sales Order # Sales Order
so = make_sales_order(do_not_submit=True) so = make_sales_order(do_not_submit=True)
@@ -241,7 +241,7 @@ class TestCustomer(unittest.TestCase):
self.assertRaises(frappe.ValidationError, si.submit) self.assertRaises(frappe.ValidationError, si.submit)
if credit_limit > outstanding_amt: 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 # Makes Sales invoice from Sales Order
so.save(ignore_permissions=True) so.save(ignore_permissions=True)
@@ -252,10 +252,10 @@ class TestCustomer(unittest.TestCase):
def test_customer_credit_limit_on_change(self): def test_customer_credit_limit_on_change(self):
outstanding_amt = self.get_customer_outstanding_amount() outstanding_amt = self.get_customer_outstanding_amount()
customer = frappe.get_doc("Customer", '_Test Customer') 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 ''' ''' 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) self.assertRaises(frappe.ValidationError, customer.save)
def test_customer_payment_terms(self): def test_customer_payment_terms(self):
@@ -295,3 +295,20 @@ def get_customer_dict(customer_name):
"doctype": "Customer", "doctype": "Customer",
"territory": "_Test Territory" "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()

View File

@@ -208,7 +208,9 @@ class SalesOrder(SellingController):
def check_credit_limit(self): def check_credit_limit(self):
# if bypass credit limit check is set to true (1) at sales order level, # 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 # 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) check_credit_limit(self.customer, self.company)
def check_nextdoc_docstatus(self): def check_nextdoc_docstatus(self):

View File

@@ -1,7 +1,7 @@
QUnit.module('Sales Order'); QUnit.module('Sales Order');
QUnit.test("test_sales_order_with_bypass_credit_limit_check", function(assert) { 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); assert.expect(2);
let done = assert.async(); let done = assert.async();
frappe.run_serially([ 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.quick_entry.dialog.$wrapper.find('.edit-full').click(),
() => frappe.timeout(1), () => frappe.timeout(1),
() => cur_frm.set_value("customer_name", "Test Customer 10"), () => 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, 'credit_limit': 1000,
'bypass_credit_limit_check': 1}), 'bypass_credit_limit_check': 1}),
// save form // save form
@@ -23,10 +24,10 @@ QUnit.test("test_sales_order_with_bypass_credit_limit_check", function(assert) {
() => frappe.timeout(1), () => frappe.timeout(1),
() => cur_frm.set_value("item_code", "Test Product 10"), () => cur_frm.set_value("item_code", "Test Product 10"),
() => cur_frm.set_value("item_group", "Products"), () => cur_frm.set_value("item_group", "Products"),
() => cur_frm.set_value("standard_rate", 100), () => cur_frm.set_value("standard_rate", 100),
// save form // save form
() => cur_frm.save(), () => cur_frm.save(),
() => frappe.timeout(1), () => frappe.timeout(1),
() => { () => {
return frappe.tests.make('Sales Order', [ 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.tests.click_button('Yes'),
() => frappe.timeout(3), () => frappe.timeout(3),
() => { () => {
assert.ok(cur_frm.doc.status=="To Deliver and Bill", "It is submited. Credit limit is NOT checked for sales order"); assert.ok(cur_frm.doc.status=="To Deliver and Bill", "It is submited. Credit limit is NOT checked for sales order");
}, },
() => done() () => done()
]); ]);
}); });

View File

@@ -1,7 +1,7 @@
QUnit.module('Sales Order'); QUnit.module('Sales Order');
QUnit.test("test_sales_order_without_bypass_credit_limit_check", function(assert) { 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); assert.expect(2);
let done = assert.async(); let done = assert.async();
frappe.run_serially([ 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.quick_entry.dialog.$wrapper.find('.edit-full').click(),
() => frappe.timeout(1), () => frappe.timeout(1),
() => cur_frm.set_value("customer_name", "Test Customer 11"), () => 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, 'credit_limit': 1000,
'company': '_Test Company', 'company': '_Test Company',
'bypass_credit_limit_check': 1}), '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'), () => frappe.click_link('Edit in full page'),
() => cur_frm.set_value("item_code", "Test Product 11"), () => cur_frm.set_value("item_code", "Test Product 11"),
() => cur_frm.set_value("item_group", "Products"), () => cur_frm.set_value("item_group", "Products"),
() => cur_frm.set_value("standard_rate", 100), () => cur_frm.set_value("standard_rate", 100),
// save form // save form
() => cur_frm.save(), () => cur_frm.save(),
() => frappe.timeout(1), () => frappe.timeout(1),
() => { () => {
return frappe.tests.make('Sales Order', [ 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.tests.click_button('Yes'),
() => frappe.timeout(3), () => 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 */ /*Match found */
assert.ok(true, "Credit Limit crossed message received"); assert.ok(true, "Credit Limit crossed message received");
} }
}, },
() => cur_dialog.cancel(), () => cur_dialog.cancel(),
() => done() () => done()

View File

@@ -1,553 +1,194 @@
{ {
"allow_copy": 0, "_comments": "[]",
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "field:customer_group_name", "autoname": "field:customer_group_name",
"beta": 0,
"creation": "2013-01-10 16:34:23", "creation": "2013-01-10 16:34:23",
"custom": 0,
"docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Setup", "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": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "customer_group_name", "fieldname": "customer_group_name",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Customer Group Name", "label": "Customer Group Name",
"length": 0,
"no_copy": 1, "no_copy": 1,
"oldfieldname": "customer_group_name", "oldfieldname": "customer_group_name",
"oldfieldtype": "Data", "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, "reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 1 "unique": 1
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1, "bold": 1,
"collapsible": 0,
"columns": 0,
"description": "",
"fieldname": "parent_customer_group", "fieldname": "parent_customer_group",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Parent Customer Group", "label": "Parent Customer Group",
"length": 0,
"no_copy": 0,
"oldfieldname": "parent_customer_group", "oldfieldname": "parent_customer_group",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Customer Group", "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
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1, "bold": 1,
"collapsible": 0, "default": "0",
"columns": 0,
"description": "Only leaf nodes are allowed in transaction", "description": "Only leaf nodes are allowed in transaction",
"fieldname": "is_group", "fieldname": "is_group",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Is Group", "label": "Is Group",
"length": 0,
"no_copy": 0,
"oldfieldname": "is_group", "oldfieldname": "is_group",
"oldfieldtype": "Select", "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
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "cb0", "fieldname": "cb0",
"fieldtype": "Column Break", "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
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "default_price_list", "fieldname": "default_price_list",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 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": "Default Price List", "label": "Default Price List",
"length": 0, "options": "Price List"
"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
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fieldname": "payment_terms", "fieldname": "payment_terms",
"fieldtype": "Link", "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", "label": "Default Payment Terms Template",
"length": 0, "options": "Payment Terms Template"
"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
}, },
{ {
"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", "fieldname": "lft",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 1, "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", "label": "lft",
"length": 0,
"no_copy": 1, "no_copy": 1,
"oldfieldname": "lft", "oldfieldname": "lft",
"oldfieldtype": "Int", "oldfieldtype": "Int",
"permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 1, "report_hide": 1,
"reqd": 0, "search_index": 1
"search_index": 1,
"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": "rgt", "fieldname": "rgt",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 1, "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", "label": "rgt",
"length": 0,
"no_copy": 1, "no_copy": 1,
"oldfieldname": "rgt", "oldfieldname": "rgt",
"oldfieldtype": "Int", "oldfieldtype": "Int",
"permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 1, "report_hide": 1,
"reqd": 0, "search_index": 1
"search_index": 1,
"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,
"description": "",
"fieldname": "old_parent", "fieldname": "old_parent",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "hidden": 1,
"ignore_user_permissions": 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", "label": "old_parent",
"length": 0,
"no_copy": 1, "no_copy": 1,
"oldfieldname": "old_parent", "oldfieldname": "old_parent",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"options": "Customer Group", "options": "Customer Group",
"permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "report_hide": 1
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 1,
"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": "default_receivable_account", "fieldname": "default_receivable_account",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "label": "Default Receivable Account"
"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
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal", "depends_on": "eval:!doc.__islocal",
"description": "Mention if non-standard receivable account applicable", "description": "Mention if non-standard receivable account applicable",
"fieldname": "accounts", "fieldname": "accounts",
"fieldtype": "Table", "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", "label": "Accounts",
"length": 0, "options": "Party Account"
"no_copy": 0, },
"options": "Party Account", {
"permlevel": 0, "fieldname": "credit_limit_section",
"print_hide": 0, "fieldtype": "Section Break",
"print_hide_if_no_value": 0, "label": "Credit Limits"
"read_only": 0, },
"remember_last_selected_value": 0, {
"report_hide": 0, "fieldname": "credit_limits",
"reqd": 0, "fieldtype": "Table",
"search_index": 0, "label": "Credit Limit",
"set_only_once": 0, "options": "Customer Credit Limit"
"translatable": 0,
"unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-sitemap", "icon": "fa fa-sitemap",
"idx": 1, "idx": 1,
"image_view": 0, "modified": "2019-09-06 12:40:14.954697",
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-08-29 06:26:05.935871",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Setup", "module": "Setup",
"name": "Customer Group", "name": "Customer Group",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 1, "email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Sales Manager", "role": "Sales Manager"
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 0
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 1, "email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Sales User", "role": "Sales User"
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 0
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 1, "import": 1,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Sales Master Manager", "role": "Sales Master Manager",
"set_user_permissions": 1, "set_user_permissions": 1,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 0,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 1, "permlevel": 1,
"print": 0,
"read": 1, "read": 1,
"report": 0,
"role": "Sales Master Manager", "role": "Sales Master Manager",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 1 "write": 1
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 0,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 1, "permlevel": 1,
"print": 0,
"read": 1, "read": 1,
"report": 0, "role": "Sales User"
"role": "Sales User",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 0
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 0,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 1, "permlevel": 1,
"print": 0,
"read": 1, "read": 1,
"report": 0, "role": "Sales Manager"
"role": "Sales Manager",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 0
} }
], ],
"quick_entry": 1, "quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"search_fields": "parent_customer_group", "search_fields": "parent_customer_group",
"show_name_in_global_search": 1, "show_name_in_global_search": 1,
"sort_order": "DESC", "sort_order": "DESC"
"track_changes": 0,
"track_seen": 0,
"track_views": 0
} }

View File

@@ -235,7 +235,7 @@ class DeliveryNote(SellingController):
extra_amount = 0 extra_amount = 0
validate_against_credit_limit = False validate_against_credit_limit = False
bypass_credit_limit_check_at_sales_order = cint(frappe.db.get_value("Customer Credit Limit", 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")) fieldname="bypass_credit_limit_check"))
if bypass_credit_limit_check_at_sales_order: if bypass_credit_limit_check_at_sales_order: