[WIZARD][PYTHON][VIEW] +ccmx export for eecidf
authorLudovic CHEVALIER <ludovic@beurresarrasin.net>
Fri, 30 Mar 2018 13:12:48 +0000 (15:12 +0200)
committerLudovic CHEVALIER <ludovic@beurresarrasin.net>
Fri, 30 Mar 2018 13:12:48 +0000 (15:12 +0200)
__openerp__.py
i18n/etudesetchantiersidf.pot
i18n/fr.po
wizard/__init__.py [new file with mode: 0644]
wizard/account_export_csv.py [new file with mode: 0644]
wizard/account_export_csv_view.xml [new file with mode: 0644]

index 89b16fc..fd8311e 100644 (file)
@@ -56,6 +56,7 @@ It installs the profile for bike co-ops to manage some features like:
         'data/bikecoop.xml',
         'view/bikecoop.xml',
         'view/point_of_sale.xml',
+        'wizard/account_export_csv_view.xml',
     ],
     'installable': True,
     'auto_install': False,
index 5b0ea92..c12bc9a 100644 (file)
@@ -6,8 +6,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: OpenERP Server 7.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-01-08 13:57+0000\n"
-"PO-Revision-Date: 2016-01-08 13:57+0000\n"
+"POT-Creation-Date: 2018-03-30 12:53+0000\n"
+"PO-Revision-Date: 2018-03-30 12:53+0000\n"
 "Last-Translator: <>\n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -25,11 +25,22 @@ msgstr ""
 msgid "Roue libre 7 vitesses shimano"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:125
+#, python-format
+msgid "The selected journal is not available for this export type."
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN023_product_template
 msgid "Cassette shimano 7 vitesses"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: model:product.template,name:etudesetchantiersidf.eecidf_product_product_LOC_product_template
+msgid "Location de vélo"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:bikecoop.partner.theme,name:etudesetchantiersidf.bikecoop_partner_theme_admin
 msgid "Administratif"
@@ -75,6 +86,11 @@ msgstr ""
 msgid "Panier à tringle"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: model:ir.model,name:etudesetchantiersidf.model_account_csv_export
+msgid "Export Accounting"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN065_product_template
 msgid "Manette dérailleur poussoirs sun race (paire)"
@@ -146,6 +162,12 @@ msgstr ""
 msgid "Embout arrêt gaine frein/der (x10)"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:81
+#, python-format
+msgid "JOURNAL"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN035_product_template
 msgid "Coude v-brake (unité)"
@@ -171,6 +193,12 @@ msgstr ""
 msgid "Autre"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:86
+#, python-format
+msgid "CREDIT"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_ADH05_product_template
 msgid "Cotisation annuelle date-à-date les champs bleus"
@@ -206,14 +234,20 @@ msgstr ""
 msgid "Guidoline toutes couleurs"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:101
+#, python-format
+msgid "You must select ONE period for this export."
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN050_product_template
 msgid "Fond de jante 24/28 pouces"
 msgstr ""
 
 #. module: etudesetchantiersidf
-#: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN054_product_template
-msgid "Jante double paroi 700 noir (622)"
+#: model:product.category,name:etudesetchantiersidf.eecidf_product_category_1
+msgid "Cotisation"
 msgstr ""
 
 #. module: etudesetchantiersidf
@@ -377,6 +411,12 @@ msgstr ""
 msgid "Casque polisport enfant"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:87
+#, python-format
+msgid "ANALYTIQUE"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN078_product_template
 msgid "Pneu 500x28 a import"
@@ -413,8 +453,9 @@ msgid "Roue simple paroi / rl arrière 700 (622)"
 msgstr ""
 
 #. module: etudesetchantiersidf
-#: model:product.category,name:etudesetchantiersidf.eecidf_product_category_1
-msgid "Cotisation"
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:85
+#, python-format
+msgid "DEBIT"
 msgstr ""
 
 #. module: etudesetchantiersidf
