mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 15:38:39 +00:00
refactor: parse native JSON request args in buying/doctype/purchase_order/mapper.py
Use frappe.parse_json instead of json.loads so the whitelisted endpoints accept native JSON types (list/dict/bool) in addition to JSON strings.
This commit is contained in:
@@ -27,8 +27,7 @@ def make_purchase_receipt(
|
||||
):
|
||||
if args is None:
|
||||
args = {}
|
||||
if isinstance(args, str):
|
||||
args = json.loads(args)
|
||||
args = frappe.parse_json(args)
|
||||
|
||||
has_unit_price_items = frappe.db.get_value("Purchase Order", source_name, "has_unit_price_items")
|
||||
|
||||
@@ -123,8 +122,7 @@ def make_purchase_invoice_from_portal(purchase_order_name: str):
|
||||
def get_mapped_purchase_invoice(source_name, target_doc=None, ignore_permissions=False, args=None):
|
||||
if args is None:
|
||||
args = {}
|
||||
if isinstance(args, str):
|
||||
args = json.loads(args)
|
||||
args = frappe.parse_json(args)
|
||||
|
||||
def postprocess(source, target):
|
||||
target.flags.ignore_permissions = ignore_permissions
|
||||
@@ -294,7 +292,7 @@ def get_mapped_subcontracting_order(source_name: str, target_doc: str | Document
|
||||
) or frappe.get_value("Production Plan", target_doc.production_plan, "reserve_stock")
|
||||
|
||||
if target_doc and isinstance(target_doc, str):
|
||||
target_doc = json.loads(target_doc)
|
||||
target_doc = frappe.parse_json(target_doc)
|
||||
for key in ["service_items", "items", "supplied_items"]:
|
||||
if key in target_doc:
|
||||
del target_doc[key]
|
||||
|
||||
Reference in New Issue
Block a user