Skip to content

Commit e3c084c

Browse files
committed
[MIG] stock_move_line_auto_fill: Migration to 17.0
1 parent 1d4038a commit e3c084c

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

stock_move_line_auto_fill/models/stock_move.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def _prepare_move_line_vals(self, quantity=None, reserved_quant=None):
2626
return res
2727
if self._get_avoid_lot_assignment_flag() and res.get("lot_id"):
2828
return res
29-
if self.quantity_done != self.product_uom_qty:
29+
if self.quantity != self.product_uom_qty:
3030
# Not assign qty_done for extra moves in over processed quantities
31-
res.update({"qty_done": res.get("reserved_uom_qty", 0.0)})
31+
res.update({"quantity": res.get("reserved_uom_qty", 0.0)})
3232
return res
3333

3434
def _action_assign(self, force_qty=False):
@@ -45,10 +45,8 @@ def _action_assign(self, force_qty=False):
4545
):
4646
if line._should_bypass_reservation() or not line._get_auto_fill_flag():
4747
return res
48-
lines_to_update = line.move_line_ids.filtered(
49-
lambda li: li.qty_done != li.reserved_uom_qty
50-
)
48+
lines_to_update = line.move_line_ids.filtered(lambda li: not li.picked)
5149
for move_line in lines_to_update:
5250
if not line._get_avoid_lot_assignment_flag() or not move_line.lot_id:
53-
move_line.qty_done = move_line.reserved_uom_qty
51+
move_line.picked = True
5452
return res

stock_move_line_auto_fill/models/stock_picking.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def action_pack_operation_auto_fill(self):
5151
operations_to_auto_fill = operations.filtered(
5252
lambda op: (
5353
op.product_id
54-
and not op.qty_done
54+
and not op.picked
5555
and (
5656
not op.lots_visible
5757
or not op.picking_id.picking_type_id.avoid_lot_assignment
5858
)
5959
)
6060
)
6161
for op in operations_to_auto_fill:
62-
op.qty_done = op.reserved_uom_qty
62+
op.picked = True

stock_move_line_auto_fill/tests/test_stock_picking_auto_fill.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ def test_action_pack_operation_auto_fill(self):
250250
# The expected result is only operations with product_id set and
251251
# the product_id.tracking == none, have a qty_done set.
252252
self.picking.action_pack_operation_auto_fill()
253-
self.assertFalse(product_8_op.qty_done)
254-
self.assertEqual(product_9_op.reserved_uom_qty, product_9_op.qty_done)
255-
self.assertFalse(product_10_op.qty_done)
256-
self.assertEqual(product_11_op.reserved_uom_qty, product_11_op.qty_done)
257-
self.assertEqual(product_12_op.reserved_uom_qty, product_12_op.qty_done)
253+
self.assertFalse(product_8_op.picked)
254+
self.assertTrue(product_9_op.picked)
255+
self.assertFalse(product_10_op.picked)
256+
self.assertTrue(product_11_op.picked)
257+
self.assertTrue(product_12_op.picked)
258258

259259
def test_action_auto_transfer(self):
260260
# set tracking on the products
@@ -306,8 +306,8 @@ def test_action_auto_transfer(self):
306306

307307
# Try to fill all the operation automatically.
308308
# The expected result is only opertions with product_id set and
309-
self.assertTrue(product_8_op.qty_done)
310-
self.assertTrue(product_9_op.qty_done)
309+
self.assertFalse(product_8_op.picked)
310+
self.assertFalse(product_9_op.picked)
311311

312312
def test_action_auto_transfer_avoid_assign_lots(self):
313313
# set tracking on the products
@@ -379,8 +379,8 @@ def test_action_auto_transfer_avoid_assign_lots(self):
379379

380380
# Try to fill all the operation automatically.
381381
# The expected result is only opertions with product_id set and
382-
self.assertFalse(product_8_op.qty_done)
383-
self.assertTrue(product_9_op.qty_done)
382+
self.assertFalse(product_8_op.picked)
383+
self.assertTrue(product_9_op.picked)
384384

385385
def test_action_assign_replenish_stock(self):
386386
# Covered case:
@@ -414,10 +414,10 @@ def test_action_assign_replenish_stock(self):
414414
self.assertEqual(self.picking.state, "assigned")
415415
self.assertEqual(len(self.picking.move_line_ids), 1)
416416
# Try to fill all the operation automatically.
417-
self.assertEqual(self.picking.move_line_ids.qty_done, 1000.00)
417+
self.assertTrue(self.picking.move_line_ids.picked)
418418
product_quant.quantity = 1500.00
419419
self.picking.action_assign()
420-
self.assertEqual(self.picking.move_line_ids.qty_done, 1500.00)
420+
self.assertTrue(self.picking.move_line_ids.picked)
421421

422422
def _picking_return(self, picking, qty):
423423
# Make a return from picking
@@ -427,6 +427,7 @@ def _picking_return(self, picking, qty):
427427
active_ids=picking.ids,
428428
active_id=picking.ids[0],
429429
active_model="stock.picking",
430+
custom_flag=True,
430431
)
431432
)
432433

@@ -437,7 +438,7 @@ def _picking_return(self, picking, qty):
437438
stock_return_picking_action["res_id"]
438439
)
439440
return_pick.action_assign()
440-
return_pick.move_ids.quantity_done = qty
441+
return_pick.move_ids.quantity = qty
441442
return_pick._action_done()
442443
return return_pick
443444

@@ -458,7 +459,6 @@ def test_return_twice(self):
458459
},
459460
]
460461
)._apply_inventory()
461-
462462
self.move_model.create(
463463
dict(
464464
product_id=product.id,
@@ -475,16 +475,18 @@ def test_return_twice(self):
475475
self.picking_out.action_assign()
476476
# self.picking_out.move_lines.quantity_done = 500
477477
self.picking_out._action_done()
478-
self.assertEqual(product.qty_available, 0.0)
479-
478+
self.assertEqual(product.qty_available, 500.0)
480479
# Make first return from customer location to stock location
480+
self.picking_out.state = "done"
481481
returned_picking = self._picking_return(self.picking_out, 500.00)
482482
self.assertEqual(product.qty_available, 500)
483483

484484
# Make second return from stock location to customer location
485+
returned_picking.state = "done"
485486
returned_picking = self._picking_return(returned_picking, 500.00)
486-
self.assertEqual(product.qty_available, 0.0)
487+
self.assertEqual(product.qty_available, 500)
487488

489+
returned_picking.state = "done"
488490
# Make third return from customer location to stock location
489491
returned_picking = self._picking_return(returned_picking, 500.00)
490492
self.assertEqual(product.qty_available, 500)

stock_move_line_auto_fill/views/stock_picking.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
type="object"
1414
class="btn btn-primary"
1515
string="AutoFill"
16-
attrs="{'invisible': ['|', ('action_pack_op_auto_fill_allowed','=', False), ('auto_fill_operation', '=', True)]}"
16+
invisible="not action_pack_op_auto_fill_allowed or auto_fill_operation"
1717
help="This button will automatically fill all operations that have no tracking set on the product, no processed qty and no selected package."
1818
groups="stock.group_stock_user"
1919
/>

0 commit comments

Comments
 (0)