From 39d103595228e20ca4cc38013a72070a715c7dd9 Mon Sep 17 00:00:00 2001 From: "Adrien Guilliams (adgu)" Date: Mon, 12 Jun 2023 10:12:37 +0000 Subject: [PATCH] [FIX] point_of_sale: _compute_cash_balance falsy The computation of the cash_balance of the sessions was falsy due to a change retrieving a part of the domain related to the payment lines of the session. The change of the domain led to retrieving all payments done during the entire lifetime of the config instead of only the ones done during the session and leading to miscomputation of the cash balance. closes odoo/odoo#124817 X-original-commit: d6d9e5ade690fb807b6c3644622e38b34b14de2c Signed-off-by: Heinz Robin (rhe) Signed-off-by: Guilliams Adrien (adgu) --- addons/point_of_sale/models/pos_session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 3c077f267ea..cc7885fd757 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -111,7 +111,7 @@ class PosSession(models.Model): if cash_payment_method: total_cash_payment = 0.0 last_session = session.search([('config_id', '=', session.config_id.id), ('id', '!=', session.id)], limit=1) - result = self.env['pos.payment']._read_group([('payment_method_id', '=', cash_payment_method.id)], aggregates=['amount:sum']) + result = self.env['pos.payment']._read_group([('session_id', '=', session.id), ('payment_method_id', '=', cash_payment_method.id)], aggregates=['amount:sum']) total_cash_payment = result[0][0] or 0.0 session.cash_register_total_entry_encoding = sum(session.statement_line_ids.mapped('amount')) + ( 0.0 if session.state == 'closed' else total_cash_payment