mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 07:01:56 +00:00
fix(job_card): apply the completion dialog's qty to manufacture
Both the desk dialog and the shop floor session dialog send for_quantity when completing a job card, but complete_job_card dropped it. Reducing Qty to Manufacture to 3 on a job card of 5 left for_quantity at 5, so set_process_loss turned the untouched 2 into process loss on the next save. The dialog qty covers the current cycle, so add it to the qty already completed by the earlier cycles of the job card instead of overwriting for_quantity, and validate the pending qty against the result.
This commit is contained in:
@@ -1657,6 +1657,7 @@ class JobCard(Document):
|
||||
if isinstance(kwargs, dict):
|
||||
kwargs = frappe._dict(kwargs)
|
||||
|
||||
self.set_for_quantity(kwargs)
|
||||
self.validate_complete_job_card_qty(kwargs)
|
||||
|
||||
self.pending_qty = flt(kwargs.pending_qty)
|
||||
@@ -1667,6 +1668,14 @@ class JobCard(Document):
|
||||
if kwargs.auto_submit:
|
||||
self.auto_submit_job_card(kwargs.auto_submit)
|
||||
|
||||
def set_for_quantity(self, kwargs):
|
||||
"""Qty to Manufacture of the completion dialog covers the current cycle only,
|
||||
so the qty completed by the earlier cycles of this job card is kept."""
|
||||
if not flt(kwargs.for_quantity):
|
||||
return
|
||||
|
||||
self.for_quantity = flt(self.total_completed_qty) + flt(kwargs.for_quantity)
|
||||
|
||||
def validate_docstatus(self):
|
||||
if self.docstatus == 2:
|
||||
frappe.throw(_("Cancelled Job Card cannot be processed."))
|
||||
|
||||
Reference in New Issue
Block a user