summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Monjoie <dmo@odoo.com>2016-07-27 19:33:01 +0200
committerDavid Monjoie <dmo@odoo.com>2016-07-27 19:41:50 +0200
commit2cfa7b562638264037cbd7fe892390d2bf5ea2d0 (patch)
tree90994e6bc15f64c2addaa63ec7e58a6d1f3ee0f2
parent6cc7c0321249817b061326f5fa2aba2774c79896 (diff)
[FIX] l10n_fr_fec: exclude initial balance at 0
This is the proper fix for 3180aec56a634ec8d44f87376c089b9427a51969 and is the continuation of f7e4241a91c36db157a4a6bfc8252b46a5185800. A sum without groupby will return NULL so we forced it back to 0,00. Then, it can happen that you have no move before the start date, so you don't have any opening "OUV" row. opw-682365
-rw-r--r--addons/l10n_fr_fec/wizard/fec.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/addons/l10n_fr_fec/wizard/fec.py b/addons/l10n_fr_fec/wizard/fec.py
index e46f12648ed..3acc2e7e644 100644
--- a/addons/l10n_fr_fec/wizard/fec.py
+++ b/addons/l10n_fr_fec/wizard/fec.py
@@ -41,8 +41,8 @@ class AccountFrFec(models.TransientModel):
'-' AS PieceRef,
%s AS PieceDate,
'/' AS EcritureLib,
- replace(CASE WHEN sum(aml.balance) <= 0 THEN '0,00' ELSE to_char(SUM(aml.balance), '999999999999999D99') END, '.', ',') AS Debit,
- replace(CASE WHEN sum(aml.balance) >= 0 THEN '0,00' ELSE to_char(-SUM(aml.balance), '999999999999999D99') END, '.', ',') AS Credit,
+ replace(CASE WHEN COALESCE(sum(aml.balance), 0) <= 0 THEN '0,00' ELSE to_char(SUM(aml.balance), '999999999999999D99') END, '.', ',') AS Debit,
+ replace(CASE WHEN COALESCE(sum(aml.balance), 0) >= 0 THEN '0,00' ELSE to_char(-SUM(aml.balance), '999999999999999D99') END, '.', ',') AS Credit,
'' AS EcritureLet,
'' AS DateLet,
%s AS ValidDate,
@@ -191,13 +191,13 @@ class AccountFrFec(models.TransientModel):
listrow[12] = str(listrow_amount)
w.writerow([s.encode("utf-8") for s in listrow])
#if the unaffected earnings account wasn't in the selection yet: add it manually
- if not unaffected_earnings_line and unaffected_earnings_results:
+ if not unaffected_earnings_line and unaffected_earnings_results and unaffected_earnings_results[11] != '0,00' and unaffected_earnings_results[12] != '0,00':
#search an unaffected earnings account
unaffected_earnings_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_unaffected_earnings').id)], limit=1)
if unaffected_earnings_account:
unaffected_earnings_results[4] = unaffected_earnings_account.code
unaffected_earnings_results[5] = unaffected_earnings_account.name
- w.writerow([(s if s else '').encode("utf-8") for s in unaffected_earnings_results])
+ w.writerow([s.encode("utf-8") for s in unaffected_earnings_results])
# LINES
sql_query = '''