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
This commit is contained in:
parent
7116d7ae0e
commit
eaccef6116
@ -28,9 +28,24 @@ from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
|
|||||||
|
|
||||||
class ProductionPlan(Document):
|
class ProductionPlan(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
self.set_pending_qty_in_row_without_reference()
|
||||||
self.calculate_total_planned_qty()
|
self.calculate_total_planned_qty()
|
||||||
self.set_status()
|
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):
|
def validate_data(self):
|
||||||
for d in self.get('po_items'):
|
for d in self.get('po_items'):
|
||||||
if not d.bom_no:
|
if not d.bom_no:
|
||||||
@ -263,11 +278,6 @@ class ProductionPlan(Document):
|
|||||||
'qty': so_detail['qty']
|
'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):
|
def calculate_total_produced_qty(self):
|
||||||
self.total_produced_qty = 0
|
self.total_produced_qty = 0
|
||||||
for d in self.po_items:
|
for d in self.po_items:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user