From 8cb0632081bb7a2970145d040dd6e2600a0dde19 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 10 Dec 2025 13:49:46 +0530 Subject: [PATCH 1/3] fix: make sure buying/selling default terms from company master is default --- erpnext/controllers/buying_controller.py | 12 ++++++++++++ erpnext/controllers/selling_controller.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 373481fee72..4e3a1cfdc20 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -81,6 +81,18 @@ class BuyingController(SubcontractingController): ), ) + if ( + self.get("company") + and ( + default_buying_terms := frappe.get_value( + "Company", self.get("company"), "default_buying_terms" + ) + ) + and not self.get("tc_name") + ): + self.tc_name = default_buying_terms + self.terms = frappe.get_value("Terms and Conditions", self.get("tc_name"), "terms") + def validate_posting_date_with_po(self): po_list = {x.purchase_order for x in self.items if x.purchase_order} diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index cafcf0195db..cf51902c51d 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -43,6 +43,18 @@ class SellingController(StockController): ), ) + if ( + self.get("company") + and ( + default_selling_terms := frappe.get_value( + "Company", self.get("company"), "default_selling_terms" + ) + ) + and not self.get("tc_name") + ): + self.tc_name = default_selling_terms + self.terms = frappe.get_value("Terms and Conditions", self.get("tc_name"), "terms") + def validate(self): super().validate() self.validate_items() From 3787b9fbe5554caecfbdfa311b4cd4e551f232c5 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 10 Dec 2025 21:57:33 +0530 Subject: [PATCH 2/3] fix: check if `terms` is not set in buying controller --- erpnext/controllers/buying_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 4e3a1cfdc20..a0d51a0c016 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -89,6 +89,7 @@ class BuyingController(SubcontractingController): ) ) and not self.get("tc_name") + and not self.get("terms") ): self.tc_name = default_buying_terms self.terms = frappe.get_value("Terms and Conditions", self.get("tc_name"), "terms") From 074bdd119b39d304a947eddd9d32f6c1a3ae952e Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 10 Dec 2025 21:58:16 +0530 Subject: [PATCH 3/3] fix: check if `terms` is not set in selling controller --- erpnext/controllers/selling_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index cf51902c51d..d7d12ff46bb 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -51,6 +51,7 @@ class SellingController(StockController): ) ) and not self.get("tc_name") + and not self.get("terms") ): self.tc_name = default_selling_terms self.terms = frappe.get_value("Terms and Conditions", self.get("tc_name"), "terms")