From 8dcb1ab63bc86860ddd59b2c566a48cca9d0fe0d Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Mon, 26 Aug 2024 22:32:16 +0530 Subject: [PATCH] fix: update child table from last source_doc --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 2 +- erpnext/buying/doctype/purchase_order/purchase_order.py | 4 ++-- erpnext/selling/doctype/quotation/quotation.py | 4 ++-- erpnext/selling/doctype/sales_order/sales_order.py | 7 +++++-- erpnext/stock/doctype/delivery_note/delivery_note.py | 2 +- erpnext/stock/doctype/purchase_receipt/purchase_receipt.py | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 4f62ad2f4c4..978c1ad021c 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -2081,7 +2081,7 @@ def make_delivery_note(source_name, target_doc=None): "postprocess": update_item, "condition": lambda doc: doc.delivered_by_supplier != 1, }, - "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "add_if_empty": True}, + "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True}, "Sales Team": { "doctype": "Sales Team", "field_map": {"incentives": "incentives"}, diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index 37592ce77fa..e0cb9dc8292 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -735,7 +735,7 @@ def make_purchase_receipt(source_name, target_doc=None): "condition": lambda doc: abs(doc.received_qty) < abs(doc.qty) and doc.delivered_by_supplier != 1, }, - "Purchase Taxes and Charges": {"doctype": "Purchase Taxes and Charges", "add_if_empty": True}, + "Purchase Taxes and Charges": {"doctype": "Purchase Taxes and Charges", "reset_value": True}, }, target_doc, set_missing_values, @@ -811,7 +811,7 @@ def get_mapped_purchase_invoice(source_name, target_doc=None, ignore_permissions "postprocess": update_item, "condition": lambda doc: (doc.base_amount == 0 or abs(doc.billed_amt) < abs(doc.amount)), }, - "Purchase Taxes and Charges": {"doctype": "Purchase Taxes and Charges", "add_if_empty": True}, + "Purchase Taxes and Charges": {"doctype": "Purchase Taxes and Charges", "reset_value": True}, } doc = get_mapped_doc( diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 1d7d3fcfbe0..2e861bcbec4 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -426,7 +426,7 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False): "postprocess": update_item, "condition": can_map_row, }, - "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "add_if_empty": True}, + "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True}, "Sales Team": {"doctype": "Sales Team", "add_if_empty": True}, "Payment Schedule": {"doctype": "Payment Schedule", "add_if_empty": True}, }, @@ -491,7 +491,7 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False): "postprocess": update_item, "condition": lambda row: not row.is_alternative, }, - "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "add_if_empty": True}, + "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True}, "Sales Team": {"doctype": "Sales Team", "add_if_empty": True}, }, target_doc, diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 8d0329641c7..9bd13184521 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -936,7 +936,7 @@ def make_delivery_note(source_name, target_doc=None, kwargs=None): mapper = { "Sales Order": {"doctype": "Delivery Note", "validation": {"docstatus": ["=", 1]}}, - "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "add_if_empty": True}, + "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True}, "Sales Team": {"doctype": "Sales Team", "add_if_empty": True}, } @@ -1136,7 +1136,10 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False): "condition": lambda doc: doc.qty and (doc.base_amount == 0 or abs(doc.billed_amt) < abs(doc.amount)), }, - "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "add_if_empty": True}, + "Sales Taxes and Charges": { + "doctype": "Sales Taxes and Charges", + "reset_value": True, + }, "Sales Team": {"doctype": "Sales Team", "add_if_empty": True}, }, target_doc, diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index c3622d7a0b0..1e4bb0d143f 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -1048,7 +1048,7 @@ def make_sales_invoice(source_name, target_doc=None, args=None): }, "Sales Taxes and Charges": { "doctype": "Sales Taxes and Charges", - "add_if_empty": True, + "reset_value": True, "ignore": args.get("merge_taxes") if args else 0, }, "Sales Team": { diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index e611361a3e5..0b4cde01064 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -1201,7 +1201,7 @@ def make_purchase_invoice(source_name, target_doc=None, args=None): }, "Purchase Taxes and Charges": { "doctype": "Purchase Taxes and Charges", - "add_if_empty": True, + "reset_value": True, "ignore": args.get("merge_taxes") if args else 0, }, },