@@ -437,6 +478,12 @@ msgstr ""
 msgid "Etrier frein ville traditionnel"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:84
+#, python-format
+msgid "REFERENCE"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN056_product_template
 msgid "Jante simple paroi 650 a (590)"
@@ -543,8 +590,9 @@ msgid "Jante simple paroi 26p (559)"
 msgstr ""
 
 #. module: etudesetchantiersidf
-#: model:product.template,name:etudesetchantiersidf.eecidf_product_product_LOC_product_template
-msgid "Location de vélo"
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:82
+#, python-format
+msgid "COMPTE"
 msgstr ""
 
 #. module: etudesetchantiersidf
@@ -592,6 +640,12 @@ msgstr ""
 msgid "Paire de levier frein alu canti ou vbrake"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:106
+#, python-format
+msgid "You must select ONE journal for this export."
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN036_product_template
 msgid "Dérailleur avant ou arrière shimano standard"
@@ -612,6 +666,12 @@ msgstr ""
 msgid "Ruban tressoplast (paire)"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:80
+#, python-format
+msgid "DATE"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN003_product_template
 msgid "Antivol chaîne 120x8"
@@ -722,11 +782,33 @@ msgstr ""
 msgid "Roue double paroi avant 700 (622)"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:79
+#, python-format
+msgid "ID"
+msgstr ""
+
+#. module: etudesetchantiersidf
+#: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN054_product_template
+msgid "Jante double paroi 700 noir (622)"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_VO_product_template
 msgid "Vélo occasion "
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:83
+#, python-format
+msgid "LIBELLE"
+msgstr ""
+
+#. module: etudesetchantiersidf
+#: view:account.csv.export:0
+msgid "CCMX export"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.product_take_in_out_product_template
 msgid "Produit d'entrée et de sortie de caisse"
index d8f67c8..e3db23b 100644 (file)
@@ -2,15 +2,15 @@ msgid ""
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-01-08 14:58+0100\n"
-"PO-Revision-Date: 2016-01-08 14:58+0100\n"
+"POT-Creation-Date: 2018-03-30 12:53+0000\n"
+"PO-Revision-Date: 2018-03-30 14:59+0200\n"
 "Last-Translator: Ludovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>\n"
 "Language-Team: \n"
 "Language: fr\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 1.8.6\n"
+"X-Generator: Poedit 2.0.6\n"
 "X-Poedit-Basepath: .\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
@@ -24,11 +24,22 @@ msgstr ""
 msgid "Roue libre 7 vitesses shimano"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:125
+#, python-format
+msgid "The selected journal is not available for this export type."
+msgstr "Le journal sélectionné n'est pas disponible pour ce type d'export."
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN023_product_template
 msgid "Cassette shimano 7 vitesses"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: model:product.template,name:etudesetchantiersidf.eecidf_product_product_LOC_product_template
+msgid "Location de vélo"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:bikecoop.partner.theme,name:etudesetchantiersidf.bikecoop_partner_theme_admin
 msgid "Administratif"
@@ -74,6 +85,11 @@ msgstr ""
 msgid "Panier à tringle"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: model:ir.model,name:etudesetchantiersidf.model_account_csv_export
+msgid "Export Accounting"
+msgstr "Exporter la comptabilité"
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN065_product_template
 msgid "Manette dérailleur poussoirs sun race (paire)"
@@ -144,6 +160,12 @@ msgstr ""
 msgid "Embout arrêt gaine frein/der (x10)"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:81
+#, python-format
+msgid "JOURNAL"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN035_product_template
 msgid "Coude v-brake (unité)"
@@ -169,6 +191,12 @@ msgstr ""
 msgid "Autre"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:86
+#, python-format
+msgid "CREDIT"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_ADH05_product_template
 msgid "Cotisation annuelle date-à-date les champs bleus"
