[FIX] stock_account: valuation layer is zero when twice return dropshipping
To reproduce: 1. Create a Sales Order for a product whose product category is set to FIFO and automated. Use route "dropship". 2. Confirm the PO created. 3. Deliver the products (DS transfer) 5. Return, for example, 1 unit of product 6. Return the return This is a continuation of commit f9a1c1d7bb8234eb96c48dddae9930a419bfb696 If the origin of the move is a dropshipped_returned, then the error describe in the mentioned commit will still happen. opw-3283436 closes odoo/odoo#127403 X-original-commit: b7a91e3682aad7ecc1a4a8a42b2d6368573ba906 Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com> Signed-off-by: David Fesquet (dafr) <dafr@odoo.com>
This commit is contained in:
@@ -47,7 +47,7 @@ class StockMove(models.Model):
|
||||
layers = self.origin_returned_move_id.sudo().stock_valuation_layer_ids
|
||||
# dropshipping create additional positive svl to make sure there is no impact on the stock valuation
|
||||
# We need to remove them from the computation of the price unit.
|
||||
if self.origin_returned_move_id._is_dropshipped():
|
||||
if self.origin_returned_move_id._is_dropshipped() or self.origin_returned_move_id._is_dropshipped_returned():
|
||||
layers = layers.filtered(lambda l: float_compare(l.value, 0, precision_rounding=l.product_id.uom_id.rounding) <= 0)
|
||||
layers |= layers.stock_valuation_layer_ids
|
||||
quantity = sum(layers.mapped("quantity"))
|
||||
|
||||
@@ -323,3 +323,16 @@ class TestStockValuation(ValuationReconciliationTestCommon):
|
||||
|
||||
self.assertTrue(8 in return_pick.move_ids.stock_valuation_layer_ids.mapped('value'))
|
||||
self.assertTrue(-8 in return_pick.move_ids.stock_valuation_layer_ids.mapped('value'))
|
||||
|
||||
# return again to have a new dropship picking from a dropship return
|
||||
stock_return_picking_form_2 = Form(self.env['stock.return.picking']
|
||||
.with_context(active_ids=return_pick.ids, active_id=return_pick.ids[0],
|
||||
active_model='stock.picking'))
|
||||
stock_return_picking_2 = stock_return_picking_form_2.save()
|
||||
stock_return_picking_action_2 = stock_return_picking_2.create_returns()
|
||||
return_pick_2 = self.env['stock.picking'].browse(stock_return_picking_action_2['res_id'])
|
||||
return_pick_2.move_ids[0].move_line_ids[0].qty_done = 1.0
|
||||
return_pick_2._action_done()
|
||||
|
||||
self.assertTrue(8 in return_pick_2.move_ids.stock_valuation_layer_ids.mapped('value'))
|
||||
self.assertTrue(-8 in return_pick_2.move_ids.stock_valuation_layer_ids.mapped('value'))
|
||||
|
||||
Reference in New Issue
Block a user