mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-01 20:48:27 +00:00
Co-authored-by: diptanilsaha <diptanil@frappe.io> fix(`get_stock_balance`): validate inventory dimension fieldnames (#54587)
This commit is contained in:
@@ -10,6 +10,7 @@ from frappe.query_builder.functions import IfNull, Sum
|
|||||||
from frappe.utils import cstr, flt, get_link_to_form, get_time, getdate, nowdate, nowtime
|
from frappe.utils import cstr, flt, get_link_to_form, get_time, getdate, nowdate, nowtime
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
|
from erpnext.stock.doctype.inventory_dimension.inventory_dimension import get_inventory_dimensions
|
||||||
from erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle import get_available_serial_nos
|
from erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle import get_available_serial_nos
|
||||||
from erpnext.stock.doctype.warehouse.warehouse import get_child_warehouses
|
from erpnext.stock.doctype.warehouse.warehouse import get_child_warehouses
|
||||||
from erpnext.stock.serial_batch_bundle import BatchNoValuation, SerialNoValuation
|
from erpnext.stock.serial_batch_bundle import BatchNoValuation, SerialNoValuation
|
||||||
@@ -122,11 +123,19 @@ def get_stock_balance(
|
|||||||
}
|
}
|
||||||
|
|
||||||
extra_cond = ""
|
extra_cond = ""
|
||||||
|
|
||||||
if inventory_dimensions_dict:
|
if inventory_dimensions_dict:
|
||||||
|
inventory_dimensions_fieldname = [d.get("fieldname") for d in get_inventory_dimensions()]
|
||||||
|
|
||||||
for field, value in inventory_dimensions_dict.items():
|
for field, value in inventory_dimensions_dict.items():
|
||||||
column = frappe.utils.sanitize_column(field)
|
if field not in inventory_dimensions_fieldname:
|
||||||
|
frappe.throw(
|
||||||
|
_("{0} is not a valid {1} fieldname.").format(
|
||||||
|
frappe.bold(field), frappe.bold("Inventory Dimension")
|
||||||
|
)
|
||||||
|
)
|
||||||
args[field] = value
|
args[field] = value
|
||||||
extra_cond += f" and {column} = %({field})s"
|
extra_cond += f" and {field} = %({field})s"
|
||||||
|
|
||||||
last_entry = get_previous_sle(args, extra_cond=extra_cond)
|
last_entry = get_previous_sle(args, extra_cond=extra_cond)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user