Skip to content

Commit

Permalink
fixup! shopfloor_delivery_shipment: Group package by sales
Browse files Browse the repository at this point in the history
  • Loading branch information
TDu committed Feb 5, 2024
1 parent 5eec14f commit ef6ba06
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
14 changes: 7 additions & 7 deletions shopfloor_delivery_shipment/services/delivery_shipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def _data_for_content_to_load_from_pickings(self, shipment_advice):
pickings_partially_loaded = loaded_lines.picking_id
domain += [("picking_id", "in", pickings_partially_loaded.ids)]
move_lines = self.env["stock.move.line"].search(domain)
return self._prepare_data_for_content(move_lines, False)
return self._prepare_data_for_content(move_lines, group_by_sale=False)

def _data_for_content_to_load_from_picking(
self, shipment_advice, picking=None, location=None
Expand All @@ -598,10 +598,10 @@ def _data_for_content_to_load_from_picking(
)
elif location:
move_lines = self._find_move_lines_from_location(shipment_advice, location)
group_by_sales = bool(location)
return self._prepare_data_for_content(move_lines, group_by_sales)
group_by_sale = bool(location)
return self._prepare_data_for_content(move_lines, group_by_sale=group_by_sale)

def _prepare_data_for_content(self, move_lines, group_by_sales):
def _prepare_data_for_content(self, move_lines, group_by_sale=False):
"""Returns data for package levels and/or move lines.
The data is grouped by source location with a key for package levels and
Expand All @@ -625,13 +625,13 @@ def _prepare_data_for_content(self, move_lines, group_by_sales):
},
}
"""
empty_group_name = " "
empty_group_name = "null"
data = collections.OrderedDict()
package_level_ids = []

# Sort and group move lines by source location and prepare the data
sales_started = []
if group_by_sales:
if group_by_sale:
sales_started = move_lines.shipment_advice_id.loaded_picking_ids.sale_id
# Grouping by sales (the packages) sort starting from last position
# 2 the lines NOT in a sales order whose loading has started.
Expand All @@ -653,7 +653,7 @@ def _prepare_data_for_content(self, move_lines, group_by_sales):
)
if move_line.package_level_id.id in package_level_ids:
continue
if group_by_sales:
if group_by_sale:
group_name = (
move_line.move_id.sale_line_id.order_id.name or empty_group_name
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ def assert_response_scan_document(
shipment_advice, picking
)
if lines_to_load:
group_by_sales = bool(location)
group_by_sale = bool(location)
data["content"] = self.service._prepare_data_for_content(
lines_to_load, group_by_sales
lines_to_load, group_by_sale=group_by_sale
)
self.assert_response(
response,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_scan_document_shipment_not_planned_lot_not_planned(self):
)
# 'package_levels' key contains the package available from the same delivery
self.assertEqual(
content[location_src]["package_levels"][" "],
content[location_src]["package_levels"]["null"],
self.service.data.package_levels(self.picking1.package_level_ids),
)

Expand Down Expand Up @@ -187,7 +187,7 @@ def test_scan_document_lot_already_loaded(self):
)
# 'package_levels' key contains the package available from the same delivery
self.assertEqual(
content[location_src]["package_levels"][" "],
content[location_src]["package_levels"]["null"],
self.service.data.package_levels(self.picking1.package_level_ids),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_scan_document_shipment_not_planned_package_not_planned(self):
# 'package_levels' key contains the package which has been loaded
# grouped in a dict
self.assertEqual(
content[location_src]["package_levels"][" "],
content[location_src]["package_levels"]["null"],
self.service.data.package_levels(package_level),
)

Expand Down Expand Up @@ -144,7 +144,7 @@ def test_scan_document_package_already_loaded(self):
# 'package_levels' key contains the package which has been loaded
# grouped in a dic
self.assertEqual(
content[location_src]["package_levels"][" "],
content[location_src]["package_levels"]["null"],
self.service.data.package_levels(package_level),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_scan_document_shipment_planned_picking_planned(self):
)
# 'package_levels' key contains the packages
self.assertEqual(
content[location_src]["package_levels"][" "],
content[location_src]["package_levels"]["null"],
self.service.data.package_levels(self.picking1.package_level_ids),
)

Expand Down Expand Up @@ -199,7 +199,7 @@ def test_scan_document_shipment_not_planned_picking_partially_planned(self):
self.assertNotIn("move_lines", content[location_src])
# 'package_levels' key contains the not planned packages
self.assertEqual(
content[location_src]["package_levels"][" "],
content[location_src]["package_levels"]["null"],
self.service.data.package_levels(self.picking1.package_level_ids),
)

Expand Down Expand Up @@ -261,6 +261,6 @@ def test_scan_document_shipment_not_planned_picking_partially_loaded(self):
self.assertNotIn("move_lines", content[location_src])
# 'package_levels' key contains the already loaded package levels
self.assertEqual(
content[location_src]["package_levels"][" "],
content[location_src]["package_levels"]["null"],
self.service.data.package_levels(self.picking1.package_level_ids),
)
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_scan_document_shipment_not_planned_product_not_planned(self):
# 'package_levels' key contains the package available from the same delivery
# grouped in a dict
self.assertEqual(
content[location_src]["package_levels"][" "],
content[location_src]["package_levels"]["null"],
self.service.data.package_levels(self.picking1.package_level_ids),
)

Expand Down Expand Up @@ -185,7 +185,7 @@ def test_scan_document_product_already_loaded(self):
)
# 'package_levels' key contains the package available from the same delivery
self.assertEqual(
content[location_src]["package_levels"][" "],
content[location_src]["package_levels"]["null"],
self.service.data.package_levels(self.picking1.package_level_ids),
)

Expand Down

0 comments on commit ef6ba06

Please sign in to comment.