From 90e9c66ad21119b1cb7d5e1f7bea23d8df9bfb5c Mon Sep 17 00:00:00 2001
From: benjamin <benjamin@le-filament.com>
Date: Tue, 22 Feb 2022 15:08:24 +0100
Subject: [PATCH] [fix] export CG empty values

---
 controllers/main.py             |  8 +++++---
 wizard/export_journal_wizard.py | 17 ++++++++++++-----
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/controllers/main.py b/controllers/main.py
index 76917c4..6b85533 100644
--- a/controllers/main.py
+++ b/controllers/main.py
@@ -19,8 +19,10 @@ class ExportJournalCg(http.Controller):
     @http.route('/web/export_journal_cg/', type='http', auth="user")
     @serialize_exception
     def export_journal_cg(
-            self, date_start, date_end, date_creation_start, date_creation_end,
-            company_id, partner_ids, **kwargs):
+            self, company_id,
+            date_start=False, date_end=False,
+            date_creation_start=False, date_creation_end=False,
+            partner_ids=False, **kwargs):
         """
         Sélectionne les account.move.line correspondants aux journaux
         et à la plage de date définis
@@ -48,7 +50,7 @@ class ExportJournalCg(http.Controller):
                 ('date', '>=', date_start),
                 ('date', '<=', date_end),
             ]
-        if date_start and date_end:
+        if date_creation_start and date_creation_end:
             domain += [
                 ('create_date', '>=', date_creation_start),
                 ('create_date', '<=', date_creation_end),
diff --git a/wizard/export_journal_wizard.py b/wizard/export_journal_wizard.py
index a3e4b0b..4b421dd 100755
--- a/wizard/export_journal_wizard.py
+++ b/wizard/export_journal_wizard.py
@@ -48,13 +48,20 @@ class ExportJournalWizard(models.TransientModel):
         """
         datas = {
             'export_type': self.export_type,
-            'date_start': self.date_start,
-            'date_end': self.date_end,
-            'date_creation_start': self.date_creation_start,
-            'date_creation_end': self.date_creation_end,
             'company_id': self.company_id.id,
-            'partner_ids': ','.join(str(x) for x in self.partner_ids.ids),
         }
+        if self.date_start and self.date_end:
+            datas.update({
+                'date_start': self.date_start,
+                'date_end': self.date_end,
+            })
+        if self.date_creation_start and self.date_creation_end:
+            datas.update({
+                'date_creation_start': self.date_start,
+                'date_creation_end': self.date_end,
+            })
+        if self.partner_ids:
+            datas['partner_ids'] = ','.join(str(x) for x in self.partner_ids.ids)
         return {
             'type': 'ir.actions.act_url',
             'url': '/web/export_journal_cg?' + urlencode(datas),
-- 
GitLab