fix: Override template only if setting is enabled

This commit is contained in:
Deepesh Garg 2021-08-07 00:12:57 +05:30 committed by GangaManoj
parent b37c6992df
commit bff3b0962a
2 changed files with 3 additions and 2 deletions

View File

@ -1108,7 +1108,8 @@ class AccountsController(TransactionBase):
base_grand_total = flt(grand_total * self.get("conversion_rate"), self.precision("base_grand_total"))
if not self.get("payment_schedule"):
if self.doctype in ["Sales Invoice", "Purchase Invoice"] and self.linked_order_has_payment_terms(po_or_so, fieldname, doctype):
if self.doctype in ["Sales Invoice", "Purchase Invoice"] and automatically_fetch_payment_terms \
and self.linked_order_has_payment_terms(po_or_so, fieldname, doctype):
self.fetch_payment_terms_from_order(po_or_so, doctype)
if self.get('payment_terms_template'):
self.ignore_default_payment_terms_template = 1

View File

@ -76,7 +76,7 @@ erpnext.utils.get_party_details = function(frm, method, args, callback) {
if (args) {
args.posting_date = frm.doc.posting_date || frm.doc.transaction_date;
args.fetch_payment_terms_template = cint(!frm.doc.ignore_default_payment_terms_template)
args.fetch_payment_terms_template = cint(!frm.doc.ignore_default_payment_terms_template);
}
}
if (!args || !args.party) return;