Skip to content

Commit

Permalink
shopfloor: fix progress computation
Browse files Browse the repository at this point in the history
Don't take into account if there is packages or not.
Leads to wrong computation if not all lines have a package.
  • Loading branch information
TDu committed Nov 9, 2023
1 parent 724aca6 commit df915d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions shopfloor/actions/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,11 @@ def _get_operation_progress(self, domain):
lines = self.env["stock.move.line"].search(domain)
# operations_to_do = number of total operations that are pending for this location.
# operations_done = number of operations already done.
# A line with an assigned package counts as 1 operation.
operations_to_do = 0
operations_done = 0
for line in lines:
is_done = line.qty_done == line.product_uom_qty
package_qty_done = 1 if is_done else 0
operations_done += (
line.qty_done if not line.package_id else package_qty_done
)
operations_to_do += line.product_uom_qty if not line.package_id else 1
operations_done += line.qty_done
operations_to_do += line.product_uom_qty - line.qty_done
return {
"done": operations_done,
"to_do": operations_to_do,
Expand Down
2 changes: 1 addition & 1 deletion shopfloor/tests/test_actions_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_data_location_with_operation_progress(self):
"barcode": location.name,
"operation_progress": {
"done": 16.0,
"to_do": 165.0,
"to_do": 167.0,
},
}
self.assertDictEqual(data, expected)
Expand Down

0 comments on commit df915d3

Please sign in to comment.