diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index d883c3adc72fe2c2d0fecde47520aca01c91c885..b1409abe9b302fd3c345eb4c6aa4af2c8fb83895 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -81,6 +81,19 @@ 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") + and not self.get("terms") + ): + 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 056dc2a38d3227f0b584cce5cb7f7b91f34b05a9..383fd66731eed7c1e9423341537a190974f0833c 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -48,6 +48,19 @@ 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") + and not self.get("terms") + ): + 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()