From 178558bd1464f416ab9ce340f552829b9c061477 Mon Sep 17 00:00:00 2001 From: JuMiSanAr Date: Wed, 22 Nov 2023 08:37:51 +0100 Subject: [PATCH] shopfloor: display pickings by priority in checkout --- shopfloor/actions/data.py | 3 ++- shopfloor/actions/schema.py | 1 + shopfloor/services/checkout.py | 2 +- shopfloor/tests/test_actions_data.py | 2 ++ shopfloor_mobile/static/wms/src/scenario/checkout.js | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/shopfloor/actions/data.py b/shopfloor/actions/data.py index 1454636b03..f8cf6d5000 100644 --- a/shopfloor/actions/data.py +++ b/shopfloor/actions/data.py @@ -34,7 +34,7 @@ def picking(self, record, **kw): # and it may reduce performance significatively # when dealing with a large number of pickings. # Thus, we make it optional. - if "with_progress" in kw: + if kw.get("with_progress"): parser.append("progress") return self._jsonify(record, parser, **kw) @@ -56,6 +56,7 @@ def _picking_parser(self, **kw): "bulk_line_count", "total_weight:weight", "scheduled_date", + "priority", ] @ensure_model("stock.quant.package") diff --git a/shopfloor/actions/schema.py b/shopfloor/actions/schema.py index bdfab9801b..77c179c126 100644 --- a/shopfloor/actions/schema.py +++ b/shopfloor/actions/schema.py @@ -26,6 +26,7 @@ def picking(self): "ship_carrier": self._schema_dict_of(self._simple_record(), required=False), "scheduled_date": {"type": "string", "nullable": False, "required": True}, "progress": {"type": "float", "nullable": True}, + "priority": {"type": "string", "nullable": True, "required": False}, } def move_line(self, with_packaging=False, with_picking=False): diff --git a/shopfloor/services/checkout.py b/shopfloor/services/checkout.py index 80fd861b29..c0cd600091 100644 --- a/shopfloor/services/checkout.py +++ b/shopfloor/services/checkout.py @@ -345,7 +345,7 @@ def _domain_for_list_stock_picking(self): ] def _order_for_list_stock_picking(self): - return "scheduled_date asc, id asc" + return "priority desc, scheduled_date asc, id asc" def list_stock_picking(self): """List stock.picking records available diff --git a/shopfloor/tests/test_actions_data.py b/shopfloor/tests/test_actions_data.py index 19262531f6..35819bdbdc 100644 --- a/shopfloor/tests/test_actions_data.py +++ b/shopfloor/tests/test_actions_data.py @@ -115,6 +115,7 @@ def test_data_picking(self): "partner": {"id": self.customer.id, "name": self.customer.name}, "carrier": {"id": carrier.id, "name": carrier.name}, "ship_carrier": None, + "priority": "0", } self.assertEqual(data.pop("scheduled_date").split("T")[0], "2020-08-03") self.assertDictEqual(data, expected) @@ -139,6 +140,7 @@ def test_data_picking_with_progress(self): "carrier": {"id": carrier.id, "name": carrier.name}, "ship_carrier": None, "progress": 0.0, + "priority": "0", } self.assertEqual(data.pop("scheduled_date").split("T")[0], "2020-08-03") self.assertDictEqual(data, expected) diff --git a/shopfloor_mobile/static/wms/src/scenario/checkout.js b/shopfloor_mobile/static/wms/src/scenario/checkout.js index f263ce642f..bd460fb9e6 100644 --- a/shopfloor_mobile/static/wms/src/scenario/checkout.js +++ b/shopfloor_mobile/static/wms/src/scenario/checkout.js @@ -277,6 +277,7 @@ const Checkout = { {path: "origin"}, {path: "carrier.name", label: "Carrier"}, {path: "move_line_count", label: "Lines"}, + {path: "priority", label: "Priority"}, ], }, };