From 0e91af415ece2f87b95a81a3f7bfdaae5113a840 Mon Sep 17 00:00:00 2001
From: Thibault Libioulle <thibault.libioulle@aerospacelab.be>
Date: Tue, 6 Feb 2024 10:46:15 +0100
Subject: [PATCH] [FIX] stock_account: fix sum list of dict

This commit fixes summing list of dicts returned by
_prepare_analytic_lines.

closes odoo/odoo#152819

Nb: This code is not yet covered by a test use case.
Signed-off-by: Cedric Snauwaert <csn@odoo.com>
---
 addons/stock_account/models/stock_move.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/addons/stock_account/models/stock_move.py b/addons/stock_account/models/stock_move.py
index 5a5b0e6a4cf7..22d20abbea2c 100644
--- a/addons/stock_account/models/stock_move.py
+++ b/addons/stock_account/models/stock_move.py
@@ -427,8 +427,8 @@ class StockMove(models.Model):
             account_valuation = accounts_data.get('stock_valuation', False)
             analytic_line_vals = self.stock_valuation_layer_ids.account_move_id.line_ids.filtered(
                 lambda l: l.account_id == account_valuation)._prepare_analytic_lines()
-            amount = - sum(sum(vals['amount'] for vals in lists) for lists in analytic_line_vals)
-            unit_amount = - sum(sum(vals['unit_amount'] for vals in lists) for lists in analytic_line_vals)
+            amount = - sum(vals['amount'] for vals in analytic_line_vals)
+            unit_amount = - sum(vals['unit_amount'] for vals in analytic_line_vals)
         elif sum(self.stock_valuation_layer_ids.mapped('quantity')):
             amount = sum(self.stock_valuation_layer_ids.mapped('value'))
             unit_amount = - sum(self.stock_valuation_layer_ids.mapped('quantity'))
-- 
GitLab