fix: use predefined onload property load_after_mapping (backport #38209) (#38518)

Co-authored-by: Sagar Vora <sagar@resilient.tech>
fix: use predefined onload property `load_after_mapping` (#38209)
This commit is contained in:
mergify[bot]
2023-12-04 09:52:16 +05:30
committed by GitHub
parent b7fe163de5
commit 9f23b7e46f
10 changed files with 7 additions and 28 deletions

View File

@@ -1703,6 +1703,4 @@ def make_purchase_receipt(source_name, target_doc=None):
target_doc, target_doc,
) )
doc.set_onload("ignore_price_list", True)
return doc return doc

View File

@@ -1934,7 +1934,6 @@ def make_delivery_note(source_name, target_doc=None):
set_missing_values, set_missing_values,
) )
doclist.set_onload("ignore_price_list", True)
return doclist return doclist

View File

@@ -541,8 +541,6 @@ def make_purchase_receipt(source_name, target_doc=None):
set_missing_values, set_missing_values,
) )
doc.set_onload("ignore_price_list", True)
return doc return doc
@@ -622,7 +620,6 @@ def get_mapped_purchase_invoice(source_name, target_doc=None, ignore_permissions
postprocess, postprocess,
ignore_permissions=ignore_permissions, ignore_permissions=ignore_permissions,
) )
doc.set_onload("ignore_price_list", True)
return doc return doc

View File

@@ -168,7 +168,6 @@ def make_purchase_order(source_name, target_doc=None):
set_missing_values, set_missing_values,
) )
doclist.set_onload("ignore_price_list", True)
return doclist return doclist

View File

@@ -530,8 +530,6 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None):
set_missing_values, set_missing_values,
) )
doclist.set_onload("ignore_price_list", True)
return doclist return doclist

View File

@@ -328,7 +328,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
onload_post_render() { onload_post_render() {
if(this.frm.doc.__islocal && !(this.frm.doc.taxes || []).length if(this.frm.doc.__islocal && !(this.frm.doc.taxes || []).length
&& !(this.frm.doc.__onload ? this.frm.doc.__onload.load_after_mapping : false)) { && !this.frm.doc.__onload?.load_after_mapping) {
frappe.after_ajax(() => this.apply_default_taxes()); frappe.after_ajax(() => this.apply_default_taxes());
} else if(this.frm.doc.__islocal && this.frm.doc.company && this.frm.doc["items"] } else if(this.frm.doc.__islocal && this.frm.doc.company && this.frm.doc["items"]
&& !this.frm.doc.is_pos) { && !this.frm.doc.is_pos) {
@@ -918,9 +918,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
let me = this; let me = this;
this.set_dynamic_labels(); this.set_dynamic_labels();
let company_currency = this.get_company_currency(); let company_currency = this.get_company_currency();
// Added `ignore_price_list` to determine if document is loading after mapping from another doc // Added `load_after_mapping` to determine if document is loading after mapping from another doc
if(this.frm.doc.currency && this.frm.doc.currency !== company_currency if(this.frm.doc.currency && this.frm.doc.currency !== company_currency
&& !(this.frm.doc.__onload && this.frm.doc.__onload.ignore_price_list)) { && !this.frm.doc.__onload?.load_after_mapping) {
this.get_exchange_rate(transaction_date, this.frm.doc.currency, company_currency, this.get_exchange_rate(transaction_date, this.frm.doc.currency, company_currency,
function(exchange_rate) { function(exchange_rate) {
@@ -952,7 +952,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
} }
if(flt(this.frm.doc.conversion_rate)>0.0) { if(flt(this.frm.doc.conversion_rate)>0.0) {
if(this.frm.doc.__onload && this.frm.doc.__onload.ignore_price_list) { if(this.frm.doc.__onload?.load_after_mapping) {
this.calculate_taxes_and_totals(); this.calculate_taxes_and_totals();
} else if (!this.in_apply_price_list){ } else if (!this.in_apply_price_list){
this.apply_price_list(); this.apply_price_list();
@@ -1039,9 +1039,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
this.set_dynamic_labels(); this.set_dynamic_labels();
var company_currency = this.get_company_currency(); var company_currency = this.get_company_currency();
// Added `ignore_price_list` to determine if document is loading after mapping from another doc // Added `load_after_mapping` to determine if document is loading after mapping from another doc
if(this.frm.doc.price_list_currency !== company_currency && if(this.frm.doc.price_list_currency !== company_currency &&
!(this.frm.doc.__onload && this.frm.doc.__onload.ignore_price_list)) { !this.frm.doc.__onload?.load_after_mapping) {
this.get_exchange_rate(this.frm.doc.posting_date, this.frm.doc.price_list_currency, company_currency, this.get_exchange_rate(this.frm.doc.posting_date, this.frm.doc.price_list_currency, company_currency,
function(exchange_rate) { function(exchange_rate) {
me.frm.set_value("plc_conversion_rate", exchange_rate); me.frm.set_value("plc_conversion_rate", exchange_rate);
@@ -1420,7 +1420,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
} }
// Target doc created from a mapped doc // Target doc created from a mapped doc
if (this.frm.doc.__onload && this.frm.doc.__onload.ignore_price_list) { if (this.frm.doc.__onload?.load_after_mapping) {
// Calculate totals even though pricing rule is not applied. // Calculate totals even though pricing rule is not applied.
// `apply_pricing_rule` is triggered due to change in data which most likely contributes to Total. // `apply_pricing_rule` is triggered due to change in data which most likely contributes to Total.
if (calculate_taxes_and_totals) me.calculate_taxes_and_totals(); if (calculate_taxes_and_totals) me.calculate_taxes_and_totals();

View File

@@ -352,9 +352,6 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
ignore_permissions=ignore_permissions, ignore_permissions=ignore_permissions,
) )
# postprocess: fetch shipping address, set missing values
doclist.set_onload("ignore_price_list", True)
return doclist return doclist
@@ -423,8 +420,6 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
ignore_permissions=ignore_permissions, ignore_permissions=ignore_permissions,
) )
doclist.set_onload("ignore_price_list", True)
return doclist return doclist

View File

@@ -716,8 +716,6 @@ def make_delivery_note(source_name, target_doc=None, skip_item_mapping=False):
target_doc = get_mapped_doc("Sales Order", source_name, mapper, target_doc, set_missing_values) target_doc = get_mapped_doc("Sales Order", source_name, mapper, target_doc, set_missing_values)
target_doc.set_onload("ignore_price_list", True)
return target_doc return target_doc
@@ -806,8 +804,6 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
if automatically_fetch_payment_terms: if automatically_fetch_payment_terms:
doclist.set_payment_schedule() doclist.set_payment_schedule()
doclist.set_onload("ignore_price_list", True)
return doclist return doclist

View File

@@ -665,8 +665,6 @@ def make_sales_invoice(source_name, target_doc=None):
if automatically_fetch_payment_terms: if automatically_fetch_payment_terms:
doc.set_payment_schedule() doc.set_payment_schedule()
doc.set_onload("ignore_price_list", True)
return doc return doc

View File

@@ -1057,7 +1057,6 @@ def make_purchase_invoice(source_name, target_doc=None):
set_missing_values, set_missing_values,
) )
doclist.set_onload("ignore_price_list", True)
return doclist return doclist