From a3563da39ac575e91f321c4dc6fafb381e4bc9de Mon Sep 17 00:00:00 2001 From: "Guillaume (guva)" <guva@odoo.com> Date: Tue, 17 May 2022 05:17:55 +0000 Subject: [PATCH] [FIX] account: cumulated balance non exportable in GL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We made the field cumulated balance non exportable in the GL. Steps: - Go to Accounting->Accounting->General Ledger - Unfold and select one or several lines - export lines -> The cumulated balance is not computed The reason is we don't pass in the compute as we don't come from the search_read method when exporting, so we don't have a domain to compute the cumulated balance. As we can't force the domain, we override the fields_get method to make the field non exportable. opw-2800669 closes odoo/odoo#91527 Signed-off-by: William André (wan) <wan@odoo.com> --- addons/account/models/account_move.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index e7e1e1f51ad4..9fdf5e834eb6 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3874,6 +3874,13 @@ class AccountMoveLine(models.Model): # Add the domain and order by in order to compute the cumulated balance in _compute_cumulated_balance return super(AccountMoveLine, self.with_context(domain_cumulated_balance=to_tuple(domain or []), order_cumulated_balance=order)).search_read(domain, fields, offset, limit, order) + @api.model + def fields_get(self, allfields=None, attributes=None): + res = super().fields_get(allfields, attributes) + if res.get('cumulated_balance'): + res['cumulated_balance']['exportable'] = False + return res + @api.depends_context('order_cumulated_balance', 'domain_cumulated_balance') def _compute_cumulated_balance(self): if not self.env.context.get('order_cumulated_balance'): -- GitLab