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. cint function is added.

This commit is contained in:
ashish 2017-10-26 20:15:24 +05:30
parent 9dfc0f32ab
commit 751b05f1e8

View File

@ -198,7 +198,7 @@ class SalesOrder(SellingController):
from erpnext.selling.doctype.customer.customer import check_credit_limit
#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")
bypass_credit_limit_check_at_sales_order = cint(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)
@ -351,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
@ -468,12 +468,11 @@ def make_delivery_note(source_name, target_doc=None):
#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")
bypass_credit_limit_check_at_sales_order = cint(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")
@ -538,7 +537,7 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
#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")
bypass_credit_limit_check_at_sales_order = cint(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)