@@ -177,7 +205,7 @@ msgstr ""
 #. module: etudesetchantiersidf
 #: model:ir.model,name:etudesetchantiersidf.model_res_partner
 msgid "Partner"
-msgstr ""
+msgstr "Partenaire"
 
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN008_product_template
@@ -204,14 +232,20 @@ msgstr ""
 msgid "Guidoline toutes couleurs"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:101
+#, python-format
+msgid "You must select ONE period for this export."
+msgstr "Vous ne devez sélectionner qu'UNE période pour cet export."
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN050_product_template
 msgid "Fond de jante 24/28 pouces"
 msgstr ""
 
 #. module: etudesetchantiersidf
-#: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN054_product_template
-msgid "Jante double paroi 700 noir (622)"
+#: model:product.category,name:etudesetchantiersidf.eecidf_product_category_1
+msgid "Cotisation"
 msgstr ""
 
 #. module: etudesetchantiersidf
@@ -379,6 +413,12 @@ msgstr ""
 msgid "Casque polisport enfant"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:87
+#, python-format
+msgid "ANALYTIQUE"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN078_product_template
 msgid "Pneu 500x28 a import"
@@ -415,9 +455,10 @@ msgid "Roue simple paroi / rl arrière 700 (622)"
 msgstr ""
 
 #. module: etudesetchantiersidf
-#: model:product.category,name:etudesetchantiersidf.eecidf_product_category_1
-msgid "Cotisation"
-msgstr ""
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:85
+#, python-format
+msgid "DEBIT"
+msgstr "DEBIT"
 
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN110_product_template
@@ -439,6 +480,12 @@ msgstr ""
 msgid "Etrier frein ville traditionnel"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:84
+#, python-format
+msgid "REFERENCE"
+msgstr "REFERENCE"
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN056_product_template
 msgid "Jante simple paroi 650 a (590)"
@@ -545,9 +592,10 @@ msgid "Jante simple paroi 26p (559)"
 msgstr ""
 
 #. module: etudesetchantiersidf
-#: model:product.template,name:etudesetchantiersidf.eecidf_product_product_LOC_product_template
-msgid "Location de vélo"
-msgstr ""
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:82
+#, python-format
+msgid "COMPTE"
+msgstr "COMPTE"
 
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN033_product_template
@@ -594,6 +642,12 @@ msgstr ""
 msgid "Paire de levier frein alu canti ou vbrake"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:106
+#, python-format
+msgid "You must select ONE journal for this export."
+msgstr "Vous ne devez sélectionner qu'UN journal pour cet export."
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN036_product_template
 msgid "Dérailleur avant ou arrière shimano standard"
@@ -614,6 +668,12 @@ msgstr ""
 msgid "Ruban tressoplast (paire)"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:80
+#, python-format
+msgid "DATE"
+msgstr "DATE"
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN003_product_template
 msgid "Antivol chaîne 120x8"
@@ -724,11 +784,33 @@ msgstr ""
 msgid "Roue double paroi avant 700 (622)"
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:79
+#, python-format
+msgid "ID"
+msgstr "ID"
+
+#. module: etudesetchantiersidf
+#: model:product.template,name:etudesetchantiersidf.eecidf_product_product_PN054_product_template
+msgid "Jante double paroi 700 noir (622)"
+msgstr ""
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.eecidf_product_product_VO_product_template
 msgid "Vélo occasion "
 msgstr ""
 
+#. module: etudesetchantiersidf
+#: code:addons/etudesetchantiersidf/wizard/account_export_csv.py:83
+#, python-format
+msgid "LIBELLE"
+msgstr "LIBELLE"
+
+#. module: etudesetchantiersidf
+#: view:account.csv.export:0
+msgid "CCMX export"
+msgstr "Export CCMX"
+
 #. module: etudesetchantiersidf
 #: model:product.template,name:etudesetchantiersidf.product_take_in_out_product_template
 msgid "Produit d'entrée et de sortie de caisse"
