Skip to content

Commit

Permalink
fix: don't overwrite existing terms in transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Jan 24, 2024
1 parent 7a6a789 commit 77b044f
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions erpnext/public/js/controllers/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,16 +795,34 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
me.frm.set_value("letter_head", company_doc.default_letter_head);
}
}
let selling_doctypes_for_tc = ["Sales Invoice", "Quotation", "Sales Order", "Delivery Note"];
if (company_doc.default_selling_terms && frappe.meta.has_field(me.frm.doc.doctype, "tc_name") &&
selling_doctypes_for_tc.indexOf(me.frm.doc.doctype) != -1) {

if (
company_doc.default_selling_terms &&
frappe.meta.has_field(me.frm.doc.doctype, "tc_name") &&
[
"Sales Invoice",
"Quotation",
"Sales Order",
"Delivery Note",
].includes(me.frm.doc.doctype) &&
!me.frm.doc.tc_name
) {
me.frm.set_value("tc_name", company_doc.default_selling_terms);
}
let buying_doctypes_for_tc = ["Request for Quotation", "Supplier Quotation", "Purchase Order",
"Material Request", "Purchase Receipt"];
// Purchase Invoice is excluded as per issue #3345
if (company_doc.default_buying_terms && frappe.meta.has_field(me.frm.doc.doctype, "tc_name") &&
buying_doctypes_for_tc.indexOf(me.frm.doc.doctype) != -1) {

if (
company_doc.default_buying_terms &&
frappe.meta.has_field(me.frm.doc.doctype, "tc_name") &&
[
"Request for Quotation",
"Supplier Quotation",
"Purchase Order",
// Purchase Invoice is excluded as per issue #3345
"Material Request",
"Purchase Receipt",
].includes(me.frm.doc.doctype) &&
!me.frm.doc.tc_name
) {
me.frm.set_value("tc_name", company_doc.default_buying_terms);
}

Expand Down

0 comments on commit 77b044f

Please sign in to comment.