Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions shopfloor_reception/actions/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
}

Expand Down
4 changes: 2 additions & 2 deletions shopfloor_reception/services/reception.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions shopfloor_reception/tests/test_scan_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 1 addition & 3 deletions shopfloor_reception/tests/test_set_lot_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading