From ca4bb96fb4182d784444ee704679550ec6368806 Mon Sep 17 00:00:00 2001 From: Ejaaz Khan Date: Tue, 4 Feb 2025 23:39:29 +0530 Subject: [PATCH 1/3] fix: default payment terms template selected while duplicating (cherry picked from commit 18127603fe837af8856565a2deddc9d3e42ef243) --- erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index a2d02981d64..7e17f7abab7 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -343,7 +343,9 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. account: this.frm.doc.credit_to, price_list: this.frm.doc.buying_price_list, fetch_payment_terms_template: cint( - (this.frm.doc.is_return == 0) & !this.frm.doc.ignore_default_payment_terms_template + (this.frm.doc.is_return == 0) & + !this.frm.doc.ignore_default_payment_terms_template & + (this.frm.doc.__run_link_triggers !== false) ), }, function () { From c52362531cb4209ed14b77bb64bbb675111c666f Mon Sep 17 00:00:00 2001 From: Ejaaz Khan Date: Wed, 5 Feb 2025 00:06:48 +0530 Subject: [PATCH 2/3] fix: payment schedule table is empty while duplicating record (cherry picked from commit fb3f08a44139d12b0d205e3f019cedcca923397a) --- .../doctype/purchase_invoice/purchase_invoice.js | 12 +++++++++--- erpnext/public/js/controllers/transaction.js | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 7e17f7abab7..13430b46449 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -332,6 +332,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. if (this.frm.doc.__onload && this.frm.doc.__onload.load_after_mapping) return; + let payment_terms_template = this.frm.doc.payment_terms_template; + erpnext.utils.get_party_details( this.frm, "erpnext.accounts.party.get_party_details", @@ -343,9 +345,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. account: this.frm.doc.credit_to, price_list: this.frm.doc.buying_price_list, fetch_payment_terms_template: cint( - (this.frm.doc.is_return == 0) & - !this.frm.doc.ignore_default_payment_terms_template & - (this.frm.doc.__run_link_triggers !== false) + (this.frm.doc.is_return == 0) & !this.frm.doc.ignore_default_payment_terms_template ), }, function () { @@ -354,6 +354,12 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. me.frm.doc.tax_withholding_category = me.frm.supplier_tds; me.frm.set_df_property("apply_tds", "read_only", me.frm.supplier_tds ? 0 : 1); me.frm.set_df_property("tax_withholding_category", "hidden", me.frm.supplier_tds ? 0 : 1); + + // while duplicating, don't change payment terms + if (me.frm.doc.__run_link_triggers === false) { + me.frm.set_value("payment_terms_template", payment_terms_template); + me.frm.refresh_field("payment_terms_template"); + } } ); } diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 81a8a617e64..ba08ffe4bb0 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2483,6 +2483,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } payment_terms_template() { + console.log("payment_terms_template outside"); + var me = this; const doc = this.frm.doc; if(doc.payment_terms_template && doc.doctype !== 'Delivery Note' && !doc.is_return) { From df0ca2d1984c53c9f02c7740511d17c5bce838a5 Mon Sep 17 00:00:00 2001 From: Ejaaz Khan Date: Wed, 5 Feb 2025 00:09:16 +0530 Subject: [PATCH 3/3] refactor: remove log (cherry picked from commit bfc01441a073c9e5658c2723b76235f5e8ed237f) --- erpnext/public/js/controllers/transaction.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index ba08ffe4bb0..81a8a617e64 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2483,8 +2483,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } payment_terms_template() { - console.log("payment_terms_template outside"); - var me = this; const doc = this.frm.doc; if(doc.payment_terms_template && doc.doctype !== 'Delivery Note' && !doc.is_return) {