From b1149fe950bcdbba2b2e55e5314617b0e611e0f5 Mon Sep 17 00:00:00 2001 From: SowmyaArunachalam Date: Wed, 28 Jan 2026 22:23:10 +0530 Subject: [PATCH] fix: consider payment term only when enabled --- .../selling/doctype/quotation/quotation.py | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index a7ab743acd8..8f39e857ea1 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -451,34 +451,33 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False, ar child_filter = d.name in filtered_items if filtered_items else True return child_filter - doclist = get_mapped_doc( - "Quotation", - source_name, - { - "Quotation": { - "doctype": "Sales Order", - "validation": {"docstatus": ["=", 1]}, - }, - "Quotation Item": { - "doctype": "Sales Order Item", - "field_map": {"parent": "prevdoc_docname", "name": "quotation_item"}, - "postprocess": update_item, - "condition": lambda d: can_map_row(d) and select_item(d), - }, - "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True}, - "Sales Team": {"doctype": "Sales Team", "add_if_empty": True}, - }, - target_doc, - set_missing_values, - ignore_permissions=ignore_permissions, - ) - automatically_fetch_payment_terms = cint( frappe.get_single_value("Selling Settings", "automatically_fetch_payment_terms_from_quotation") ) + mapping = { + "Quotation": {"doctype": "Sales Order", "validation": {"docstatus": ["=", 1]}}, + "Quotation Item": { + "doctype": "Sales Order Item", + "field_map": {"parent": "prevdoc_docname", "name": "quotation_item"}, + "postprocess": update_item, + "condition": lambda d: can_map_row(d) and select_item(d), + }, + "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True}, + "Sales Team": {"doctype": "Sales Team", "add_if_empty": True}, + } + if automatically_fetch_payment_terms: - doclist.set_payment_schedule() + mapping["Payment Schedule"] = {"doctype": "Payment Schedule", "add_if_empty": True} + + doclist = get_mapped_doc( + "Quotation", + source_name, + mapping, + target_doc, + set_missing_values, + ignore_permissions=ignore_permissions, + ) return doclist