From 7fcfea6db26f99520618b7c09d866324bb7f86ea Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sun, 9 Aug 2026 20:42:02 +0530 Subject: [PATCH] chore: resolve conflict --- .../doctype/job_card/job_card.py | 55 ++++++++----------- .../doctype/job_card/test_job_card.py | 3 - 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py index b8fa052e801..a2708bb5eac 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.py +++ b/erpnext/manufacturing/doctype/job_card/job_card.py @@ -1344,31 +1344,19 @@ class JobCard(Document): if data and len(data) > 0: current_operation_qty = flt(data[0].completed_qty) -<<<<<<< HEAD current_operation_qty += flt(self.total_completed_qty) - data = frappe.get_all( -======= - for row in self.get_previous_operations(): - if self.track_semi_finished_goods: - self.validate_previous_operation_manufactured_qty(row, current_operation_qty) - else: - self.validate_previous_operation(row, current_operation_qty) - - def get_previous_operations(self): previous_operations = frappe.get_all( ->>>>>>> 3bd3354152 (fix(job_card): require the previous operation to be manufactured (#57684)) "Work Order Operation", fields=["name", "operation", "status", "completed_qty", "sequence_id"], filters={"docstatus": 1, "parent": self.work_order, "sequence_id": ("<", self.sequence_id)}, order_by="sequence_id, idx", ) -<<<<<<< HEAD message = "Job Card {}: As per the sequence of the operations in the work order {}".format( bold(self.name), bold(get_link_to_form("Work Order", self.work_order)) ) -======= + if self.track_semi_finished_goods and previous_operations: manufactured_qty = self.get_manufactured_qty_per_operation( [row.name for row in previous_operations] @@ -1377,27 +1365,11 @@ class JobCard(Document): for row in previous_operations: row.manufactured_qty = flt(manufactured_qty.get(row.name)) - return previous_operations + for row in previous_operations: + if self.track_semi_finished_goods: + self.validate_previous_operation_manufactured_qty(row, current_operation_qty) + continue - def get_manufactured_qty_per_operation(self, operation_ids): - job_card = frappe.qb.DocType("Job Card") - - data = ( - frappe.qb.from_(job_card) - .select(job_card.operation_id, Sum(job_card.manufactured_qty)) - .where( - (job_card.work_order == self.work_order) - & (job_card.docstatus == 1) - & (IfNull(job_card.is_corrective_job_card, 0) == 0) - & (job_card.operation_id.isin(operation_ids)) - ) - .groupby(job_card.operation_id) - ).run() - - return dict(data) ->>>>>>> 3bd3354152 (fix(job_card): require the previous operation to be manufactured (#57684)) - - for row in data: if not row.completed_qty: frappe.throw( _("{0}, complete the operation {1} before the operation {2}.").format( @@ -1426,6 +1398,23 @@ class JobCard(Document): ) ) + def get_manufactured_qty_per_operation(self, operation_ids): + job_card = frappe.qb.DocType("Job Card") + + data = ( + frappe.qb.from_(job_card) + .select(job_card.operation_id, Sum(job_card.manufactured_qty)) + .where( + (job_card.work_order == self.work_order) + & (job_card.docstatus == 1) + & (IfNull(job_card.is_corrective_job_card, 0) == 0) + & (job_card.operation_id.isin(operation_ids)) + ) + .groupby(job_card.operation_id) + ).run() + + return dict(data) + def validate_previous_operation_manufactured_qty(self, row, current_operation_qty): manufactured_qty = flt(row.manufactured_qty) diff --git a/erpnext/manufacturing/doctype/job_card/test_job_card.py b/erpnext/manufacturing/doctype/job_card/test_job_card.py index db79f149345..4b80d68dd17 100644 --- a/erpnext/manufacturing/doctype/job_card/test_job_card.py +++ b/erpnext/manufacturing/doctype/job_card/test_job_card.py @@ -10,11 +10,8 @@ from frappe.utils.data import add_to_date, now, today from erpnext.manufacturing.doctype.job_card.job_card import ( JobCardOverTransferError, -<<<<<<< HEAD OperationMismatchError, -======= OperationSequenceError, ->>>>>>> 3bd3354152 (fix(job_card): require the previous operation to be manufactured (#57684)) OverlapError, make_corrective_job_card, make_material_request,