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()