From 9f3877d73331d4c9a7d713e2ea76d54f3729de8a Mon Sep 17 00:00:00 2001 From: Florent de Labarre Date: Tue, 20 Feb 2024 15:04:08 +0000 Subject: [PATCH] [FIX] l10_fr_fec : init line with zero balance should be not include The FEC report contains initial balances. These representing balances on accounts from the previous period. When calculating the initial balances, there is no requirement to include balances from the previous period for an account if they are at zero. When there are settled transactions for many thousands of partners from the previous period, this results in many thousands of initial balance lines in the FEC report that all have a balance of zero. This PR remove initial line with zero balance. closes odoo/odoo#160729 X-original-commit: 1d1beaf4aa02875f1843b99564562f9ed4446ae8 Signed-off-by: Florian Gilbert (flg) --- addons/l10n_fr_fec/wizard/account_fr_fec.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/l10n_fr_fec/wizard/account_fr_fec.py b/addons/l10n_fr_fec/wizard/account_fr_fec.py index 1feeba79a87..76612c9532d 100644 --- a/addons/l10n_fr_fec/wizard/account_fr_fec.py +++ b/addons/l10n_fr_fec/wizard/account_fr_fec.py @@ -198,17 +198,18 @@ class AccountFrFec(models.TransientModel): AND am.date < %(date_from)s AND aa.include_initial_balance = 't' GROUP BY aml.account_id, aa.account_type - HAVING aa.account_type not in ('asset_receivable', 'liability_payable') + HAVING aa.account_type not in ('asset_receivable', 'liability_payable') AND round(sum(aml.balance), %(currency_digits)s) != 0 ''' + currency_digits = 2 params = { **where_params, 'formatted_date_year': self.date_from.year, 'formatted_date_from': fields.Date.to_string(self.date_from).replace('-', ''), 'date_from': self.date_from, + 'currency_digits': currency_digits, } self._cr.execute(sql_query, params) - currency_digits = 2 for row in self._cr.fetchall(): listrow = list(row) account_id = listrow.pop() @@ -287,7 +288,7 @@ class AccountFrFec(models.TransientModel): AND am.date < %(date_from)s AND aa.include_initial_balance = 't' GROUP BY aml.account_id, aa.account_type, rp.ref, rp.id - HAVING aa.account_type in ('asset_receivable', 'liability_payable') + HAVING aa.account_type in ('asset_receivable', 'liability_payable') AND round(sum(aml.balance), %(currency_digits)s) != 0 ''' self._cr.execute(sql_query, params)