fix: use predefined onload property load_after_mapping (#38209)

fix: use predefined onload property `load_after_mapping` (#38209)

(cherry picked from commit b6a7549407bc04225f0bb7c144284078a314f430)

Co-authored-by: Sagar Vora <sagar@resilient.tech>
This commit is contained in:
mergify[bot] 2023-12-04 09:36:52 +05:30 committed by GitHub
parent 0aa96f783d
commit 4a558b7efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 7 additions and 27 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -586,8 +586,6 @@ def make_return_doc(
set_missing_values,
)
doclist.set_onload("ignore_price_list", True)
return doclist

View File

@ -357,7 +357,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
onload_post_render() {
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());
} else if(this.frm.doc.__islocal && this.frm.doc.company && this.frm.doc["items"]
&& !this.frm.doc.is_pos) {
@ -963,9 +963,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
let me = this;
this.set_dynamic_labels();
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
&& !(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,
function(exchange_rate) {
@ -997,7 +997,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
}
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();
} else if (!this.in_apply_price_list){
this.apply_price_list();
@ -1084,9 +1084,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
this.set_dynamic_labels();
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 &&
!(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,
function(exchange_rate) {
me.frm.set_value("plc_conversion_rate", exchange_rate);
@ -1475,7 +1475,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
}
// 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.
// `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();

View File

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

View File

@ -995,7 +995,6 @@ def make_delivery_note(source_name, target_doc=None, kwargs=None):
# Should be called after mapping items.
set_missing_values(so, target_doc)
target_doc.set_onload("ignore_price_list", True)
return target_doc
@ -1085,8 +1084,6 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
if automatically_fetch_payment_terms:
doclist.set_payment_schedule()
doclist.set_onload("ignore_price_list", True)
return doclist

View File

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

View File

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