Skip to content

Commit 464dc81

Browse files
[IMP] shopfloor_reception: clear lot when canceling in "set_quantity"
1 parent ad6100c commit 464dc81

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from . import data
22
from . import schema
33
from . import message
4+
from . import stock
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from odoo.addons.component.core import Component
2+
3+
4+
class StockAction(Component):
5+
"""Provide methods to work with stock operations."""
6+
7+
_inherit = "shopfloor.stock.action"
8+
9+
def unmark_move_line_as_picked(self, move_lines):
10+
res = super().unmark_move_line_as_picked(move_lines)
11+
move_lines.write({"lot_id": False})
12+
return res

shopfloor_reception/tests/test_set_quantity_action.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,31 @@ def test_cancel_action(self):
169169
)
170170
# This line has been created by shopfloor, therefore, we unlinked it
171171
self.assertFalse(move_line_user_2.exists())
172+
173+
def test_cancel_action_clears_lot(self):
174+
product = self.selected_move_line.product_id
175+
product.sudo().tracking = "lot"
176+
self.picking.sudo().picking_type_id.use_create_lots = True
177+
178+
response = self.service.dispatch(
179+
"set_lot_confirm_action",
180+
params={
181+
"picking_id": self.picking.id,
182+
"selected_line_id": self.selected_move_line.id,
183+
"lot_name": "FooBar",
184+
"expiration_date": "2022-08-24T12:00:00",
185+
},
186+
)
187+
self.assertEqual(response.get("next_state"), "set_quantity")
188+
self.assertEqual(self.selected_move_line.lot_id.name, "FooBar")
189+
190+
response = self.service.dispatch(
191+
"set_quantity__cancel_action",
192+
params={
193+
"picking_id": self.picking.id,
194+
"selected_line_id": self.selected_move_line.id,
195+
},
196+
)
197+
self.assertFalse(
198+
self.selected_move_line.lot_id, "Cancel action should clear the lot"
199+
)

0 commit comments

Comments
 (0)