From 47f8a8600374a6a130c45c12e65f1cf11fa450e0 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 20 Jan 2025 12:41:28 +0530 Subject: [PATCH] fix: logical error in where condition of qb query --- erpnext/manufacturing/doctype/bom/bom.py | 3 ++- .../landed_cost_taxes_and_charges.json | 12 ++++++++++-- .../landed_cost_taxes_and_charges.py | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index a1194811f0f..79fe1d5b0f0 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -1466,7 +1466,7 @@ def add_operations_cost(stock_entry, work_order=None, expense_account=None): query = ( frappe.qb.from_(table) .select(Sum(table.amount).as_("amount")) - .where(table.parent.isin(subquery) & (table.description == "Corrective Operation Cost")) + .where(table.parent.isin(subquery) & (table.has_corrective_cost == 1)) ) return query.run(as_dict=True)[0].amount or 0 @@ -1486,6 +1486,7 @@ def add_operations_cost(stock_entry, work_order=None, expense_account=None): { "expense_account": expense_account, "description": "Corrective Operation Cost", + "has_corrective_cost": 1, "amount": remaining_cc / max_qty * flt(stock_entry.fg_completed_qty), }, ) diff --git a/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.json b/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.json index df5c0f9e91c..57328772e13 100644 --- a/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.json +++ b/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.json @@ -11,7 +11,8 @@ "description", "col_break3", "amount", - "base_amount" + "base_amount", + "has_corrective_cost" ], "fields": [ { @@ -62,12 +63,19 @@ "label": "Amount (Company Currency)", "options": "Company:company:default_currency", "read_only": 1 + }, + { + "default": "0", + "fieldname": "has_corrective_cost", + "fieldtype": "Check", + "label": "Has Corrective Cost", + "read_only": 1 } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-03-27 13:09:59.493991", + "modified": "2025-01-20 12:22:03.455762", "modified_by": "Administrator", "module": "Stock", "name": "Landed Cost Taxes and Charges", diff --git a/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.py b/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.py index 8509cb71d85..a3f7f037d60 100644 --- a/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.py +++ b/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.py @@ -20,6 +20,7 @@ class LandedCostTaxesandCharges(Document): description: DF.SmallText exchange_rate: DF.Float expense_account: DF.Link | None + has_corrective_cost: DF.Check parent: DF.Data parentfield: DF.Data parenttype: DF.Data