[FIX] stock_landed_costs: prevent crash
Prevent crash if `stock_valuation_layer_ids` is an empty recordset. Note that the original issue is solved with #43017, but requires an upgrade of the module. opw-2172049 closes odoo/odoo#43289 X-original-commit: 8a1ce12aee326b59f33f48804a4cfca61dab7506 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -122,7 +122,7 @@ class LandedCost(models.Model):
|
||||
}
|
||||
for line in cost.valuation_adjustment_lines.filtered(lambda line: line.move_id):
|
||||
remaining_qty = sum(line.move_id.stock_valuation_layer_ids.mapped('remaining_qty'))
|
||||
linked_layer = line.move_id.stock_valuation_layer_ids[0]
|
||||
linked_layer = line.move_id.stock_valuation_layer_ids[:1]
|
||||
|
||||
# Prorate the value at what's still in stock
|
||||
cost_to_add = (remaining_qty / line.move_id.product_qty) * line.additional_landed_cost
|
||||
|
||||
Reference in New Issue
Block a user