diff --git a/shopfloor_reception/actions/message.py b/shopfloor_reception/actions/message.py index 0d17382616..d0db6b64ea 100644 --- a/shopfloor_reception/actions/message.py +++ b/shopfloor_reception/actions/message.py @@ -12,22 +12,16 @@ class MessageAction(Component): _inherit = "shopfloor.message.action" - def lot_already_exists_different_expiration_date(self, lot, expiration_date): + def lot_already_exists_different_expiration_date(self, lot): formatted_lot_expiration_date = self.work.env[ "ir.qweb.field.date" ].value_to_html(lot.expiration_date, {}) - formatted_provided_expiration_date = self.work.env[ - "ir.qweb.field.date" - ].value_to_html(expiration_date, {}) return { - "message_type": "warning", + "message_type": "error", "body": _( - "This lot already exists with a different expiration date.\n\n" - "Lot: '%(lot_name)s'\nStored expiration date: %(current)s" - "\nProvided expiration date: %(provided)s", - lot_name=lot.name, - current=formatted_lot_expiration_date, - provided=formatted_provided_expiration_date, + "This lot already exists with expiration date " + "'%(lot_expiration_date)s'. You cannot change its date.", + lot_expiration_date=formatted_lot_expiration_date, ), } diff --git a/shopfloor_reception/services/reception.py b/shopfloor_reception/services/reception.py index 85dbc19c3d..1792d9ffc4 100644 --- a/shopfloor_reception/services/reception.py +++ b/shopfloor_reception/services/reception.py @@ -1237,7 +1237,7 @@ def scan_lot(self, picking_id, selected_line_id, barcode): and existing_lot.expiration_date != lot_expiration_date ): message = self.msg_store.lot_already_exists_different_expiration_date( - existing_lot, lot_expiration_date + existing_lot ) res = self._response_for_set_lot( @@ -1342,7 +1342,7 @@ def _set_lot_confirm_action__handle_existing_lot( picking, line, message=self.msg_store.lot_already_exists_different_expiration_date( - lot, expiration_date + lot ), lot_name=lot.name, lot_expiration_date=expiration_date, diff --git a/shopfloor_reception/tests/test_scan_lot.py b/shopfloor_reception/tests/test_scan_lot.py index e52a35183e..743637d3f5 100644 --- a/shopfloor_reception/tests/test_scan_lot.py +++ b/shopfloor_reception/tests/test_scan_lot.py @@ -126,9 +126,7 @@ def test_scan_lot_extract_expiration_date_existing_lot(self): ) self.assertEqual( res["message"], - self.msg_store.lot_already_exists_different_expiration_date( - lot, lot.expiration_date + timedelta(days=2) - ), + self.msg_store.lot_already_exists_different_expiration_date(lot), ) def test_scan_lot_name_auto_set_lot_on_move_line(self): diff --git a/shopfloor_reception/tests/test_set_lot_confirm.py b/shopfloor_reception/tests/test_set_lot_confirm.py index 5a2230eea1..6250405b16 100644 --- a/shopfloor_reception/tests/test_set_lot_confirm.py +++ b/shopfloor_reception/tests/test_set_lot_confirm.py @@ -164,9 +164,7 @@ def test_set_existing_lot_try_overwrite_expiration_date_error(self): "picking": self.data.picking(picking), "selected_move_line": move_line_response_data, }, - message=self.msg_store.lot_already_exists_different_expiration_date( - lot, new_expiration_date - ), + message=self.msg_store.lot_already_exists_different_expiration_date(lot), ) @freeze_time("2020-01-01 11:00:00")