diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2020-01-14 12:18:37 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2020-01-14 14:41:57 +0000 |
| commit | 1227e407767da810aa75a4b64ef2a335c575c00a (patch) | |
| tree | 7b8c353168cc80a7b1edaddb91304106e557f4f3 /addons | |
| parent | 2de4417ccd6db13eb2c44419543badf4dfddf2c0 (diff) | |
[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>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/stock_landed_costs/models/stock_landed_cost.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/stock_landed_costs/models/stock_landed_cost.py b/addons/stock_landed_costs/models/stock_landed_cost.py index f65bed8b803..21b23e27aca 100644 --- a/addons/stock_landed_costs/models/stock_landed_cost.py +++ b/addons/stock_landed_costs/models/stock_landed_cost.py @@ -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 |
