fix: consider payment term only when enabled

(cherry picked from commit b1149fe950)
This commit is contained in:
SowmyaArunachalam
2026-01-28 22:23:10 +05:30
committed by Mergify
parent f7dd730bc3
commit 1470a79a1b

View File

@@ -446,14 +446,12 @@ 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 child_filter = d.name in filtered_items if filtered_items else True
return child_filter return child_filter
doclist = get_mapped_doc( automatically_fetch_payment_terms = cint(
"Quotation", frappe.get_single_value("Selling Settings", "automatically_fetch_payment_terms_from_quotation")
source_name, )
{
"Quotation": { mapping = {
"doctype": "Sales Order", "Quotation": {"doctype": "Sales Order", "validation": {"docstatus": ["=", 1]}},
"validation": {"docstatus": ["=", 1]},
},
"Quotation Item": { "Quotation Item": {
"doctype": "Sales Order Item", "doctype": "Sales Order Item",
"field_map": {"parent": "prevdoc_docname", "name": "quotation_item"}, "field_map": {"parent": "prevdoc_docname", "name": "quotation_item"},
@@ -462,19 +460,20 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False, ar
}, },
"Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True}, "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True},
"Sales Team": {"doctype": "Sales Team", "add_if_empty": True}, "Sales Team": {"doctype": "Sales Team", "add_if_empty": True},
}, }
if automatically_fetch_payment_terms:
mapping["Payment Schedule"] = {"doctype": "Payment Schedule", "add_if_empty": True}
doclist = get_mapped_doc(
"Quotation",
source_name,
mapping,
target_doc, target_doc,
set_missing_values, set_missing_values,
ignore_permissions=ignore_permissions, ignore_permissions=ignore_permissions,
) )
automatically_fetch_payment_terms = cint(
frappe.get_single_value("Selling Settings", "automatically_fetch_payment_terms_from_quotation")
)
if automatically_fetch_payment_terms:
doclist.set_payment_schedule()
return doclist return doclist