fix: logical error in where condition of qb query

(cherry picked from commit 47f8a86003)

# Conflicts:
#	erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.json
This commit is contained in:
Mihir Kandoi
2025-01-20 12:41:28 +05:30
committed by Mergify
parent d6e0c6c969
commit c102e51eb1
3 changed files with 16 additions and 2 deletions

View File

@@ -1404,7 +1404,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
@@ -1424,6 +1424,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),
},
)