From 73d950b7c14e41b19fc744672bca5d1ca0eb57a5 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 4 Apr 2016 23:10:05 +0200 Subject: [PATCH] [IMP] use mapped function thanks @pedrobaeza; [FIX] total_amount computation; (take into account balance_start); --- pos_session_summary/models/pos_session.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pos_session_summary/models/pos_session.py b/pos_session_summary/models/pos_session.py index 7064612b..53e79ea1 100644 --- a/pos_session_summary/models/pos_session.py +++ b/pos_session_summary/models/pos_session.py @@ -13,10 +13,9 @@ class PosSession(models.Model): @api.depends('statement_ids.balance_end') def _compute_total_amount(self): for session in self: - total_amount = 0 - for statement in session.statement_ids: - total_amount += statement.balance_end - session.total_amount = total_amount + session.total_amount =\ + sum(session.mapped('statement_ids.balance_end')) -\ + sum(session.mapped('statement_ids.balance_start')) @api.multi @api.depends('order_ids')