Add completed_qty to test fixtures #280
Conversation
|
An alternative is to add sequence id in the fixturing: https://github.com/agritheory/beam/blob/version-14/beam/tests/setup.py#L343 |
|
@agritheory I tested the sorting with
It didn’t solve the issue, so I kept debugging. The problem comes from row.status != "Completed" # This condition is true, it is not completed yet
row.completed_qty < current_operation_qty # This is also true, and I believe this is what should be avoidedCase where it fails:
if d.completed_qty and not self.sub_operations:
self.total_completed_qty += d.completed_qtyThis causes the validation to fail. Fix applied: when adding job_card.append(
"time_logs",
{
#"completed_qty": wo.qty,
"from_time": start_time,
"to_time": start_time + datetime.timedelta(minutes=time_in_mins),
"time_in_mins": time_in_mins,
"remaining_time_in_mins": time_in_mins,
},
)Tests still pass, and Playwright tests run without issues. Not entirely sure if setting "completed_qty" here is ever required. |
agritheory
left a comment
There was a problem hiding this comment.
I think the completed_qty fix is the correct approach
|
@lauty95 Please also cherry pick this for a PR against the version-15 branch |
ERPNext has updated recently: frappe/erpnext#48745
If you try to execute bench execute 'beam.tests.setup.before_test' with ERPNext updated to v15.71.1, it will throw an error:
erpnext.manufacturing.doctype.job_card.job_card.OperationSequenceError: Job Card PO-JOB00002: As per the sequence of the operations in the work order MFG-WO-2025-00001, complete the operation Gather Pie Filling Ingredients before the operation Cook Pie Filling Operation.This error occurs because Work Order has a new function,
validate_operations_sequence:https://github.com/frappe/erpnext/blob/3825490f0dbbd5530b739e928d012f639b6efafe/erpnext/manufacturing/doctype/work_order/work_order.py#L173
This function assigns
sequence_idto all operations that don't have one assigned, and then we have this function:https://github.com/frappe/erpnext/blob/ad45063c76880a443c772a0ea3aa7ab6ca33da3c/erpnext/manufacturing/doctype/job_card/job_card.py#L1032
That function was created one year ago, but it wasn't a problem because it has this condition:
Since we didn't assign
sequence_idto our operations, this validation wasn't a problem.But this function has a condition before:
That is the reason for my change.