mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-15 00:06:22 +00:00
fix: Initialise pending qty as planned qty for independent item rows in Prod Plan
- Rows that are not fetched from MR or SO, had pending qty 0 throughout
- Initialise pending qty on save only.
- After submit this field will be updated by work order/stock entry
- Bring functions in `validate()` closer to the top
(cherry picked from commit eaccef6116)
This commit is contained in:
@@ -29,9 +29,24 @@ from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
|
||||
|
||||
class ProductionPlan(Document):
|
||||
def validate(self):
|
||||
self.set_pending_qty_in_row_without_reference()
|
||||
self.calculate_total_planned_qty()
|
||||
self.set_status()
|
||||
|
||||
def set_pending_qty_in_row_without_reference(self):
|
||||
"Set Pending Qty in independent rows (not from SO or MR)."
|
||||
if self.docstatus > 0: # set only to initialise value before submit
|
||||
return
|
||||
|
||||
for item in self.po_items:
|
||||
if not item.get("sales_order") or not item.get("material_request"):
|
||||
item.pending_qty = item.planned_qty
|
||||
|
||||
def calculate_total_planned_qty(self):
|
||||
self.total_planned_qty = 0
|
||||
for d in self.po_items:
|
||||
self.total_planned_qty += flt(d.planned_qty)
|
||||
|
||||
def validate_data(self):
|
||||
for d in self.get('po_items'):
|
||||
if not d.bom_no:
|
||||
@@ -264,11 +279,6 @@ class ProductionPlan(Document):
|
||||
'qty': so_detail['qty']
|
||||
})
|
||||
|
||||
def calculate_total_planned_qty(self):
|
||||
self.total_planned_qty = 0
|
||||
for d in self.po_items:
|
||||
self.total_planned_qty += flt(d.planned_qty)
|
||||
|
||||
def calculate_total_produced_qty(self):
|
||||
self.total_produced_qty = 0
|
||||
for d in self.po_items:
|
||||
|
||||
Reference in New Issue
Block a user