From 8235a551f0c56e92398358acc2d573821f39b999 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Tue, 25 Nov 2025 12:08:31 +0530 Subject: [PATCH 1/2] refactor: further changes to adapt to query builder changes --- erpnext/manufacturing/doctype/bom_creator/bom_creator.py | 4 +++- erpnext/patches/v14_0/single_to_multi_dunning.py | 3 ++- erpnext/projects/doctype/timesheet/timesheet.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom_creator/bom_creator.py b/erpnext/manufacturing/doctype/bom_creator/bom_creator.py index d67f0c3536b..bb62c7a84da 100644 --- a/erpnext/manufacturing/doctype/bom_creator/bom_creator.py +++ b/erpnext/manufacturing/doctype/bom_creator/bom_creator.py @@ -360,6 +360,8 @@ class BOMCreator(Document): @frappe.whitelist() def get_children(doctype=None, parent=None, **kwargs): + from pypika.terms import ValueWrapper + if isinstance(kwargs, str): kwargs = frappe.parse_json(kwargs) @@ -373,7 +375,7 @@ def get_children(doctype=None, parent=None, **kwargs): "parent as parent_id", "qty", "idx", - "'BOM Creator Item' as doctype", + ValueWrapper("BOM Creator Item").as_("doctype"), "name", "uom", "rate", diff --git a/erpnext/patches/v14_0/single_to_multi_dunning.py b/erpnext/patches/v14_0/single_to_multi_dunning.py index 3def5922c07..3ddba8c76e6 100644 --- a/erpnext/patches/v14_0/single_to_multi_dunning.py +++ b/erpnext/patches/v14_0/single_to_multi_dunning.py @@ -1,4 +1,5 @@ import frappe +from pypika.terms import LiteralValue from erpnext.accounts.general_ledger import make_reverse_gl_entries @@ -39,7 +40,7 @@ def execute(): "payment_amount", # at the time of creating this dunning, the full amount was outstanding "payment_amount as outstanding", - "'0' as paid_amount", + LiteralValue(0).as_("paid_amount"), "discounted_amount", ], ) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 2119d214a61..80552abe895 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -383,7 +383,7 @@ def get_timesheet_data(name, project): data = frappe.get_all( "Timesheet", fields=[ - "(total_billable_amount - total_billed_amount) as billing_amt", + {"SUB": ["total_billable_amount", "total_billed_amount"], "as": "billing_amt"}, "total_billable_hours as billing_hours", ], filters={"name": name}, From a2fadd9347b8f5474ec4fc12321206ff25beacb8 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Fri, 28 Nov 2025 13:33:24 +0530 Subject: [PATCH 2/2] fix: use `ValueWrapper` consistently --- erpnext/manufacturing/doctype/bom_creator/bom_creator.py | 3 +-- erpnext/patches/v14_0/single_to_multi_dunning.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom_creator/bom_creator.py b/erpnext/manufacturing/doctype/bom_creator/bom_creator.py index bb62c7a84da..18599b2c20c 100644 --- a/erpnext/manufacturing/doctype/bom_creator/bom_creator.py +++ b/erpnext/manufacturing/doctype/bom_creator/bom_creator.py @@ -7,6 +7,7 @@ import frappe from frappe import _ from frappe.model.document import Document from frappe.utils import cint, flt, sbool +from pypika.terms import ValueWrapper from erpnext.manufacturing.doctype.bom.bom import get_bom_item_rate @@ -360,8 +361,6 @@ class BOMCreator(Document): @frappe.whitelist() def get_children(doctype=None, parent=None, **kwargs): - from pypika.terms import ValueWrapper - if isinstance(kwargs, str): kwargs = frappe.parse_json(kwargs) diff --git a/erpnext/patches/v14_0/single_to_multi_dunning.py b/erpnext/patches/v14_0/single_to_multi_dunning.py index 3ddba8c76e6..47d13a0e383 100644 --- a/erpnext/patches/v14_0/single_to_multi_dunning.py +++ b/erpnext/patches/v14_0/single_to_multi_dunning.py @@ -1,5 +1,5 @@ import frappe -from pypika.terms import LiteralValue +from pypika.terms import ValueWrapper from erpnext.accounts.general_ledger import make_reverse_gl_entries @@ -40,7 +40,7 @@ def execute(): "payment_amount", # at the time of creating this dunning, the full amount was outstanding "payment_amount as outstanding", - LiteralValue(0).as_("paid_amount"), + ValueWrapper(0).as_("paid_amount"), "discounted_amount", ], )