sales_order.py -- Three changes are done (a) if bypass credit limit check is enabled we should not check customer credit on submit of sales order (b.1/b.2) There is provision to make delivery note and sales invoice from sales order. Since credit limit is bypassed at sales order level we need to check credit of customer on make of (b.1)delivery note or (b.2)sales invoice

This commit is contained in:
ashish 2017-10-25 16:07:21 +05:30
parent 06e6a82d56
commit 8ad4efee25

View File

@ -196,7 +196,11 @@ class SalesOrder(SellingController):
def check_credit_limit(self):
from erpnext.selling.doctype.customer.customer import check_credit_limit
check_credit_limit(self.customer, self.company)
#PR : 10861, Author : ashish-greycube & jigneshpshah, Email:mr.ashish.shah@gmail.com
# bypass credit limit check is set to true (1) at sales order level, then we need not to check credit limit and vise versa
bypass_credit_limit_check_at_sales_order = frappe.db.get_value("Customer", self.customer, "bypass_credit_limit_check_at_sales_order")
if bypass_credit_limit_check_at_sales_order == 0:
check_credit_limit(self.customer, self.company)
def check_nextdoc_docstatus(self):
# Checks Delivery Note
@ -347,15 +351,15 @@ class SalesOrder(SellingController):
return items
def on_recurring(self, reference_doc, subscription_doc):
self.set("delivery_date", get_next_schedule_date(reference_doc.delivery_date,
subscription_doc.frequency, cint(subscription_doc.repeat_on_day)))
self.set("delivery_date", get_next_schedule_date(reference_doc.delivery_date, subscription_doc.frequency,
cint(subscription_doc.repeat_on_day)))
for d in self.get("items"):
reference_delivery_date = frappe.db.get_value("Sales Order Item",
{"parent": reference_doc.name, "item_code": d.item_code, "idx": d.idx}, "delivery_date")
d.set("delivery_date", get_next_schedule_date(reference_delivery_date,
subscription_doc.frequency, cint(subscription_doc.repeat_on_day)))
d.set("delivery_date",
get_next_schedule_date(reference_delivery_date, subscription_doc.frequency, cint(subscription_doc.repeat_on_day)))
def get_list_context(context=None):
from erpnext.controllers.website_list_for_contact import get_list_context
@ -462,6 +466,14 @@ def make_delivery_note(source_name, target_doc=None):
else:
target.po_no = source.po_no
#PR : 10861, Author : ashish-greycube & jigneshpshah, Email:mr.ashish.shah@gmail.com
# Since the credit limit check is bypassed at sales order level, we need to check it at delivery note
bypass_credit_limit_check_at_sales_order = frappe.db.get_value("Customer", source.customer, "bypass_credit_limit_check_at_sales_order")
if bypass_credit_limit_check_at_sales_order == 1:
from erpnext.selling.doctype.customer.customer import check_credit_limit
check_credit_limit(source.customer, source.company)
target.ignore_pricing_rule = 1
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
@ -524,6 +536,13 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
#PR : 10861, Author : ashish-greycube & jigneshpshah, Email:mr.ashish.shah@gmail.com
# Since the credit limit check is bypassed at sales order level, we need to check it at sales invoice
bypass_credit_limit_check_at_sales_order = frappe.db.get_value("Customer", source.customer, "bypass_credit_limit_check_at_sales_order")
if bypass_credit_limit_check_at_sales_order == 1:
from erpnext.selling.doctype.customer.customer import check_credit_limit
check_credit_limit(source.customer, source.company)
# set company address
target.update(get_company_address(target.company))
if target.company_address: