[FIX] stock_picking_batch: new stock.move added to wave picking
Usecase to reproduce: - Create a batch picking from a new location to customer - Put some `stock.move.line` in a wave - Validate the remaining of the initial `stock.picking` - Create a new `stock.move` with the same data and without `picking_id` Current behavior The stock.move is added to the existing wave. However the stock.move.line created could not match the current wave specification Expected behavior A new picking is created and it could be merge in the wave picking if wanted closes odoo/odoo#84875 X-original-commit: 4ea418ed1cceff4aee916cf791011a1dc67c77a1 Signed-off-by: Arnold Moyaux <arm@odoo.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import stock_move
|
||||
from . import stock_move_line
|
||||
from . import stock_picking
|
||||
from . import stock_picking_batch
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
class StockMove(models.Model):
|
||||
_inherit = "stock.move"
|
||||
|
||||
def _search_picking_for_assignation_domain(self):
|
||||
domain = super()._search_picking_for_assignation_domain()
|
||||
domain = expression.AND([domain, ['|', ('batch_id', '=', False), ('batch_id.is_wave', '=', False)]])
|
||||
return domain
|
||||
@@ -342,3 +342,55 @@ class TestBatchPicking(TransactionCase):
|
||||
wizard_form.mode = 'new'
|
||||
wizard = wizard_form.save()
|
||||
wizard.attach_pickings()
|
||||
|
||||
def test_not_assign_to_wave(self):
|
||||
""" Picking
|
||||
- Move line A 5 from Container to Cust -> Going to a wave picking
|
||||
- Move line A 5 from Container to Cust -> Validate
|
||||
---------------------------------------------
|
||||
Create
|
||||
- Move A 5 from Container to Cust
|
||||
Check it creates a new picking and it's not assign to the wave
|
||||
"""
|
||||
location = self.env['stock.location'].create({
|
||||
'name': 'Container',
|
||||
'location_id': self.stock_location.id
|
||||
})
|
||||
self.env['stock.quant']._update_available_quantity(self.productA, location, 5.0, lot_id=self.lots_p_a[0])
|
||||
self.env['stock.quant']._update_available_quantity(self.productA, location, 5.0, lot_id=self.lots_p_a[1])
|
||||
picking_1 = self.env['stock.picking'].create({
|
||||
'location_id': location.id,
|
||||
'location_dest_id': self.customer_location.id,
|
||||
'picking_type_id': self.picking_type_out,
|
||||
'company_id': self.env.company.id,
|
||||
})
|
||||
self.env['stock.move'].create({
|
||||
'name': 'Test Wave',
|
||||
'product_id': self.productA.id,
|
||||
'product_uom_qty': 10,
|
||||
'product_uom': self.productA.uom_id.id,
|
||||
'picking_id': picking_1.id,
|
||||
'picking_type_id': self.picking_type_out,
|
||||
'location_id': location.id,
|
||||
'location_dest_id': self.customer_location.id,
|
||||
})
|
||||
picking_1.action_confirm()
|
||||
picking_1.action_assign()
|
||||
self.assertEqual(len(picking_1.move_line_ids), 2)
|
||||
move_line_to_wave = picking_1.move_line_ids[0]
|
||||
move_line_to_wave._add_to_wave()
|
||||
picking_1.move_line_ids.qty_done = 5
|
||||
picking_1._action_done()
|
||||
|
||||
new_move = self.env['stock.move'].create({
|
||||
'name': 'Test Wave',
|
||||
'product_id': self.productA.id,
|
||||
'product_uom_qty': 5,
|
||||
'product_uom': self.productA.uom_id.id,
|
||||
'picking_type_id': self.picking_type_out,
|
||||
'location_id': location.id,
|
||||
'location_dest_id': self.customer_location.id,
|
||||
})
|
||||
new_move._action_confirm()
|
||||
self.assertTrue(new_move.picking_id)
|
||||
self.assertTrue(new_move.picking_id.id not in [picking_1.id, move_line_to_wave.picking_id.id])
|
||||
|
||||
Reference in New Issue
Block a user