From a086a72d7f6f135e06e31aaa24ecb5608ebb8a93 Mon Sep 17 00:00:00 2001 From: Andrea Stirpe Date: Mon, 13 Mar 2017 08:38:01 +0100 Subject: [PATCH] [10.0][MIG] Port l10n_nl_xaf_auditfile_export (#59) * Align code with l10n_nl_xaf_auditfile_export V8 * Porting to V10 * Update readme * Minor code review * Fix start and end date of periods + updated readme * Fix condition when checking dates * Update Usage in readme according V10 menu names * Replace bank field with bank_id * Make menuitem compatible with Odoo enterprise * Add nl.po file (courtesy of @ploegvde) * Fix menu name in readme * Add empty line in chatter between errors --- l10n_nl_xaf_auditfile_export/README.rst | 50 +++-- l10n_nl_xaf_auditfile_export/__manifest__.py | 23 +-- .../i18n/l10n_nl_xaf_auditfile_export.pot | 191 ------------------ l10n_nl_xaf_auditfile_export/i18n/nl.po | 186 +++++++++++++++++ .../models/ir_qweb.py | 30 +-- .../models/xaf_auditfile_export.py | 141 ++++++++----- .../security/ir.model.access.csv | 4 +- l10n_nl_xaf_auditfile_export/views/menu.xml | 20 +- .../views/templates.xml | 34 ++-- .../views/xaf_auditfile_export.xml | 88 ++++---- 10 files changed, 413 insertions(+), 354 deletions(-) delete mode 100644 l10n_nl_xaf_auditfile_export/i18n/l10n_nl_xaf_auditfile_export.pot create mode 100644 l10n_nl_xaf_auditfile_export/i18n/nl.po diff --git a/l10n_nl_xaf_auditfile_export/README.rst b/l10n_nl_xaf_auditfile_export/README.rst index e343215f4..76fd667e9 100644 --- a/l10n_nl_xaf_auditfile_export/README.rst +++ b/l10n_nl_xaf_auditfile_export/README.rst @@ -1,3 +1,8 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +==================== XAF auditfile export ==================== @@ -5,12 +10,26 @@ This module allows you to export XAF audit files for the Dutch tax authorities ( The currently exported version is 3.2 +Configuration +============= + +The exporting feature is available to the users who have `Accountant` or `Adviser` rights for accounting. + +To configure the default start and end dates of the actual fiscal year, go to `accounting`/`settings` and change the +last date of the year you want to export. Then in the form of the audit file export, by default the end-date will be set +accordingly and the start date will be 12 months before the end date. +Be aware that in case the OCA module `account_fiscal_year` is installed, then the calculus of the fiscal year dates is +overridden, taking by default the date range defined for the actual fiscal year (check `Settings`/`Date Ranges`). + +This module works on huge amount of data, so there is a possibility to encounter out of memory exceptions. In this case. set the config parameter `l10n_nl_xaf_auditfile_export.max_records` to a value much lower than 10000. + Usage ===== To use this module, you need to: -* go to `Invoicing`/`Reporting`/`Legal Reports`/`Auditfile export` +* be sure that you have `Accountant` or `Adviser` rights for accounting +* go to `Invoicing`/`Reports`/`Auditfile export` * create a new record, adjust values if the defaults are not appropriate * click `Generate auditfile` * click `Download` on the field `Auditfile` @@ -19,10 +38,9 @@ For further information, please visit: * https://www.odoo.com/forum/help-1 -Configuration -============= - -This module works on huge amount of data, so there is a possibility to encounter out of memory exceptions. In this case. set the config parameter `l10n_nl_xaf_auditfile_export.max_records` to a value much lower than 10000. +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/176/10.0 Known issues / Roadmap ====================== @@ -33,11 +51,10 @@ Known issues / Roadmap Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. - +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. Credits ======= @@ -46,6 +63,7 @@ Contributors ------------ * Holger Brunn +* Andrea Stirpe Icon ---- @@ -60,12 +78,14 @@ http://www.softwarepakket.nl/swpakketten/auditfiles/auditfile_financieel.php?bro Maintainer ---------- -.. image:: http://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: http://odoo-community.org +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org This module is maintained by the OCA. -OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/l10n_nl_xaf_auditfile_export/__manifest__.py b/l10n_nl_xaf_auditfile_export/__manifest__.py index 66a4a616e..758c80e7d 100644 --- a/l10n_nl_xaf_auditfile_export/__manifest__.py +++ b/l10n_nl_xaf_auditfile_export/__manifest__.py @@ -20,29 +20,20 @@ ############################################################################## { "name": "XAF auditfile export", - "version": "8.0.1.0.0", - "author": "Therp BV", + "version": "10.0.1.0.0", + "author": "Therp BV, Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Accounting & Finance", "summary": "Export XAF auditfiles for Dutch tax authorities", "depends": [ - 'base', - 'account', + "base", + "account", ], "data": [ + "security/ir.model.access.csv", "views/xaf_auditfile_export.xml", + "views/templates.xml", "views/menu.xml", - 'views/templates.xml', - 'security/ir.model.access.csv', ], - "qweb": [ - ], - "test": [ - ], - "auto_install": False, - 'installable': False, - "application": False, - "external_dependencies": { - 'python': [], - }, + "installable": True, } diff --git a/l10n_nl_xaf_auditfile_export/i18n/l10n_nl_xaf_auditfile_export.pot b/l10n_nl_xaf_auditfile_export/i18n/l10n_nl_xaf_auditfile_export.pot deleted file mode 100644 index 904f897a8..000000000 --- a/l10n_nl_xaf_auditfile_export/i18n/l10n_nl_xaf_auditfile_export.pot +++ /dev/null @@ -1,191 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * l10n_nl_xaf_auditfile_export -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-02-20 09:43+0000\n" -"PO-Revision-Date: 2015-02-20 09:43+0000\n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,auditfile:0 -msgid "Auditfile" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: model:ir.actions.act_window,name:l10n_nl_xaf_auditfile_export.action_auditfiles -#: model:ir.ui.menu,name:l10n_nl_xaf_auditfile_export.menu_auditfiles -msgid "Auditfile export" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,company_id:0 -msgid "Company" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,create_uid:0 -msgid "Created by" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,create_date:0 -msgid "Created on" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,date_generated:0 -msgid "Date generated" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: help:xaf.auditfile.export,message_last_post:0 -msgid "Date of the last message posted on the record." -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,period_end:0 -msgid "End period" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,message_follower_ids:0 -msgid "Followers" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: view:xaf.auditfile.export:4 -msgid "Generate auditfile" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: help:xaf.auditfile.export,message_summary:0 -msgid "Holds the Chatter summary (number of messages, ...). This summary is directly in html format in order to be inserted in kanban views." -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:ir.qweb.widget.auditfile.string10,id:0 -#: field:ir.qweb.widget.auditfile.string15,id:0 -#: field:ir.qweb.widget.auditfile.string20,id:0 -#: field:ir.qweb.widget.auditfile.string30,id:0 -#: field:ir.qweb.widget.auditfile.string50,id:0 -#: field:ir.qweb.widget.auditfile.string9,id:0 -#: field:ir.qweb.widget.auditfile.string999,id:0 -#: field:xaf.auditfile.export,id:0 -msgid "ID" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: help:xaf.auditfile.export,message_unread:0 -msgid "If checked new messages require your attention." -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,message_is_follower:0 -msgid "Is a Follower" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,message_last_post:0 -msgid "Last Message Date" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,write_uid:0 -msgid "Last Updated by" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,write_date:0 -msgid "Last Updated on" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: view:False:68 -#: view:False:97 -msgid "Last write" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,message_ids:0 -msgid "Messages" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: help:xaf.auditfile.export,message_ids:0 -msgid "Messages and communication history" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,name:0 -msgid "Name" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: view:False:10 -msgid "Odoo" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,period_start:0 -msgid "Start period" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,message_summary:0 -msgid "Summary" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: field:xaf.auditfile.export,message_unread:0 -msgid "Unread Messages" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_xaf_auditfile_export -msgid "XAF auditfile export" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_widget_auditfile_string10 -msgid "ir.qweb.widget.auditfile.string10" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_widget_auditfile_string15 -msgid "ir.qweb.widget.auditfile.string15" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_widget_auditfile_string20 -msgid "ir.qweb.widget.auditfile.string20" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_widget_auditfile_string30 -msgid "ir.qweb.widget.auditfile.string30" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_widget_auditfile_string50 -msgid "ir.qweb.widget.auditfile.string50" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_widget_auditfile_string9 -msgid "ir.qweb.widget.auditfile.string9" -msgstr "" - -#. module: l10n_nl_xaf_auditfile_export -#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_widget_auditfile_string999 -msgid "ir.qweb.widget.auditfile.string999" -msgstr "" - diff --git a/l10n_nl_xaf_auditfile_export/i18n/nl.po b/l10n_nl_xaf_auditfile_export/i18n/nl.po new file mode 100644 index 000000000..0f3588254 --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/i18n/nl.po @@ -0,0 +1,186 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_nl_xaf_auditfile_export +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-09 11:47+0000\n" +"PO-Revision-Date: 2017-03-09 11:47+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_auditfile +msgid "Auditfile" +msgstr "Auditfile" + +#. module: l10n_nl_xaf_auditfile_export +#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:77 +#, python-format +msgid "Auditfile %s %s" +msgstr "Auditfile %s %s" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.actions.act_window,name:l10n_nl_xaf_auditfile_export.action_auditfiles +#: model:ir.ui.menu,name:l10n_nl_xaf_auditfile_export.menu_auditfiles +msgid "Auditfile export" +msgstr "Auditfile export" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_auditfile_name +msgid "Auditfile filename" +msgstr "Auditfile bestandsnaam" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_company_id +msgid "Company" +msgstr "Bedrijf" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_create_uid +msgid "Created by" +msgstr "Aangemaakt door" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_create_date +msgid "Created on" +msgstr "Aangemaakt op" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_date_generated +msgid "Date generated" +msgstr "Datum gegenereerd" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string10_display_name +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string15_display_name +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string20_display_name +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string30_display_name +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string50_display_name +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string999_display_name +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string9_display_name +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_display_name +msgid "Display Name" +msgstr "Weergave naam" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_date_end +msgid "End date" +msgstr "Einddatum" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_fiscalyear_name +msgid "Fiscalyear name" +msgstr "Boekjaar" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.ui.view,arch_db:l10n_nl_xaf_auditfile_export.form_xaf_auditfile_export +msgid "Generate auditfile" +msgstr "Genereer auditfile" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string10_id +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string15_id +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string20_id +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string30_id +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string50_id +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string999_id +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string9_id +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_id +msgid "ID" +msgstr "ID" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string10___last_update +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string15___last_update +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string20___last_update +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string30___last_update +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string50___last_update +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string999___last_update +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_ir_qweb_field_auditfile_string9___last_update +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export___last_update +msgid "Last Modified on" +msgstr "Laatst gewijzigd op" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_write_uid +msgid "Last Updated by" +msgstr "Laatst bijgewerkt door" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_write_date +msgid "Last Updated on" +msgstr "Laatst bijgewerkt op" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.ui.view,arch_db:l10n_nl_xaf_auditfile_export.auditfile_template +msgid "Last write" +msgstr "Laast geschreven" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_name +msgid "Name" +msgstr "Naam" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.ui.view,arch_db:l10n_nl_xaf_auditfile_export.auditfile_template +msgid "Odoo" +msgstr "Odoo" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_date_start +msgid "Start date" +msgstr "Startdatum" + +#. module: l10n_nl_xaf_auditfile_export +#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:88 +#, python-format +msgid "Starting date must be anterior ending date!" +msgstr "Startdatum moet liggen voor de einddatum!" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_xaf_auditfile_export +msgid "XAF auditfile export" +msgstr "XAF auditfile export" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_field_auditfile_string10 +msgid "ir.qweb.field.auditfile.string10" +msgstr "ir.qweb.field.auditfile.string10" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_field_auditfile_string15 +msgid "ir.qweb.field.auditfile.string15" +msgstr "ir.qweb.field.auditfile.string15" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_field_auditfile_string20 +msgid "ir.qweb.field.auditfile.string20" +msgstr "ir.qweb.field.auditfile.string20" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_field_auditfile_string30 +msgid "ir.qweb.field.auditfile.string30" +msgstr "ir.qweb.field.auditfile.string30" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_field_auditfile_string50 +msgid "ir.qweb.field.auditfile.string50" +msgstr "ir.qweb.field.auditfile.string50" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_field_auditfile_string9 +msgid "ir.qweb.field.auditfile.string9" +msgstr "ir.qweb.field.auditfile.string9" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.model,name:l10n_nl_xaf_auditfile_export.model_ir_qweb_field_auditfile_string999 +msgid "ir.qweb.field.auditfile.string999" +msgstr "ir.qweb.field.auditfile.string999" + diff --git a/l10n_nl_xaf_auditfile_export/models/ir_qweb.py b/l10n_nl_xaf_auditfile_export/models/ir_qweb.py index 9d3c55235..4041d824e 100644 --- a/l10n_nl_xaf_auditfile_export/models/ir_qweb.py +++ b/l10n_nl_xaf_auditfile_export/models/ir_qweb.py @@ -18,12 +18,12 @@ # along with this program. If not, see . # ############################################################################## -from openerp import models +from odoo import models class IrQwebAuditfileStringWidget999(models.AbstractModel): - _name = 'ir.qweb.widget.auditfile.string999' - _inherit = 'ir.qweb.widget' + _name = 'ir.qweb.field.auditfile.string999' + _inherit = 'ir.qweb.field' _max_length = 999 def _format(self, inner, options, qwebcontext): @@ -32,36 +32,36 @@ def _format(self, inner, options, qwebcontext): class IrQwebAuditfileStringWidget9(models.AbstractModel): - _name = 'ir.qweb.widget.auditfile.string9' - _inherit = 'ir.qweb.widget.auditfile.string999' + _name = 'ir.qweb.field.auditfile.string9' + _inherit = 'ir.qweb.field.auditfile.string999' _max_length = 9 class IrQwebAuditfileStringWidget10(models.AbstractModel): - _name = 'ir.qweb.widget.auditfile.string10' - _inherit = 'ir.qweb.widget.auditfile.string999' + _name = 'ir.qweb.field.auditfile.string10' + _inherit = 'ir.qweb.field.auditfile.string999' _max_length = 10 class IrQwebAuditfileStringWidget15(models.AbstractModel): - _name = 'ir.qweb.widget.auditfile.string15' - _inherit = 'ir.qweb.widget.auditfile.string999' + _name = 'ir.qweb.field.auditfile.string15' + _inherit = 'ir.qweb.field.auditfile.string999' _max_length = 15 class IrQwebAuditfileStringWidget20(models.AbstractModel): - _name = 'ir.qweb.widget.auditfile.string20' - _inherit = 'ir.qweb.widget.auditfile.string999' + _name = 'ir.qweb.field.auditfile.string20' + _inherit = 'ir.qweb.field.auditfile.string999' _max_length = 20 class IrQwebAuditfileStringWidget30(models.AbstractModel): - _name = 'ir.qweb.widget.auditfile.string30' - _inherit = 'ir.qweb.widget.auditfile.string999' + _name = 'ir.qweb.field.auditfile.string30' + _inherit = 'ir.qweb.field.auditfile.string999' _max_length = 30 class IrQwebAuditfileStringWidget50(models.AbstractModel): - _name = 'ir.qweb.widget.auditfile.string50' - _inherit = 'ir.qweb.widget.auditfile.string999' + _name = 'ir.qweb.field.auditfile.string50' + _inherit = 'ir.qweb.field.auditfile.string999' _max_length = 50 diff --git a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py index 40b823407..4541715e6 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -19,10 +19,12 @@ # ############################################################################## import base64 +import collections from StringIO import StringIO from lxml import etree -from datetime import datetime -from openerp import _, models, fields, api, exceptions, release, modules +from datetime import datetime, timedelta +from dateutil.rrule import rrule, MONTHLY +from odoo import _, models, fields, api, exceptions, release, modules MAX_RECORDS = 10000 @@ -36,17 +38,22 @@ class XafAuditfileExport(models.Model): _name = 'xaf.auditfile.export' _description = 'XAF auditfile export' _inherit = ['mail.thread'] - _order = 'period_start desc' + _order = 'date_start desc' @api.depends('name') def _auditfile_name_get(self): self.auditfile_name = '%s.xaf' % self.name + @api.multi + def _compute_fiscalyear_name(self): + for auditfile in self: + if auditfile.date_start: + auditfile.fiscalyear_name = auditfile.date_start[0:4] + name = fields.Char('Name') - period_start = fields.Many2one( - 'account.period', 'Start period', required=True) - period_end = fields.Many2one( - 'account.period', 'End period', required=True) + date_start = fields.Date('Start date', required=True) + date_end = fields.Date('End date', required=True) + fiscalyear_name = fields.Char(compute='_compute_fiscalyear_name') auditfile = fields.Binary('Auditfile', readonly=True, copy=False) auditfile_name = fields.Char( 'Auditfile filename', compute=_auditfile_name_get) @@ -55,39 +62,30 @@ def _auditfile_name_get(self): company_id = fields.Many2one('res.company', 'Company', required=True) @api.model - def default_get(self, fields): - defaults = super(XafAuditfileExport, self).default_get(fields) - company = self.env['res.company'].browse([ - self.env['res.company']._company_default_get( - object=self._model._name)]) - fiscalyear = self.env['account.fiscalyear'].browse([ - self.env['account.fiscalyear'].find(exception=False)]) - if fiscalyear and self.env['account.fiscalyear'].search( - [('date_start', '<', fiscalyear.date_start)], - limit=1): - fiscalyear = self.env['account.fiscalyear'].search( - [('date_start', '<', fiscalyear.date_start)], limit=1, - order='date_stop desc') - if 'company_id' in fields: + def default_get(self, fields_list): + defaults = super(XafAuditfileExport, self).default_get(fields_list) + company = self.env.user.company_id + fy_dates = company.compute_fiscalyear_dates(datetime.now()) + date_from = fields.Date.to_string(fy_dates['date_from']) + date_to = fields.Date.to_string(fy_dates['date_to']) + defaults.setdefault('date_start', date_from) + defaults.setdefault('date_end', date_to) + if 'company_id' in fields_list: defaults.setdefault('company_id', company.id) - if 'name' in fields: + if 'name' in fields_list: defaults.setdefault( 'name', _('Auditfile %s %s') % ( company.name, - fiscalyear.name if fiscalyear - else datetime.now().strftime('%Y'))) - if 'period_start' in fields and fiscalyear: - defaults.setdefault('period_start', fiscalyear.period_ids[0].id) - if 'period_end' in fields and fiscalyear: - defaults.setdefault('period_end', fiscalyear.period_ids[-1].id) + datetime.now().strftime('%Y'))) + return defaults @api.one - @api.constrains('period_start', 'period_end') - def check_periods(self): - if self.period_start.date_start > self.period_end.date_start: + @api.constrains('date_start', 'date_end') + def check_dates(self): + if self.date_start >= self.date_end: raise exceptions.ValidationError( - _('You need to choose consecutive periods!')) + _('Starting date must be anterior ending date!')) @api.multi def button_generate(self): @@ -124,11 +122,11 @@ def button_generate(self): 'l10n_nl_xaf_auditfile_export', 'data', 'XmlAuditfileFinancieel3.2.xsd')))) if not xsd.validate(xmldoc): - self.message_post('\n'.join(map(str, xsd.error_log))) + self.message_post('

\n'.join(map(str, xsd.error_log))) return self.auditfile = base64.b64encode(etree.tostring( - xmldoc, xml_declaration=True, encoding='utf8')) + xmldoc, xml_declaration=True, encoding='UTF-8')) @api.multi def get_odoo_version(self): @@ -163,19 +161,53 @@ def get_partners(self): @api.multi def get_accounts(self): - '''return browse record list of accounts''' + '''return recordset of accounts''' return self.env['account.account'].search([ ('company_id', '=', self.company_id.id), ]) + @api.model + def get_period_number(self, date): + period_id = date[3:4] + date[5:7] + return period_id + @api.multi def get_periods(self): - '''return periods in this export''' - return self.env['account.period'].search([ - ('date_start', '<=', self.period_end.date_stop), - ('date_stop', '>=', self.period_start.date_start), - ('company_id', '=', self.company_id.id), - ]) + + def month_end_date(date_start): + month = date_start.month + year = date_start.year + month += 1 + if month == 13: + month = 1 + year += 1 + + start_date_next_month = date_start.replace(month=month, year=year) + return start_date_next_month - timedelta(days=1) + + self.ensure_one() + months = rrule( + freq=MONTHLY, bymonth=(), + dtstart=fields.Date.from_string(self.date_start), + until=fields.Date.from_string(self.date_end) + ) + + Period = collections.namedtuple( + 'Period', + 'number name date_start date_end' + ) + periods = [] + for dt_start in list(months): + date_start = fields.Date.to_string(dt_start.date()) + date_end = fields.Date.to_string(month_end_date(dt_start.date())) + periods.append(Period( + number=self.get_period_number(date_start), + name=dt_start.strftime('%B') + ' ' + self.fiscalyear_name, + date_start=date_start, + date_end=date_end, + )) + + return periods @api.multi def get_taxes(self): @@ -188,27 +220,33 @@ def get_taxes(self): def get_move_line_count(self): '''return amount of move lines''' self.env.cr.execute( - 'select count(*) from account_move_line where period_id in %s ' + 'select count(*) from account_move_line ' + 'where date >= \'' + self.date_start + '\' ' + 'and date <= \'' + self.date_end + '\' ' 'and (company_id=%s or company_id is null)', - (tuple(p.id for p in self.get_periods()), self.company_id.id)) + (self.company_id.id, )) return self.env.cr.fetchall()[0][0] @api.multi def get_move_line_total_debit(self): '''return total debit of move lines''' self.env.cr.execute( - 'select sum(debit) from account_move_line where period_id in %s ' + 'select sum(debit) from account_move_line ' + 'where date >= \'' + self.date_start + '\' ' + 'and date <= \'' + self.date_end + '\' ' 'and (company_id=%s or company_id is null)', - (tuple(p.id for p in self.get_periods()), self.company_id.id)) + (self.company_id.id, )) return self.env.cr.fetchall()[0][0] @api.multi def get_move_line_total_credit(self): '''return total credit of move lines''' self.env.cr.execute( - 'select sum(credit) from account_move_line where period_id in %s ' + 'select sum(credit) from account_move_line ' + 'where date >= \'' + self.date_start + '\' ' + 'and date <= \'' + self.date_end + '\' ' 'and (company_id=%s or company_id is null)', - (tuple(p.id for p in self.get_periods()), self.company_id.id)) + (self.company_id.id, )) return self.env.cr.fetchall()[0][0] @api.multi @@ -222,11 +260,11 @@ def get_journals(self): def get_moves(self, journal): '''return moves for a journal, generator style''' offset = 0 - period_ids = [p.id for p in self.get_periods()] while True: results = self.env['account.move'].search( [ - ('period_id', 'in', period_ids), + ('date', '>=', self.date_start), + ('date', '<=', self.date_end), ('journal_id', '=', journal.id), ], offset=offset, @@ -240,3 +278,8 @@ def get_moves(self, journal): yield result results.env.invalidate_all() del results + + @api.model + def get_move_period_number(self, move): + period_number = self.get_period_number(move.date) + return period_number diff --git a/l10n_nl_xaf_auditfile_export/security/ir.model.access.csv b/l10n_nl_xaf_auditfile_export/security/ir.model.access.csv index 79c5fbdd4..575379fb1 100644 --- a/l10n_nl_xaf_auditfile_export/security/ir.model.access.csv +++ b/l10n_nl_xaf_auditfile_export/security/ir.model.access.csv @@ -1,2 +1,2 @@ -"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -crud_xaf_auditfile_export,"Crud auditfile exports",model_xaf_auditfile_export,account.group_account_manager,1,1,1,1 +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +crud_xaf_auditfile_export,Crud auditfile exports,model_xaf_auditfile_export,account.group_account_manager,1,1,1,1 diff --git a/l10n_nl_xaf_auditfile_export/views/menu.xml b/l10n_nl_xaf_auditfile_export/views/menu.xml index 8a3f3023e..6fce62e00 100644 --- a/l10n_nl_xaf_auditfile_export/views/menu.xml +++ b/l10n_nl_xaf_auditfile_export/views/menu.xml @@ -1,13 +1,9 @@ - - - - - - + + + + + diff --git a/l10n_nl_xaf_auditfile_export/views/templates.xml b/l10n_nl_xaf_auditfile_export/views/templates.xml index 2005690b0..f3577b33c 100644 --- a/l10n_nl_xaf_auditfile_export/views/templates.xml +++ b/l10n_nl_xaf_auditfile_export/views/templates.xml @@ -1,12 +1,12 @@ - - + +