mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 11:49:10 +00:00
* feat: Adding requested qty in packed item (#53486)
* feat: Adding requested qty in packed item
* fix: correct import path
---------
Co-authored-by: Nishka Gosalia <nishkagosalia@Nishkas-MacBook-Air.local>
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
(cherry picked from commit 953f089c06)
# Conflicts:
# erpnext/patches.txt
* chore: resolve conflicts
---------
Co-authored-by: Nishka Gosalia <58264710+nishkagosalia@users.noreply.github.com>
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
This commit is contained in:
24
erpnext/patches/v16_0/update_requested_qty_packed_item.py
Normal file
24
erpnext/patches/v16_0/update_requested_qty_packed_item.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import frappe
|
||||
from frappe.query_builder.functions import Sum
|
||||
|
||||
|
||||
def execute():
|
||||
MaterialRequestItem = frappe.qb.DocType("Material Request Item")
|
||||
|
||||
mri_query = (
|
||||
frappe.qb.from_(MaterialRequestItem)
|
||||
.select(MaterialRequestItem.packed_item, Sum(MaterialRequestItem.qty))
|
||||
.where((MaterialRequestItem.packed_item.isnotnull()) & (MaterialRequestItem.docstatus == 1))
|
||||
.groupby(MaterialRequestItem.packed_item)
|
||||
)
|
||||
|
||||
mri_data = mri_query.run()
|
||||
|
||||
if not mri_data:
|
||||
return
|
||||
|
||||
updates_against_mr = {data[0]: {"requested_qty": data[1]} for data in mri_data}
|
||||
|
||||
frappe.db.auto_commit_on_many_writes = True
|
||||
frappe.db.bulk_update("Packed Item", updates_against_mr)
|
||||
frappe.db.auto_commit_on_many_writes = False
|
||||
Reference in New Issue
Block a user