Skip to content

Commit

Permalink
fix: use predefined onload property load_after_mapping (backport #3…
Browse files Browse the repository at this point in the history
…8209) (#38518)

Co-authored-by: Sagar Vora <sagar@resilient.tech>
fix: use predefined onload property `load_after_mapping` (#38209)
  • Loading branch information
mergify[bot] and sagarvora authored Dec 4, 2023
1 parent b7fe163 commit 9f23b7e
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 28 deletions.
2 changes: 0 additions & 2 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,4 @@ def update_item(obj, target, source_parent):
target_doc,
)

doc.set_onload("ignore_price_list", True)

return doc
1 change: 0 additions & 1 deletion erpnext/accounts/doctype/sales_invoice/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,6 @@ def update_item(source_doc, target_doc, source_parent):
set_missing_values,
)

doclist.set_onload("ignore_price_list", True)
return doclist


Expand Down
3 changes: 0 additions & 3 deletions erpnext/buying/doctype/purchase_order/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,6 @@ def update_item(obj, target, source_parent):
set_missing_values,
)

doc.set_onload("ignore_price_list", True)

return doc


Expand Down Expand Up @@ -622,7 +620,6 @@ def update_item(obj, target, source_parent):
postprocess,
ignore_permissions=ignore_permissions,
)
doc.set_onload("ignore_price_list", True)

return doc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def update_item(obj, target, source_parent):
set_missing_values,
)

doclist.set_onload("ignore_price_list", True)
return doclist


Expand Down
2 changes: 0 additions & 2 deletions erpnext/controllers/sales_and_purchase_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,6 @@ def update_terms(source_doc, target_doc, source_parent):
set_missing_values,
)

doclist.set_onload("ignore_price_list", True)

return doclist


Expand Down
14 changes: 7 additions & 7 deletions erpnext/public/js/controllers/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,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) {
Expand Down Expand Up @@ -918,9 +918,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) {
Expand Down Expand Up @@ -952,7 +952,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();
Expand Down Expand Up @@ -1039,9 +1039,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);
Expand Down Expand Up @@ -1420,7 +1420,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();
Expand Down
5 changes: 0 additions & 5 deletions erpnext/selling/doctype/quotation/quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,6 @@ def can_map_row(item) -> bool:
ignore_permissions=ignore_permissions,
)

# postprocess: fetch shipping address, set missing values
doclist.set_onload("ignore_price_list", True)

return doclist


Expand Down Expand Up @@ -423,8 +420,6 @@ def update_item(obj, target, source_parent):
ignore_permissions=ignore_permissions,
)

doclist.set_onload("ignore_price_list", True)

return doclist


Expand Down
4 changes: 0 additions & 4 deletions erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,6 @@ def condition(doc):

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


Expand Down Expand Up @@ -806,8 +804,6 @@ def update_item(source, target, source_parent):
if automatically_fetch_payment_terms:
doclist.set_payment_schedule()

doclist.set_onload("ignore_price_list", True)

return doclist


Expand Down
2 changes: 0 additions & 2 deletions erpnext/stock/doctype/delivery_note/delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,6 @@ def get_pending_qty(item_row):
if automatically_fetch_payment_terms:
doc.set_payment_schedule()

doc.set_onload("ignore_price_list", True)

return doc


Expand Down
1 change: 0 additions & 1 deletion erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,6 @@ def get_pending_qty(item_row):
set_missing_values,
)

doclist.set_onload("ignore_price_list", True)
return doclist


Expand Down

0 comments on commit 9f23b7e

Please sign in to comment.