Merge pull request #50149 from Dharanidharan2813/fix/payment-terms-template-fetching

This commit is contained in:
Diptanil Saha
2025-12-02 12:05:12 +05:30
committed by GitHub
2 changed files with 35 additions and 1 deletions

View File

@@ -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]},

View File

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