[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) <flg@odoo.com>
This commit is contained in:
Florent de Labarre
2024-04-22 13:39:47 +00:00
committed by Florian(flg)
parent 13708008ed
commit 9f3877d733
+4 -3
View File
@@ -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)