diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index a1047c11a96..832992198b6 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -1203,7 +1203,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 d38473e4b69..a78367900eb 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -200,10 +200,16 @@ class TestSalesOrder(AccountsTestMixin, FrappeTestCase): so.load_from_db() self.assertEqual(so.per_billed, 0) +<<<<<<< HEAD @change_settings( "Accounts Settings", {"add_taxes_from_item_tax_template": 0, "add_taxes_from_taxes_and_charges_template": 1}, ) +======= + @IntegrationTestCase.change_settings( + "Accounts Settings", {"automatically_fetch_payment_terms": 1} + ) # Enable auto fetch +>>>>>>> cf1d892d60 (fix: Payment Terms auto-fetched in Sales Invoice even when automatically_fetch_payment_terms is disabled) def test_make_sales_invoice_with_terms(self): so = make_sales_order(do_not_submit=True) @@ -232,6 +238,38 @@ class TestSalesOrder(AccountsTestMixin, FrappeTestCase): 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()