diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 863bb74012b..fb684155d45 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -1413,7 +1413,6 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False, a "doctype": "Sales Invoice", "field_map": { "party_account_currency": "party_account_currency", - "payment_terms_template": "payment_terms_template", }, "field_no_map": ["payment_terms_template"], "validation": {"docstatus": ["=", 1]}, diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index ed0a1083e11..7ff4c3e5c63 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -177,6 +177,9 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase): so.load_from_db() self.assertEqual(so.per_billed, 0) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"automatically_fetch_payment_terms": 1} + ) # Enable auto fetch def test_make_sales_invoice_with_terms(self): so = make_sales_order(do_not_submit=True) @@ -205,6 +208,38 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase): si1 = make_sales_invoice(so.name) self.assertEqual(len(si1.get("items")), 0) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"automatically_fetch_payment_terms": 1} + ) # Enable auto fetch + def test_auto_fetch_terms_enable(self): + so = make_sales_order(do_not_submit=True) + + so.payment_terms_template = "_Test Payment Term Template" + so.save() + so.submit() + + si = make_sales_invoice(so.name) + # Check if payment terms are copied from sales order to sales invoice + self.assertTrue(si.payment_terms_template) + si.insert() + si.submit() + + @IntegrationTestCase.change_settings( + "Accounts Settings", {"automatically_fetch_payment_terms": 0} + ) # Disable auto fetch + def test_auto_fetch_terms_disable(self): + so = make_sales_order(do_not_submit=True) + + so.payment_terms_template = "_Test Payment Term Template" + so.save() + so.submit() + + si = make_sales_invoice(so.name) + # Check if payment terms are not copied from sales order to sales invoice + self.assertFalse(si.payment_terms_template) + si.insert() + si.submit() + def test_update_qty(self): so = make_sales_order()