mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-13 01:34:10 +00:00
fix: Update Values before after_mapping hook is called (#42682)
* fix: update values before after_mapping hook is called
* fix: appropriate function name
(cherry picked from commit 26fc8ce209)
# Conflicts:
# erpnext/buying/doctype/purchase_order/purchase_order.py
This commit is contained in:
@@ -889,6 +889,28 @@ def make_subcontracting_order(source_name, target_doc=None, save=False, submit=F
|
||||
|
||||
|
||||
def get_mapped_subcontracting_order(source_name, target_doc=None):
|
||||
def post_process(source_doc, target_doc):
|
||||
target_doc.populate_items_table()
|
||||
|
||||
if target_doc.set_warehouse:
|
||||
for item in target_doc.items:
|
||||
item.warehouse = target_doc.set_warehouse
|
||||
else:
|
||||
if source_doc.set_warehouse:
|
||||
for item in target_doc.items:
|
||||
item.warehouse = source_doc.set_warehouse
|
||||
else:
|
||||
for idx, item in enumerate(target_doc.items):
|
||||
item.warehouse = source_doc.items[idx].warehouse
|
||||
|
||||
for idx, item in enumerate(target_doc.items):
|
||||
item.job_card = source_doc.items[idx].job_card
|
||||
if not target_doc.supplier_warehouse:
|
||||
# WIP warehouse is set as Supplier Warehouse in Job Card
|
||||
target_doc.supplier_warehouse = frappe.get_cached_value(
|
||||
"Job Card", item.job_card, "wip_warehouse"
|
||||
)
|
||||
|
||||
if target_doc and isinstance(target_doc, str):
|
||||
target_doc = json.loads(target_doc)
|
||||
for key in ["service_items", "items", "supplied_items"]:
|
||||
@@ -919,8 +941,10 @@ def get_mapped_subcontracting_order(source_name, target_doc=None):
|
||||
},
|
||||
},
|
||||
target_doc,
|
||||
post_process,
|
||||
)
|
||||
|
||||
<<<<<<< HEAD
|
||||
target_doc.populate_items_table()
|
||||
source_doc = frappe.get_doc("Purchase Order", source_name)
|
||||
|
||||
@@ -935,6 +959,8 @@ def get_mapped_subcontracting_order(source_name, target_doc=None):
|
||||
for idx, item in enumerate(target_doc.items):
|
||||
item.warehouse = source_doc.items[idx].warehouse
|
||||
|
||||
=======
|
||||
>>>>>>> 26fc8ce209 (fix: Update Values before `after_mapping` hook is called (#42682))
|
||||
return target_doc
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user