diff --git a/wizard/__init__.py b/wizard/__init__.py
new file mode 100644 (file)
index 0000000..c70f69e
--- /dev/null
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    etudesetchantiersidf module for OpenERP, Custom module for Étude et
+#    Chantiers île-de-France
+#    Copyright (C) 2014-2017 etudesetchantiersidf
+#    (<http://etudesetchantiersiledefrance.unarec.org/>)
+#
+#    This file is a part of etudesetchantiersidf
+#
+#    etudesetchantiersidf is free software: you can redistribute it and/or
+#    modify it under the terms of the GNU General Public License as published
+#    by the Free Software Foundation, either version 3 of the License, or (at
+#    your option) any later version.
+#
+#    etudesetchantiersidf is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import account_export_csv
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/wizard/account_export_csv.py b/wizard/account_export_csv.py
new file mode 100644 (file)
index 0000000..967f05b
--- /dev/null
@@ -0,0 +1,186 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    etudesetchantiersidf module for OpenERP, Custom module for Étude et
+#    Chantiers île-de-France
+#    Copyright (C) 2014-2018 etudesetchantiersidf
+#    (<http://etudesetchantiersiledefrance.unarec.org/>)
+#
+#    This file is a part of etudesetchantiersidf
+#
+#    etudesetchantiersidf is free software: you can redistribute it and/or
+#    modify it under the terms of the GNU General Public License as published
+#    by the Free Software Foundation, either version 3 of the License, or (at
+#    your option) any later version.
+#
+#    etudesetchantiersidf is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import StringIO
+import cStringIO
+import base64
+import csv
+import codecs
+import calendar
+
+import openerp.exceptions
+from openerp.osv import osv
+from openerp.tools.translate import _
+from openerp.addons.account_export_csv.wizard.account_export_csv import AccountUnicodeWriter
+
+class AccountUnicodeWriter(AccountUnicodeWriter):
+
+    def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds):
+        # Redirect output to a queue
+        self.queue = cStringIO.StringIO()
+        # created a writer with Excel formating settings
+
+        self.writer = csv.writer(self.queue, dialect=dialect,
+                                 quoting=csv.QUOTE_NONE, **kwds)
+        self.stream = f
+        self.encoder = codecs.getincrementalencoder(encoding)()
+
+
+class AccountCSVExport(osv.osv_memory):
+    _inherit = "account.csv.export"
+
+    def action_manual_export_ccmx(self, cr, uid, ids, context=None):
+        this = self.browse(cr, uid, ids)[0]
+        rows = self.get_data(cr, uid, ids, "ccmx", context)
+        file_data = StringIO.StringIO()
+        try:
+            writer = AccountUnicodeWriter(file_data)
+            writer.writerows(rows)
+            file_value = file_data.getvalue()
+            self.write(cr, uid, ids,
+                       {'data': base64.encodestring(file_value)},
+                       context=context)
+        finally:
+            file_data.close()
+        return {
+            'type': 'ir.actions.act_window',
+            'res_model': 'account.csv.export',
+            'view_mode': 'form',
+            'view_type': 'form',
+            'res_id': this.id,
+            'views': [(False, 'form')],
+            'target': 'new',
+        }
+
+    def _get_header_ccmx(self, cr, uid, ids, context=None):
+        """docstring for _get_header_ccmx"""
+        return [_(u'ID'),
+                _(u'DATE'),
+                _(u'JOURNAL'),
+                _(u'COMPTE'),
+                _(u'LIBELLE'),
+                _(u'REFERENCE'),
+                _(u'DEBIT'),
+                _(u'CREDIT'),
+                _(u'ANALYTIQUE'),
+                ]
+
+    def _get_rows_ccmx(self, cr, uid, ids,
+                          fiscalyear_id,
+                          period_range_ids,
+                          journal_ids,
+                          account_ids,
+                          context=None):
+        fiscalyear_obj = self.pool.get('account.fiscalyear')
+        fiscalyear_code = fiscalyear_obj.browse(cr, uid, fiscalyear_id, context=context)
+        fiscalyear_code = fiscalyear_obj.browse(cr, uid, fiscalyear_id, context=context).code
+        test = 0
+        if len(period_range_ids) != 1:
+            raise openerp.exceptions.Warning(_('You must select ONE period for this export.'))
+            return []
+        else:
+            test += 1
+        if len(journal_ids) != 1:
+            raise openerp.exceptions.Warning(_('You must select ONE journal for this export.'))
+            return []
+        else:
+            test += 1
+        if test == 2:
+            period_obj = self.pool.get('account.period')
+            period_code = period_obj.browse(cr, uid, period_range_ids[0], context=context).code
+            period_id = period_obj.browse(cr, uid, period_range_ids[0], context=context).id
+            mandy = period_code.split("/")
+            nbday = calendar.monthrange(int(mandy[1]), int(mandy[0]))[1]
+            ref_date = "".join((str(nbday), mandy[0], mandy[1][2:4]))
+            journal_obj = self.pool.get('account.journal')
+            journal = journal_obj.browse(cr, uid, journal_ids[0], context=context)
+            journal_id = journal.id
+            try:
+                city = journal.name.split(" - ")[1]
+                libelle = " ".join((journal.name, period_code))
+                reference = " ".join((journal.code[:2], period_code))
+            except IndexError:
+                raise openerp.exceptions.Warning(_('The selected journal is not available for this export type.'))
+                return []
+
+            req = """
+                select '' as id,
+                   '%(ref_date)s' as date,
+                   j.code as journal,
+                   ac.code,
+                   '%(libelle)s' as libelle,
+                   '%(reference)s' as reference,
+                    sum(debit) as sum_debit,
+                    sum(credit) as sum_credit
+                    from
+                       account_move_line as aml,
+                       account_account as ac,
+                       account_journal as j
+                    where
+                       aml.account_id = ac.id
+                       and aml.journal_id = j.id
+                       and period_id = %(period_id)d
+                       and journal_id = %(journal_id)d
+                    group by
+                       j.id,
+                       ac.id,
+                       ac.code,
+                       ac.name
+                    order by ac.code
+                   """ % {
+                       'ref_date': ref_date,
+                       'libelle': libelle,
+                       'reference': reference,
+                       'fiscalyear_id': fiscalyear_id,
+                       'period_id': period_id,
+                       'journal_id': journal_id,
+                       }
+            cr.execute(req)
+            res = cr.fetchall()
+            rows = []
+            for line in res:
+                journal = line[2]
+                code = line[3]
+                debit = line[6]
+                credit = line[7]
+                analytic = journal[2:]
+                "Add analytic account for 6 and 7 classes accounts"
+                if code[:1] in ('6', '7'):
+                    line = line + (analytic,)
+                else:
+                    line = line + ('',)
+                "Split lines whith debit AND credit amount"
+                if debit and credit:
+                    dline = list(line)
+                    dline[7] = 0
+                    rows.append(dline)
+                    cline = list(line)
+                    cline[6] = 0
+                    rows.append(cline)
+                else:
+                    rows.append(list(line))
+            return rows
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/wizard/account_export_csv_view.xml b/wizard/account_export_csv_view.xml
new file mode 100644 (file)
index 0000000..80ff3e5
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+    <record id="account_csv_export_view" model="ir.ui.view">
+        <field name="name">account.csv.export.form</field>
+        <field name="model">account.csv.export</field>
+        <field name="inherit_id" ref="account_export_csv.account_csv_export_view"/>
+        <field name="arch" type="xml">
+            <xpath expr="//button[@name='action_manual_export_account']" position="before">
+                <button name="action_manual_export_ccmx" string="CCMX export" type="object" icon="gtk-execute" class="oe_highlight"/>
+            </xpath>
+        </field>
+    </record>
+    </data>
+</openerp>