[Patch] Update material transferred for manufacturing for existing entries
This commit is contained in:
parent
ebbdd772a9
commit
56fcf30cb9
@ -164,4 +164,5 @@ erpnext.patches.v5_0.update_item_and_description_again
|
|||||||
erpnext.patches.v5_0.repost_gle_for_jv_with_multiple_party
|
erpnext.patches.v5_0.repost_gle_for_jv_with_multiple_party
|
||||||
erpnext.patches.v5_0.portal_fixes
|
erpnext.patches.v5_0.portal_fixes
|
||||||
erpnext.patches.v5_0.reset_values_in_tools
|
erpnext.patches.v5_0.reset_values_in_tools
|
||||||
execute:frappe.delete_doc("Page", "users")
|
execute:frappe.delete_doc("Page", "users")
|
||||||
|
erpnext.patches.v5_0.update_material_transferred_for_manufacturing_again
|
@ -0,0 +1,18 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
pro_order_qty_transferred = frappe._dict()
|
||||||
|
for se in frappe.db.sql("""select production_order, sum(fg_completed_qty) as transferred_qty
|
||||||
|
from `tabStock Entry`
|
||||||
|
where docstatus=1 and ifnull(production_order, '') != ''
|
||||||
|
and purpose = 'Material Transfer for Manufacture'
|
||||||
|
group by production_order""", as_dict=1):
|
||||||
|
pro_order_qty_transferred.setdefault(se.production_order, se.transferred_qty)
|
||||||
|
|
||||||
|
for d in frappe.get_all("Production Order", filters={"docstatus": 1}, fields=["name", "qty"]):
|
||||||
|
if d.name in pro_order_qty_transferred:
|
||||||
|
material_transferred_for_manufacturing = pro_order_qty_transferred.get(d.name) \
|
||||||
|
if pro_order_qty_transferred.get(d.name) <= d.qty else d.qty
|
||||||
|
|
||||||
|
frappe.db.sql("""update `tabProduction Order` set material_transferred_for_manufacturing=%s
|
||||||
|
where name=%s""", (material_transferred_for_manufacturing, d.name))
|
Loading…
x
Reference in New Issue
Block a user