From 932f5f35342544dab3dcc632ceca52de0df9aaa3 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 17 Feb 2015 15:23:10 +0100 Subject: [PATCH 001/112] [ADD] proof of concept l10n_nl_xaf_auditfile_export --- l10n_nl_xaf_auditfile_export/README.rst | 56 ++++++++++ l10n_nl_xaf_auditfile_export/__init__.py | 23 +++++ l10n_nl_xaf_auditfile_export/__openerp__.py | 47 +++++++++ .../models/__init__.py | 21 ++++ .../models/xaf_auditfile_export.py | 97 ++++++++++++++++++ .../static/description/icon.png | Bin 0 -> 2553 bytes l10n_nl_xaf_auditfile_export/views/menu.xml | 13 +++ .../views/templates.xml | 20 ++++ .../views/xaf_auditfile_export.xml | 41 ++++++++ 9 files changed, 318 insertions(+) create mode 100644 l10n_nl_xaf_auditfile_export/README.rst create mode 100644 l10n_nl_xaf_auditfile_export/__init__.py create mode 100644 l10n_nl_xaf_auditfile_export/__openerp__.py create mode 100644 l10n_nl_xaf_auditfile_export/models/__init__.py create mode 100644 l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py create mode 100644 l10n_nl_xaf_auditfile_export/static/description/icon.png create mode 100644 l10n_nl_xaf_auditfile_export/views/menu.xml create mode 100644 l10n_nl_xaf_auditfile_export/views/templates.xml create mode 100644 l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml diff --git a/l10n_nl_xaf_auditfile_export/README.rst b/l10n_nl_xaf_auditfile_export/README.rst new file mode 100644 index 000000000..b351c04ec --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/README.rst @@ -0,0 +1,56 @@ +XAF auditfile export +==================== + +This module allows you to export XAF audit files for the Dutch tax authorities (Belastingdienst). + +The currently exported version is 3.2 + +Usage +===== + +To use this module, you need to: + +* go to `Invoicing`/`Reporting`/`Legal Reports`/`Auditfile export` +* create a new record, adjust values if the defaults are not appropriate +* click `Generate auditfile` +* click `Download` on the field `Auditfile` + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +* encrypted and compressed files would be nice + +Credits +======= + +Contributors +------------ + +* Holger Brunn + +Icon +---- + +https://openclipart.org/detail/180891 + +Documentation +------------- + +http://www.softwarepakket.nl/swpakketten/auditfiles/auditfile_financieel.php?bronw=6 + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/l10n_nl_xaf_auditfile_export/__init__.py b/l10n_nl_xaf_auditfile_export/__init__.py new file mode 100644 index 000000000..36c6e4967 --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 Therp BV . +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from . import models +from . import wizard +from . import controllers diff --git a/l10n_nl_xaf_auditfile_export/__openerp__.py b/l10n_nl_xaf_auditfile_export/__openerp__.py new file mode 100644 index 000000000..b4e6301c7 --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/__openerp__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 Therp BV . +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + "name": "XAF auditfile export", + "version": "1.0", + "author": "Therp BV", + "license": "AGPL-3", + "category": "Accounting & Finance", + "summary": "Export XAF auditfiles for Dutch tax authorities", + "depends": [ + 'account', + ], + "data": [ + "views/xaf_auditfile_export.xml", + "views/menu.xml", + 'views/templates.xml', + 'security/ir.model.access.csv', + ], + "qweb": [ + ], + "test": [ + ], + "auto_install": False, + "installable": True, + "application": False, + "external_dependencies": { + 'python': [], + }, +} diff --git a/l10n_nl_xaf_auditfile_export/models/__init__.py b/l10n_nl_xaf_auditfile_export/models/__init__.py new file mode 100644 index 000000000..5b319b10e --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/models/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 Therp BV . +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from . import xaf_auditfile_export diff --git a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py new file mode 100644 index 000000000..90af45e2c --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import base64 +from lxml import etree +from datetime import datetime +from openerp import _, models, fields, api, exceptions, release + + +class XafAuditfileExport(models.Model): + _name = 'xaf.auditfile.export' + _description = 'XAF auditfile export' + _inherit = ['mail.thread'] + _order = 'period_start desc' + + @api.depends('name') + def _auditfile_name_get(self): + self.auditfile_name = '%s.xaf' % self.name + + name = fields.Char('Name') + period_start = fields.Many2one( + 'account.period', 'Start period', required=True) + period_end = fields.Many2one( + 'account.period', 'End period', required=True) + auditfile = fields.Binary('Auditfile', readonly=True, copy=False) + auditfile_name = fields.Char( + 'Auditfile filename', compute=_auditfile_name_get) + date_generated = fields.Datetime( + 'Date generated', readonly=True, copy=False) + company_id = fields.Many2one('res.company', 'Company', required=True, + readonly=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 'company_id' in fields: + defaults.setdefault('company_id', company.id) + if 'name' in fields: + defaults.setdefault( + 'name', _('Auditfile %s %s') % ( + company.name, 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) + 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: + raise exceptions.ValidationError( + _('You need to choose consecutive periods!')) + + @api.multi + def button_generate(self): + self.date_generated = fields.Datetime.now(self) + xml = self.env.ref('l10n_nl_xaf_auditfile_export.auditfile_template')\ + .render(values={ + 'self': self, + }) + from_template = etree.fromstring(xml) + xmldoc = etree.Element( + from_template.tag, + nsmap = { + None: 'http://www.auditfiles.nl/XAF/3.2', + 'xsi': 'http://www.w3.org/2001/XMLSchema-instance', + }) + xmldoc[:] = from_template[:] + self.auditfile = base64.b64encode(etree.tostring( + xmldoc, xml_declaration=True, encoding='utf8')) + + @api.multi + def get_odoo_version(self): + return release.version diff --git a/l10n_nl_xaf_auditfile_export/static/description/icon.png b/l10n_nl_xaf_auditfile_export/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cf8bd240253a0b5fb491ac8fe9bc61f81fc537d8 GIT binary patch literal 2553 zcmVmY^ZlGVb06P5=iGD7Jp*{~;K73j4<0;t@ZiCN2M-=Rc<^w=fEIG_JMX+x z85|s3Dy6Je6eR$_4ttsT+uBy=~iTh^PsGZFn});QD_dr=E67;y~)f6Ow+V-z0}p!RSTdZ5{Zmm$plg; z6uMCeu>(Mh!+kS=cWm3<7mvqBGaGeX{}D5{0eDAB`TPF<{!iRmq~b=WU0q$vRaL!* zh;9Q==hDWv0NC8z++0>!S$XpO`SbF#Mpaes08j&1K5#ozsx*AM1ug16441FdXJecB05JzGelIIrR=eO(v6T0fd=( zBY?_Tq;cf3jVU9_%KPe6D)rNFIQ*+vEM_i>L!`B}wY;vb?g0R6<}msPg%B@AqtU@) z$Em5Q*&u|t1Hk7pn$IeV^60^X2T$F6^Uc1AiHSeVCHzG6vSAo6%-1cNFM&eSw0i+) zv#9AXfZxPovExqccx!8Gd3}BT_OwJEC!$z&b#OnGC2IjZm}hrK0sLY<4*R?a z42Q$tAfg?!sMQ;jlas$YcI?=U+XqTlS66K+mC^uwJ&T0SW{1xUAs#mj<3vdb)HLmS z01xEogPHlcSS&kCMsc7G~Z8psIv9 zf={HBkM{TXpLE=jUa?}uRsii;c5lk(^F1^&GIGg@G*=)H_?ndR9spqgWhG9s1cVS9 zo0^)eL?SWlB!MCr4DQY*eL{#AqS0vFflzS$xpU|4BchE&RK9?jDusw{3pB~T@k&;SDx^2tw!5=- zBE*4#fr05_XW7}=xw5XV?hzu|j0Mh;=Qvz;c6N5IbmA1gF2?}9#ZFGw^&TnZw-><9 z6(otaZ8riqRWyO2P^b|=W42H&7K>TMOiI`FZ!+`ki&5$_5HSoRIxh(%qLv)$d#so! zLf7@XnfWV=oH!<;zZiz`d@k3l5ETw)dnlzGDk1^#J!bA%%*+wde{9?SwP~8BQ;|rn z0NpB3ZSTGU$U7;ed?Fr?pP5q{3h1;V>kjyQ69r^%b}n|cW#$9b)zv@FhrEI$keSP~ zxo6YU(|Nfsx~^|!=B3`$@J&pfN!#GduNgA^f5D^0&p6@ zS!O;5;F6*!)9H=%GjkO)Hwqz|0ep#>%L|mcQ+~hyv10C#^CnOTF~$792a%#E6>~Ys zQp#@?;Ho46#BJM-mz9+rEp$<#Q0TA_Vow3&y-q}XBauk5m<=vOg)ihFb{T+yT;W+N zmAWS%DFrY+fRb zWpnf!W9C1_VzB`y4B5cIz>KD8Je$Nb^RSfi=Z6j*8kz5Sc@wB8%7~OQn*^@QVfR)r z^R2VF3aM0TZ$3G_{_}Ay{2jY!!7dC$V}>fm`o;r;52y!r?ZI2%<=rz%WaNr+w~c)1T*t1 zt5&Ug@W_!PAG__)2_Ysgi)Hr%xZeqTm({ct@^V8%!KiPNDbMx{mXbf{`Ys^eV0)J1cN~^vn_;p$}o)AEz7do+S;nd#>SFPk5zCQ zNz=6N1L(;jg(KC~)%Si@A+T7me*OBgKp?Qo=kvWfS1pd~Dx6l&m$TU~W^SICnAo;Z zM76cGRdsiFS7dqufk5D40QGK=R}_Kqc>F^E(HypLhpy|_Ekpvv@AvOcrBbVaPjB^f zUEgZk_QL>H0C>r*fs3jSY;0^CP!#2sEZ-9Vefjd`vC+}d3#DRD*Y#ZhHZk)`RaKXc zkB{HY%-sMKX8xyJRT4!LI5swRQB_qYqU*CXmjUQhRrRoCS+4)45Dtg$0&v@B!4DCw zMfwt+na`(Esh_!Vc+87H0I)3UeN|Q05z*2t%@qK8nwpx15{ZN>mGZ5vt>r6MuKZ5g zh05j5JQ0t_PrJE+^C|J=hK7d2LWrIm$<{I=+Ni2(`I03|PMkS&MmjZVP19Bf0)agM z+GdGHUNlYffa}KBfyJ}{_z7mIT_K{60Q}J~jCbY}fpm9wFG(ho+W>54W--fnZy1L0 zw9CkeE zqlp|;s}^RypNN*^nKAh{5goT}dsqnZ5r9j~oB~iuM77KuWaiHUSW84Tc~0Z6rfEKl z68;Y6=!LeXX>~;OU1q+a#C~8Bz;Dw@iqbluZaC-RaCoZ_Vtb)?6Gh^Ll=7MW{{Eqb zh=5!xsR)HajY5cB06JY7XIu#JTr?VevlNF#$qBqX9%bgO%zPspC?F!DAtHLMs;cVk z-rnA+g-%wKtf)uRv`PS7%&Zg9wJ5A)*CL`rsZ{DM7p?%V3<5LlWJgCwvy`$KfJ#KQ zL=<4=05eaf6QXCOl%qn3p)29fbq^jqc<|uCg9i^DJb3Wn!Gi}6rNDmyWJ~Es5ou^y P00000NkvXXu0mjfV8G3> literal 0 HcmV?d00001 diff --git a/l10n_nl_xaf_auditfile_export/views/menu.xml b/l10n_nl_xaf_auditfile_export/views/menu.xml new file mode 100644 index 000000000..8a3f3023e --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/views/menu.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/l10n_nl_xaf_auditfile_export/views/templates.xml b/l10n_nl_xaf_auditfile_export/views/templates.xml new file mode 100644 index 000000000..08ada073c --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/views/templates.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml b/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml new file mode 100644 index 000000000..f0ab08c13 --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml @@ -0,0 +1,41 @@ + + + + + xaf.auditfile.export + + + + + + + + + + xaf.auditfile.export + +
+
+
+ + + + + + + + + + + + +
+ + +
+
+
+
+
+
From 2f5e6e2c8325e8fab6bf526c60374cceb842208e Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 17 Feb 2015 16:33:28 +0100 Subject: [PATCH 002/112] [ADD] export customers --- .../models/xaf_auditfile_export.py | 20 +++++++ .../views/templates.xml | 59 +++++++++++++++++++ 2 files changed, 79 insertions(+) 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 90af45e2c..e1a8657b2 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -24,6 +24,11 @@ from openerp import _, models, fields, api, exceptions, release +MAX_RECORDS = 10000 +'''For possibly huge lists, only read chunks from the database in order to +avoid oom exceptions''' + + class XafAuditfileExport(models.Model): _name = 'xaf.auditfile.export' _description = 'XAF auditfile export' @@ -94,4 +99,19 @@ def button_generate(self): @api.multi def get_odoo_version(self): + '''return odoo version''' return release.version + + @api.multi + def get_partners(self): + '''return a generator over partners and suppliers''' + offset = 0 + while True: + results = self.env['res.partner'].search( + ['|', ('customer', '=', True), ('supplier', '=', True)], + offset=offset, limit=MAX_RECORDS) + if not results: + break + offset += MAX_RECORDS + for result in results: + yield result diff --git a/l10n_nl_xaf_auditfile_export/views/templates.xml b/l10n_nl_xaf_auditfile_export/views/templates.xml index 08ada073c..cdbe1f43b 100644 --- a/l10n_nl_xaf_auditfile_export/views/templates.xml +++ b/l10n_nl_xaf_auditfile_export/views/templates.xml @@ -13,6 +13,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + T + Last write + + + + From c15d4539556702169d464f4522c59680b559ead0 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 17 Feb 2015 16:57:18 +0100 Subject: [PATCH 003/112] [FIX] hide button if auditfile was generated --- .../views/templates.xml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/l10n_nl_xaf_auditfile_export/views/templates.xml b/l10n_nl_xaf_auditfile_export/views/templates.xml index cdbe1f43b..211270e75 100644 --- a/l10n_nl_xaf_auditfile_export/views/templates.xml +++ b/l10n_nl_xaf_auditfile_export/views/templates.xml @@ -72,6 +72,35 @@ + + + + + + + + + T + Last write + + + + From bd405a6b4af630e3a6443498af876a18bb91325c Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 17 Feb 2015 16:58:16 +0100 Subject: [PATCH 004/112] [ADD] export accounts --- l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py | 5 +++++ l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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 e1a8657b2..69ad5c054 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -115,3 +115,8 @@ def get_partners(self): offset += MAX_RECORDS for result in results: yield result + + @api.multi + def get_accounts(self): + '''return browse record list of accounts''' + return self.env['account.account'].search([]) diff --git a/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml b/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml index f0ab08c13..df39b8450 100644 --- a/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml +++ b/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml @@ -16,7 +16,7 @@
-
From be42cee1dd166f693d63275267435a11a0def2a8 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 18 Feb 2015 09:36:48 +0100 Subject: [PATCH 005/112] [IMP] better multicompany support --- l10n_nl_xaf_auditfile_export/__openerp__.py | 1 + l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py | 3 +-- l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/l10n_nl_xaf_auditfile_export/__openerp__.py b/l10n_nl_xaf_auditfile_export/__openerp__.py index b4e6301c7..38c709453 100644 --- a/l10n_nl_xaf_auditfile_export/__openerp__.py +++ b/l10n_nl_xaf_auditfile_export/__openerp__.py @@ -26,6 +26,7 @@ "category": "Accounting & Finance", "summary": "Export XAF auditfiles for Dutch tax authorities", "depends": [ + 'base', 'account', ], "data": [ 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 69ad5c054..3190904b7 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -49,8 +49,7 @@ def _auditfile_name_get(self): 'Auditfile filename', compute=_auditfile_name_get) date_generated = fields.Datetime( 'Date generated', readonly=True, copy=False) - company_id = fields.Many2one('res.company', 'Company', required=True, - readonly=True) + company_id = fields.Many2one('res.company', 'Company', required=True) @api.model def default_get(self, fields): diff --git a/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml b/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml index df39b8450..0de53852a 100644 --- a/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml +++ b/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml @@ -23,6 +23,7 @@ + From 41500cddc1300827469feea7451082746b96fcba Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 18 Feb 2015 09:38:43 +0100 Subject: [PATCH 006/112] [IMP] more multicompany support --- .../models/xaf_auditfile_export.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 3190904b7..862560149 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -107,7 +107,14 @@ def get_partners(self): offset = 0 while True: results = self.env['res.partner'].search( - ['|', ('customer', '=', True), ('supplier', '=', True)], + [ + '|', + ('customer', '=', True), + ('supplier', '=', True), + '|', + ('company_id', '=', False), + ('company_id', '=', self.company_id.id), + ], offset=offset, limit=MAX_RECORDS) if not results: break From be67d97ce1891d268d863cf9651fa96f2935d37f Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 18 Feb 2015 09:44:26 +0100 Subject: [PATCH 007/112] [IMP] read MAX_RECORDS from ir.config_parameter if available --- l10n_nl_xaf_auditfile_export/README.rst | 5 +++++ .../models/xaf_auditfile_export.py | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/l10n_nl_xaf_auditfile_export/README.rst b/l10n_nl_xaf_auditfile_export/README.rst index b351c04ec..c4ac8ffa9 100644 --- a/l10n_nl_xaf_auditfile_export/README.rst +++ b/l10n_nl_xaf_auditfile_export/README.rst @@ -19,6 +19,11 @@ 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. + Known issues / Roadmap ====================== 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 862560149..1683c2866 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -26,7 +26,9 @@ MAX_RECORDS = 10000 '''For possibly huge lists, only read chunks from the database in order to -avoid oom exceptions''' +avoid oom exceptions. +This is the default for ir.config_parameter +"l10n_nl_xaf_auditfile_export.max_records"''' class XafAuditfileExport(models.Model): @@ -115,7 +117,10 @@ def get_partners(self): ('company_id', '=', False), ('company_id', '=', self.company_id.id), ], - offset=offset, limit=MAX_RECORDS) + offset=offset, + limit=self.env['ir.config_parameter'].get_param( + 'l10n_nl_xaf_auditfile_export.max_records', + default=MAX_RECORDS)) if not results: break offset += MAX_RECORDS From 58ef0c62ab6b4ed203c8dcd0236ee41b251320ec Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 18 Feb 2015 09:50:41 +0100 Subject: [PATCH 008/112] [IMP] default to last fiscalyear if available --- .../models/xaf_auditfile_export.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 1683c2866..5a46ecb53 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -61,12 +61,20 @@ def default_get(self, fields): 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: defaults.setdefault('company_id', company.id) if 'name' in fields: defaults.setdefault( 'name', _('Auditfile %s %s') % ( - company.name, datetime.now().strftime('%Y'))) + 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: From 905174c8750b1f9aecbdf2ebd713d29d68f44f76 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 18 Feb 2015 11:40:39 +0100 Subject: [PATCH 009/112] [ADD] export transactions --- .../models/xaf_auditfile_export.py | 86 ++++++++++++++++++- .../views/templates.xml | 76 ++++++++++++++++ 2 files changed, 161 insertions(+), 1 deletion(-) 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 5a46ecb53..e1f7d298e 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -138,4 +138,88 @@ def get_partners(self): @api.multi def get_accounts(self): '''return browse record list of accounts''' - return self.env['account.account'].search([]) + return self.env['account.account'].search([ + '|', + ('company_id', '=', False), + ('company_id', '=', self.company_id.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', '=', False), + ('company_id', '=', self.company_id.id), + ]) + + @api.multi + def get_taxes(self): + '''return taxes''' + return self.env['account.tax'].search([ + '|', + ('company_id', '=', False), + ('company_id', '=', self.company_id.id), + ]) + + @api.multi + 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 ' + 'and (company_id=%s or company_id is null)', + (tuple(p.id for p in self.get_periods()), 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 ' + 'and (company_id=%s or company_id is null)', + (tuple(p.id for p in self.get_periods()), 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 ' + 'and (company_id=%s or company_id is null)', + (tuple(p.id for p in self.get_periods()), self.company_id.id)) + return self.env.cr.fetchall()[0][0] + + @api.multi + def get_journals(self): + '''return journals''' + return self.env['account.journal'].search([ + '|', + ('company_id', '=', False), + ('company_id', '=', self.company_id.id), + ]) + + @api.multi + 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), + ('journal_id', '=', journal.id), + '|', + ('company_id', '=', False), + ('company_id', '=', self.company_id.id), + ], + offset=offset, + limit=self.env['ir.config_parameter'].get_param( + 'l10n_nl_xaf_auditfile_export.max_records', + default=MAX_RECORDS)) + if not results: + break + offset += MAX_RECORDS + for result in results: + yield result diff --git a/l10n_nl_xaf_auditfile_export/views/templates.xml b/l10n_nl_xaf_auditfile_export/views/templates.xml index 211270e75..72c16a2fc 100644 --- a/l10n_nl_xaf_auditfile_export/views/templates.xml +++ b/l10n_nl_xaf_auditfile_export/views/templates.xml @@ -101,6 +101,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 01daa4c7048aa275981474aa7247837c1d0b8aa6 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 18 Feb 2015 13:37:21 +0100 Subject: [PATCH 010/112] [ADD] validation and don't output empty fields for enums --- .../models/xaf_auditfile_export.py | 34 ++++++++++++++++--- .../views/templates.xml | 6 ++-- 2 files changed, 32 insertions(+), 8 deletions(-) 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 e1f7d298e..05f1ea782 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -19,9 +19,10 @@ # ############################################################################## import base64 +from StringIO import StringIO from lxml import etree from datetime import datetime -from openerp import _, models, fields, api, exceptions, release +from openerp import _, models, fields, api, exceptions, release, modules MAX_RECORDS = 10000 @@ -95,14 +96,37 @@ def button_generate(self): .render(values={ 'self': self, }) - from_template = etree.fromstring(xml) + # the following is dealing with the fact that qweb templates don't like + # namespaces, but we need the correct namespaces for validation + # we inject them at parse time in order not to traverse the document + # multiple times + default_namespace = 'http://www.auditfiles.nl/XAF/3.2' + iterparse = etree.iterparse( + StringIO(xml), + remove_blank_text=True, remove_comments=True) + for action, element in iterparse: + element.tag = '{%s}%s' % (default_namespace, element.tag) + del xml xmldoc = etree.Element( - from_template.tag, + iterparse.root.tag, nsmap = { - None: 'http://www.auditfiles.nl/XAF/3.2', + None: default_namespace, 'xsi': 'http://www.w3.org/2001/XMLSchema-instance', }) - xmldoc[:] = from_template[:] + for element in iterparse.root: + xmldoc.append(element) + del iterparse + + xsd = etree.XMLSchema( + etree.parse( + file( + modules.get_module_resource( + 'l10n_nl_xaf_auditfile_export', 'data', + 'XmlAuditfileFinancieel3.2.xsd')))) + if not xsd.validate(xmldoc): + self.message_post('\n'.join(map(str, xsd.error_log))) + return + self.auditfile = base64.b64encode(etree.tostring( xmldoc, xml_declaration=True, encoding='utf8')) diff --git a/l10n_nl_xaf_auditfile_export/views/templates.xml b/l10n_nl_xaf_auditfile_export/views/templates.xml index 72c16a2fc..f982d8318 100644 --- a/l10n_nl_xaf_auditfile_export/views/templates.xml +++ b/l10n_nl_xaf_auditfile_export/views/templates.xml @@ -25,7 +25,7 @@ - + - + - + - + @@ -150,9 +150,9 @@ - + - + - + T Last write @@ -148,7 +147,7 @@ - + From c4b1a114cb1d9a74d1c59f9a1c3e765bfa728eaa Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 2 Jan 2018 14:11:55 +0100 Subject: [PATCH 030/112] [FIX] Cast config param to int #134 --- .../models/xaf_auditfile_export.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 29fcab274..0302f0cc1 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -134,9 +134,9 @@ def get_partners(self): ('company_id', '=', self.company_id.id), ], offset=offset, - limit=self.env['ir.config_parameter'].get_param( + limit=int(self.env['ir.config_parameter'].get_param( 'l10n_nl_xaf_auditfile_export.max_records', - default=MAX_RECORDS)) + default=MAX_RECORDS))) if not results: break offset += MAX_RECORDS @@ -254,9 +254,9 @@ def get_moves(self, journal): ('journal_id', '=', journal.id), ], offset=offset, - limit=self.env['ir.config_parameter'].get_param( + limit=int(self.env['ir.config_parameter'].get_param( 'l10n_nl_xaf_auditfile_export.max_records', - default=MAX_RECORDS)) + default=MAX_RECORDS))) if not results: break offset += MAX_RECORDS From 4c9eb1a665e684b6dacf44dec8af92c4c702f7ec Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Tue, 16 Jan 2018 07:12:34 +0100 Subject: [PATCH 031/112] OCA Transbot updated translations from Transifex --- l10n_nl_xaf_auditfile_export/i18n/nl.po | 28 +++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/l10n_nl_xaf_auditfile_export/i18n/nl.po b/l10n_nl_xaf_auditfile_export/i18n/nl.po index 0f3588254..fdc08c033 100644 --- a/l10n_nl_xaf_auditfile_export/i18n/nl.po +++ b/l10n_nl_xaf_auditfile_export/i18n/nl.po @@ -1,19 +1,22 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * l10n_nl_xaf_auditfile_export -# +# * l10n_nl_xaf_auditfile_export +# +# Translators: +# OCA Transbot , 2018 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0+e\n" +"Project-Id-Version: Odoo Server 11.0\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" +"POT-Creation-Date: 2018-01-16 06:04+0000\n" +"PO-Revision-Date: 2018-01-16 06:04+0000\n" +"Last-Translator: OCA Transbot , 2018\n" +"Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: \n" +"Language: nl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: l10n_nl_xaf_auditfile_export #: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_auditfile @@ -21,7 +24,7 @@ msgid "Auditfile" msgstr "Auditfile" #. module: l10n_nl_xaf_auditfile_export -#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:77 +#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:60 #, python-format msgid "Auditfile %s %s" msgstr "Auditfile %s %s" @@ -76,8 +79,8 @@ 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" +msgid "Fiscalyear Name" +msgstr "" #. module: l10n_nl_xaf_auditfile_export #: model:ir.ui.view,arch_db:l10n_nl_xaf_auditfile_export.form_xaf_auditfile_export @@ -139,7 +142,7 @@ msgid "Start date" msgstr "Startdatum" #. module: l10n_nl_xaf_auditfile_export -#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:88 +#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:72 #, python-format msgid "Starting date must be anterior ending date!" msgstr "Startdatum moet liggen voor de einddatum!" @@ -183,4 +186,3 @@ msgstr "ir.qweb.field.auditfile.string9" #: 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" - From eb2d308fa8ba2a55436c19d3ede4e0a174a6275f Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Wed, 17 Jan 2018 01:32:24 +0100 Subject: [PATCH 032/112] OCA Transbot updated translations from Transifex --- l10n_nl_xaf_auditfile_export/i18n/nl.po | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/l10n_nl_xaf_auditfile_export/i18n/nl.po b/l10n_nl_xaf_auditfile_export/i18n/nl.po index fdc08c033..2889dcfd1 100644 --- a/l10n_nl_xaf_auditfile_export/i18n/nl.po +++ b/l10n_nl_xaf_auditfile_export/i18n/nl.po @@ -4,13 +4,14 @@ # # Translators: # OCA Transbot , 2018 +# Frank Schellenberg , 2018 msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-01-16 06:04+0000\n" -"PO-Revision-Date: 2018-01-16 06:04+0000\n" -"Last-Translator: OCA Transbot , 2018\n" +"POT-Creation-Date: 2018-01-16 06:23+0000\n" +"PO-Revision-Date: 2018-01-16 06:23+0000\n" +"Last-Translator: Frank Schellenberg , 2018\n" "Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -80,7 +81,7 @@ 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 "" +msgstr "Naam Fiscaal Jaar" #. module: l10n_nl_xaf_auditfile_export #: model:ir.ui.view,arch_db:l10n_nl_xaf_auditfile_export.form_xaf_auditfile_export From 7d8dfd552d71849ade4d2123e1517cc2c0cbfe00 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 16 Jan 2018 20:41:42 +0100 Subject: [PATCH 033/112] [FIX] SQL --- .../models/xaf_auditfile_export.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 0302f0cc1..f79ec3603 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -207,8 +207,8 @@ def get_move_line_count(self): '''return amount of move lines''' self.env.cr.execute( 'select count(*) from account_move_line ' - 'where date >= \'%s\' ' - 'and date <= \'%s\' ' + 'where date >= %s ' + 'and date <= %s ' 'and (company_id=%s or company_id is null)', (self.date_start, self.date_end, self.company_id.id, )) return self.env.cr.fetchall()[0][0] @@ -218,8 +218,8 @@ 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 date >= \'%s\' ' - 'and date <= \'%s\' ' + 'where date >= %s ' + 'and date <= %s ' 'and (company_id=%s or company_id is null)', (self.date_start, self.date_end, self.company_id.id, )) return self.env.cr.fetchall()[0][0] @@ -229,8 +229,8 @@ 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 date >= \'%s\' ' - 'and date <= \'%s\' ' + 'where date >= %s ' + 'and date <= %s ' 'and (company_id=%s or company_id is null)', (self.date_start, self.date_end, self.company_id.id, )) return self.env.cr.fetchall()[0][0] From 7594dd94541d12471c85603ef6cacd14cab6c6aa Mon Sep 17 00:00:00 2001 From: "Yenthe V.G" Date: Tue, 6 Mar 2018 09:07:09 +0100 Subject: [PATCH 034/112] [FIX] l10n_nl_xaf_auditfile_export: fix rounding issues --- l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 f79ec3603..e68a22a3f 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -222,7 +222,7 @@ def get_move_line_total_debit(self): 'and date <= %s ' 'and (company_id=%s or company_id is null)', (self.date_start, self.date_end, self.company_id.id, )) - return self.env.cr.fetchall()[0][0] + return round(self.env.cr.fetchall()[0][0], 2) @api.multi def get_move_line_total_credit(self): @@ -233,7 +233,7 @@ def get_move_line_total_credit(self): 'and date <= %s ' 'and (company_id=%s or company_id is null)', (self.date_start, self.date_end, self.company_id.id, )) - return self.env.cr.fetchall()[0][0] + return round(self.env.cr.fetchall()[0][0], 2) @api.multi def get_journals(self): From 356a12aba79e22c181dd1cbbafa9f90a1439a187 Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 28 Jun 2018 21:44:58 +0200 Subject: [PATCH 035/112] [11.0][FIX] Allow access to historical XAF files --- l10n_nl_xaf_auditfile_export/__manifest__.py | 2 +- l10n_nl_xaf_auditfile_export/readme/CONFIGURE.rst | 9 +++++++++ l10n_nl_xaf_auditfile_export/readme/CONTRIBUTORS.rst | 2 ++ l10n_nl_xaf_auditfile_export/readme/CREDITS.rst | 4 ++++ l10n_nl_xaf_auditfile_export/readme/DESCRIPTION.rst | 3 +++ l10n_nl_xaf_auditfile_export/readme/ROADMAP.rst | 1 + l10n_nl_xaf_auditfile_export/readme/USAGE.rst | 7 +++++++ .../views/xaf_auditfile_export.xml | 3 ++- 8 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 l10n_nl_xaf_auditfile_export/readme/CONFIGURE.rst create mode 100644 l10n_nl_xaf_auditfile_export/readme/CONTRIBUTORS.rst create mode 100644 l10n_nl_xaf_auditfile_export/readme/CREDITS.rst create mode 100644 l10n_nl_xaf_auditfile_export/readme/DESCRIPTION.rst create mode 100644 l10n_nl_xaf_auditfile_export/readme/ROADMAP.rst create mode 100644 l10n_nl_xaf_auditfile_export/readme/USAGE.rst diff --git a/l10n_nl_xaf_auditfile_export/__manifest__.py b/l10n_nl_xaf_auditfile_export/__manifest__.py index e8af82bf4..7691e43a5 100644 --- a/l10n_nl_xaf_auditfile_export/__manifest__.py +++ b/l10n_nl_xaf_auditfile_export/__manifest__.py @@ -3,7 +3,7 @@ { "name": "XAF auditfile export", - "version": "11.0.1.0.0", + "version": "11.0.1.0.1", "author": "Therp BV, Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Accounting & Finance", diff --git a/l10n_nl_xaf_auditfile_export/readme/CONFIGURE.rst b/l10n_nl_xaf_auditfile_export/readme/CONFIGURE.rst new file mode 100644 index 000000000..aabfd64ef --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/readme/CONFIGURE.rst @@ -0,0 +1,9 @@ +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. diff --git a/l10n_nl_xaf_auditfile_export/readme/CONTRIBUTORS.rst b/l10n_nl_xaf_auditfile_export/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..c8cae4be0 --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Holger Brunn +* Andrea Stirpe diff --git a/l10n_nl_xaf_auditfile_export/readme/CREDITS.rst b/l10n_nl_xaf_auditfile_export/readme/CREDITS.rst new file mode 100644 index 000000000..91349200b --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/readme/CREDITS.rst @@ -0,0 +1,4 @@ +Icon +---- + +https://openclipart.org/detail/180891 diff --git a/l10n_nl_xaf_auditfile_export/readme/DESCRIPTION.rst b/l10n_nl_xaf_auditfile_export/readme/DESCRIPTION.rst new file mode 100644 index 000000000..27eeef6ae --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module allows you to export XAF audit files for the Dutch tax authorities (Belastingdienst). + +The currently exported version is 3.2 diff --git a/l10n_nl_xaf_auditfile_export/readme/ROADMAP.rst b/l10n_nl_xaf_auditfile_export/readme/ROADMAP.rst new file mode 100644 index 000000000..d1c9d033e --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/readme/ROADMAP.rst @@ -0,0 +1 @@ +* encrypted and compressed files would be nice diff --git a/l10n_nl_xaf_auditfile_export/readme/USAGE.rst b/l10n_nl_xaf_auditfile_export/readme/USAGE.rst new file mode 100644 index 000000000..e15dbd529 --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/readme/USAGE.rst @@ -0,0 +1,7 @@ +To use this module, you need to: + +* 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` diff --git a/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml b/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml index 27d5853f2..8c0804984 100644 --- a/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml +++ b/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml @@ -8,6 +8,7 @@ + @@ -49,7 +50,7 @@ xaf.auditfile.export tree,form form - + current From 5c0e00147dea6163af2b58b9f5b954324fec9f89 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Tue, 3 Jul 2018 10:33:51 +0000 Subject: [PATCH 036/112] [UPD] Update l10n_nl_xaf_auditfile_export.pot --- .../i18n/l10n_nl_xaf_auditfile_export.pot | 184 ++++++++++++++++++ l10n_nl_xaf_auditfile_export/i18n/nl.po | 4 +- l10n_nl_xaf_auditfile_export/i18n/nl_NL.po | 13 +- 3 files changed, 193 insertions(+), 8 deletions(-) create mode 100644 l10n_nl_xaf_auditfile_export/i18n/l10n_nl_xaf_auditfile_export.pot 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 new file mode 100644 index 000000000..8b924498f --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/i18n/l10n_nl_xaf_auditfile_export.pot @@ -0,0 +1,184 @@ +# 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 11.0\n" +"Report-Msgid-Bugs-To: \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 "" + +#. module: l10n_nl_xaf_auditfile_export +#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:60 +#, python-format +msgid "Auditfile %s %s" +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 +#: model:ir.model.fields,field_description:l10n_nl_xaf_auditfile_export.field_xaf_auditfile_export_auditfile_name +msgid "Auditfile filename" +msgstr "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.ui.view,arch_db:l10n_nl_xaf_auditfile_export.auditfile_template +msgid "Last write" +msgstr "" + +#. 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 "" + +#. module: l10n_nl_xaf_auditfile_export +#: model:ir.ui.view,arch_db:l10n_nl_xaf_auditfile_export.auditfile_template +msgid "Odoo" +msgstr "" + +#. 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 "" + +#. module: l10n_nl_xaf_auditfile_export +#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:72 +#, python-format +msgid "Starting date must be anterior ending date!" +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_field_auditfile_string10 +msgid "ir.qweb.field.auditfile.string10" +msgstr "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + diff --git a/l10n_nl_xaf_auditfile_export/i18n/nl.po b/l10n_nl_xaf_auditfile_export/i18n/nl.po index 2889dcfd1..d5b972ec1 100644 --- a/l10n_nl_xaf_auditfile_export/i18n/nl.po +++ b/l10n_nl_xaf_auditfile_export/i18n/nl.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * l10n_nl_xaf_auditfile_export -# +# # Translators: # OCA Transbot , 2018 # Frank Schellenberg , 2018 @@ -13,10 +13,10 @@ msgstr "" "PO-Revision-Date: 2018-01-16 06:23+0000\n" "Last-Translator: Frank Schellenberg , 2018\n" "Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" +"Language: nl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: nl\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: l10n_nl_xaf_auditfile_export diff --git a/l10n_nl_xaf_auditfile_export/i18n/nl_NL.po b/l10n_nl_xaf_auditfile_export/i18n/nl_NL.po index 8032677cb..a6d32b8c8 100644 --- a/l10n_nl_xaf_auditfile_export/i18n/nl_NL.po +++ b/l10n_nl_xaf_auditfile_export/i18n/nl_NL.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * l10n_nl_xaf_auditfile_export -# +# # Translators: # Peter Hageman , 2017 msgid "" @@ -11,11 +11,12 @@ msgstr "" "POT-Creation-Date: 2017-06-04 06:46+0000\n" "PO-Revision-Date: 2017-06-04 06:46+0000\n" "Last-Translator: Peter Hageman , 2017\n" -"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: nl_NL\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: l10n_nl_xaf_auditfile_export @@ -24,7 +25,7 @@ msgid "Auditfile" msgstr "" #. module: l10n_nl_xaf_auditfile_export -#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:77 +#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:60 #, python-format msgid "Auditfile %s %s" msgstr "" @@ -79,7 +80,7 @@ msgstr "" #. 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" +msgid "Fiscalyear Name" msgstr "" #. module: l10n_nl_xaf_auditfile_export @@ -142,7 +143,7 @@ msgid "Start date" msgstr "" #. module: l10n_nl_xaf_auditfile_export -#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:88 +#: code:addons/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py:72 #, python-format msgid "Starting date must be anterior ending date!" msgstr "" From a08c9e7abbbb1f960ac8124d374dd8111bfb1f7e Mon Sep 17 00:00:00 2001 From: OCA Git Bot Date: Wed, 4 Jul 2018 05:05:58 +0200 Subject: [PATCH 037/112] [UPD] README.rst --- l10n_nl_xaf_auditfile_export/README.rst | 76 +-- .../static/description/index.html | 462 ++++++++++++++++++ 2 files changed, 510 insertions(+), 28 deletions(-) create mode 100644 l10n_nl_xaf_auditfile_export/static/description/index.html diff --git a/l10n_nl_xaf_auditfile_export/README.rst b/l10n_nl_xaf_auditfile_export/README.rst index 16aba2766..93d9efd61 100644 --- a/l10n_nl_xaf_auditfile_export/README.rst +++ b/l10n_nl_xaf_auditfile_export/README.rst @@ -1,15 +1,39 @@ -.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png - :target: https://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 - ==================== XAF auditfile export ==================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--netherlands-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-netherlands/tree/11.0/l10n_nl_xaf_auditfile_export + :alt: OCA/l10n-netherlands +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-netherlands-11-0/l10n-netherlands-11-0-l10n_nl_xaf_auditfile_export + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/176/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + This module allows you to export XAF audit files for the Dutch tax authorities (Belastingdienst). The currently exported version is 3.2 +**Table of contents** + +.. contents:: + :local: + Configuration ============= @@ -34,60 +58,56 @@ To use this module, you need to: * click `Generate auditfile` * click `Download` on the field `Auditfile` -For further information, please visit: - -* https://www.odoo.com/forum/help-1 - -.. 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/11.0 - Known issues / Roadmap ====================== * encrypted and compressed files would be nice - 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 smash it by providing detailed and welcomed feedback. +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 `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Therp BV + Contributors ------------- +~~~~~~~~~~~~ * Holger Brunn * Andrea Stirpe -Do not contact contributors directly about support or help with technical issues. +Other credits +~~~~~~~~~~~~~ Icon ---- https://openclipart.org/detail/180891 -Documentation -------------- - -http://www.softwarepakket.nl/swpakketten/auditfiles/auditfile_financieel.php?bronw=6 +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. .. 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. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/l10n-netherlands `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_nl_xaf_auditfile_export/static/description/index.html b/l10n_nl_xaf_auditfile_export/static/description/index.html new file mode 100644 index 000000000..97feafce7 --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/static/description/index.html @@ -0,0 +1,462 @@ + + + + + + +XAF auditfile export + + + +
+

XAF auditfile export

+ + +

Beta License: AGPL-3 OCA/l10n-netherlands Translate me on Weblate Try me on Runbot

+

This module allows you to export XAF audit files for the Dutch tax authorities (Belastingdienst).

+

The currently exported version is 3.2

+

Table of contents

+ +
+

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:

+
    +
  • 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
  • +
+
+
+

Known issues / Roadmap

+
    +
  • encrypted and compressed files would be nice
  • +
+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Therp BV
  • +
+
+
+

Contributors

+ +
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/l10n-netherlands project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + From 17be57aa112d2ae21bd76d3ff308c4b580eb3f05 Mon Sep 17 00:00:00 2001 From: Andrea Stirpe Date: Tue, 31 Jul 2018 14:44:03 +0200 Subject: [PATCH 038/112] [11.0][IMP] l10n_nl_xaf_auditfile_export: ease extensions (#182) * Extract method to ease extensions * Add basic tests * Make filename field stored + code review * Add group in view for extra options --- l10n_nl_xaf_auditfile_export/__manifest__.py | 2 +- .../models/xaf_auditfile_export.py | 18 +++++-- .../tests/__init__.py | 3 ++ .../test_l10n_nl_xaf_auditfile_export.py | 51 +++++++++++++++++++ .../views/xaf_auditfile_export.xml | 2 + 5 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 l10n_nl_xaf_auditfile_export/tests/__init__.py create mode 100644 l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py diff --git a/l10n_nl_xaf_auditfile_export/__manifest__.py b/l10n_nl_xaf_auditfile_export/__manifest__.py index 7691e43a5..713468da1 100644 --- a/l10n_nl_xaf_auditfile_export/__manifest__.py +++ b/l10n_nl_xaf_auditfile_export/__manifest__.py @@ -3,7 +3,7 @@ { "name": "XAF auditfile export", - "version": "11.0.1.0.1", + "version": "11.0.1.1.0", "author": "Therp BV, Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Accounting & Finance", 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 e68a22a3f..2e32d5436 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -24,8 +24,9 @@ class XafAuditfileExport(models.Model): _order = 'date_start desc' @api.depends('name') - def _auditfile_name_get(self): - self.auditfile_name = '%s.xaf' % self.name + def _compute_auditfile_name(self): + for item in self: + item.auditfile_name = '%s.xaf' % item.name @api.multi def _compute_fiscalyear_name(self): @@ -39,7 +40,10 @@ def _compute_fiscalyear_name(self): 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) + 'Auditfile filename', + compute='_compute_auditfile_name', + store=True + ) date_generated = fields.Datetime( 'Date generated', readonly=True, copy=False) company_id = fields.Many2one('res.company', 'Company', required=True) @@ -71,11 +75,17 @@ def check_dates(self): raise exceptions.ValidationError( _('Starting date must be anterior ending date!')) + @api.multi + def _get_auditfile_template(self): + '''return the qweb template to be rendered''' + return "l10n_nl_xaf_auditfile_export.auditfile_template" + @api.multi def button_generate(self): self.date_generated = fields.Datetime.now(self) + auditfile_template = self._get_auditfile_template() xml = self.env['ir.ui.view'].render_template( - "l10n_nl_xaf_auditfile_export.auditfile_template", + auditfile_template, values={ 'self': self, }, diff --git a/l10n_nl_xaf_auditfile_export/tests/__init__.py b/l10n_nl_xaf_auditfile_export/tests/__init__.py new file mode 100644 index 000000000..8c1ca88d5 --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_l10n_nl_xaf_auditfile_export diff --git a/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py b/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py new file mode 100644 index 000000000..d39e3a7c9 --- /dev/null +++ b/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py @@ -0,0 +1,51 @@ +# Copyright 2018 Onestein () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import TransactionCase + + +class TestXafAuditfileExport(TransactionCase): + + def test_01_default_values(self): + ''' Check that the default values are filled on creation ''' + record = self.env['xaf.auditfile.export'].create({}) + + self.assertTrue(record) + self.assertTrue(record.name) + self.assertFalse(record.auditfile) + self.assertTrue(record.auditfile_name) + self.assertTrue(record.company_id) + self.assertTrue(record.date_start) + self.assertTrue(record.date_end) + self.assertFalse(record.date_generated) + self.assertTrue(record.fiscalyear_name) + + def test_02_export_success(self): + ''' Do a basic auditfile export ''' + record = self.env['xaf.auditfile.export'].create({}) + record.button_generate() + + self.assertTrue(record.name) + self.assertTrue(record.auditfile) + self.assertTrue(record.auditfile_name) + self.assertTrue(record.company_id) + self.assertTrue(record.date_start) + self.assertTrue(record.date_end) + self.assertTrue(record.date_generated) + self.assertTrue(record.fiscalyear_name) + + def test_03_export_error(self): + ''' Failure to export an auditfile ''' + record = self.env['xaf.auditfile.export'].create({}) + record.company_id.country_id = False + record.button_generate() + + self.assertTrue(record) + self.assertTrue(record.name) + self.assertFalse(record.auditfile) + self.assertTrue(record.auditfile_name) + self.assertTrue(record.company_id) + self.assertTrue(record.date_start) + self.assertTrue(record.date_end) + self.assertTrue(record.date_generated) + self.assertTrue(record.fiscalyear_name) diff --git a/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml b/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml index 8c0804984..15be4cb31 100644 --- a/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml +++ b/l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml @@ -31,6 +31,8 @@
+ + From 3fedcf686210749ccba8e8540fff2fc0b135cb6c Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Fri, 27 Jul 2018 14:30:18 +0200 Subject: [PATCH 039/112] [IMP] Memory footprint, speed and disk space Generating and storing a 70MB auditfile takes 8 minutes for qweb, but for lxml.etree to reconstruct using a namespace takes 3 hours and 1GB of extra memory. Further optimization is achieved by sticking to the Odoo prefetch size when chunking record sets. As XML compresses very well, the auditfile is now stored in the Odoo database in compressed format for easier handling and saving disk space. --- .../models/xaf_auditfile_export.py | 165 +++++++++--------- .../readme/CONFIGURE.rst | 2 - .../readme/CONTRIBUTORS.rst | 1 + .../readme/ROADMAP.rst | 2 +- .../test_l10n_nl_xaf_auditfile_export.py | 10 ++ 5 files changed, 98 insertions(+), 82 deletions(-) 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 2e32d5436..d285f6f1c 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -3,18 +3,32 @@ import base64 import collections -from io import BytesIO from lxml import etree +import logging +import os +import psutil +import shutil +from tempfile import mkdtemp +import time from datetime import datetime, timedelta from dateutil.rrule import rrule, MONTHLY + from odoo import _, models, fields, api, exceptions, release, modules -MAX_RECORDS = 10000 -'''For possibly huge lists, only read chunks from the database in order to -avoid oom exceptions. -This is the default for ir.config_parameter -"l10n_nl_xaf_auditfile_export.max_records"''' +def chunks(l, n=None): + """Yield successive n-sized chunks from l.""" + if n is None: + n = models.PREFETCH_MAX + for i in range(0, len(l), n): + yield l[i:i + n] + + +def memory_info(): + """ Modified from odoo/server/service.py """ + process = psutil.Process(os.getpid()) + pmem = (getattr(process, 'memory_info', None) or process.get_memory_info)() + return pmem.vms class XafAuditfileExport(models.Model): @@ -82,6 +96,8 @@ def _get_auditfile_template(self): @api.multi def button_generate(self): + t0 = time.time() + m0 = memory_info() self.date_generated = fields.Datetime.now(self) auditfile_template = self._get_auditfile_template() xml = self.env['ir.ui.view'].render_template( @@ -92,37 +108,47 @@ def button_generate(self): ) # the following is dealing with the fact that qweb templates don't like # namespaces, but we need the correct namespaces for validation - # we inject them at parse time in order not to traverse the document - # multiple times - default_namespace = 'http://www.auditfiles.nl/XAF/3.2' - iterparse = etree.iterparse( - BytesIO(xml), - remove_blank_text=True, remove_comments=True) - for action, element in iterparse: - element.tag = '{%s}%s' % (default_namespace, element.tag) - del xml - xmldoc = etree.Element( - iterparse.root.tag, - nsmap={ - None: default_namespace, - 'xsi': 'http://www.w3.org/2001/XMLSchema-instance', - }) - for element in iterparse.root: - xmldoc.append(element) - del iterparse - - xsd = etree.XMLSchema( - etree.parse( - open( - modules.get_module_resource( - 'l10n_nl_xaf_auditfile_export', 'data', - 'XmlAuditfileFinancieel3.2.xsd')))) - if not xsd.validate(xmldoc): - self.message_post('

\n'.join(map(str, xsd.error_log))) - return - - self.auditfile = base64.b64encode(etree.tostring( - xmldoc, xml_declaration=True, encoding='UTF-8')) + xml = xml.decode().strip().replace( + '', + '' + '', 1) + + filename = self.name + '.xaf' + tmpdir = mkdtemp() + auditfile = os.path.join(tmpdir, filename) + archivedir = mkdtemp() + archive = os.path.join(archivedir, filename) + try: + with open(auditfile, 'w+') as tmphandle: + tmphandle.write(xml) + del xml + + # Validate the generated XML + xsd = etree.XMLParser( + schema=etree.XMLSchema(etree.parse( + open( + modules.get_module_resource( + 'l10n_nl_xaf_auditfile_export', 'data', + 'XmlAuditfileFinancieel3.2.xsd'))))) + etree.parse(auditfile, parser=xsd) + del xsd + + # Store in compressed format on the auditfile record + zip_path = shutil.make_archive( + archive, 'zip', tmpdir, verbose=True) + with open(zip_path, 'rb') as auditfile_zip: + self.auditfile = base64.b64encode(auditfile_zip.read()) + logging.getLogger(__name__).debug( + 'Created an auditfile in %ss, using %sk memory', + int(time.time() - t0), (memory_info() - m0) / 1024) + + except etree.XMLSyntaxError as e: + logging.getLogger(__name__).error(e) + self.message_post(e) + finally: + shutil.rmtree(tmpdir) + shutil.rmtree(archivedir) @api.multi def get_odoo_version(self): @@ -131,29 +157,20 @@ def get_odoo_version(self): @api.multi def get_partners(self): - '''return a generator over partners and suppliers''' - offset = 0 - while True: - results = self.env['res.partner'].search( - [ - '|', - ('customer', '=', True), - ('supplier', '=', True), - '|', - ('company_id', '=', False), - ('company_id', '=', self.company_id.id), - ], - offset=offset, - limit=int(self.env['ir.config_parameter'].get_param( - 'l10n_nl_xaf_auditfile_export.max_records', - default=MAX_RECORDS))) - if not results: - break - offset += MAX_RECORDS - for result in results: - yield result - results.env.cache.invalidate() - del results + '''return a generator over partners''' + partner_ids = self.env['res.partner'].search([ + '|', + ('customer', '=', True), + ('supplier', '=', True), + '|', + ('company_id', '=', False), + ('company_id', '=', self.company_id.id), + ]).ids + self.env.cache.invalidate() + for chunk in chunks(partner_ids): + for partner in self.env['res.partner'].browse(chunk): + yield partner + self.env.cache.invalidate() @api.multi def get_accounts(self): @@ -255,25 +272,15 @@ def get_journals(self): @api.multi def get_moves(self, journal): '''return moves for a journal, generator style''' - offset = 0 - while True: - results = self.env['account.move'].search( - [ - ('date', '>=', self.date_start), - ('date', '<=', self.date_end), - ('journal_id', '=', journal.id), - ], - offset=offset, - limit=int(self.env['ir.config_parameter'].get_param( - 'l10n_nl_xaf_auditfile_export.max_records', - default=MAX_RECORDS))) - if not results: - break - offset += MAX_RECORDS - for result in results: - yield result - results.env.cache.invalidate() - del results + move_ids = self.env['account.move'].search([ + ('date', '>=', self.date_start), + ('date', '<=', self.date_end), + ('journal_id', '=', journal.id)]).ids + self.env.cache.invalidate() + for chunk in chunks(move_ids): + for move in self.env['account.move'].browse(chunk): + yield move + self.env.cache.invalidate() @api.model def get_move_period_number(self, move): diff --git a/l10n_nl_xaf_auditfile_export/readme/CONFIGURE.rst b/l10n_nl_xaf_auditfile_export/readme/CONFIGURE.rst index aabfd64ef..3f0d08345 100644 --- a/l10n_nl_xaf_auditfile_export/readme/CONFIGURE.rst +++ b/l10n_nl_xaf_auditfile_export/readme/CONFIGURE.rst @@ -5,5 +5,3 @@ last date of the year you want to export. Then in the form of the audit file exp 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. diff --git a/l10n_nl_xaf_auditfile_export/readme/CONTRIBUTORS.rst b/l10n_nl_xaf_auditfile_export/readme/CONTRIBUTORS.rst index c8cae4be0..c4b3a740c 100644 --- a/l10n_nl_xaf_auditfile_export/readme/CONTRIBUTORS.rst +++ b/l10n_nl_xaf_auditfile_export/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Holger Brunn * Andrea Stirpe +* Stefan Rijnhart diff --git a/l10n_nl_xaf_auditfile_export/readme/ROADMAP.rst b/l10n_nl_xaf_auditfile_export/readme/ROADMAP.rst index d1c9d033e..f56aa14a1 100644 --- a/l10n_nl_xaf_auditfile_export/readme/ROADMAP.rst +++ b/l10n_nl_xaf_auditfile_export/readme/ROADMAP.rst @@ -1 +1 @@ -* encrypted and compressed files would be nice +* encrypted files would be nice diff --git a/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py b/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py index d39e3a7c9..7b5381cce 100644 --- a/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py @@ -1,6 +1,10 @@ # Copyright 2018 Onestein () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import base64 +from io import BytesIO +from zipfile import ZipFile + from odoo.tests.common import TransactionCase @@ -34,6 +38,12 @@ def test_02_export_success(self): self.assertTrue(record.date_generated) self.assertTrue(record.fiscalyear_name) + zf = BytesIO(base64.b64decode(record.auditfile)) + with ZipFile(zf, 'r') as archive: + filelist = archive.filelist + contents = archive.read(filelist[-1]).decode() + self.assertTrue(contents.startswith(' Date: Mon, 30 Jul 2018 08:39:05 +0200 Subject: [PATCH 040/112] Adapt method and tests --- l10n_nl_xaf_auditfile_export/__manifest__.py | 2 +- .../models/xaf_auditfile_export.py | 9 ++++++++- .../tests/test_l10n_nl_xaf_auditfile_export.py | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/l10n_nl_xaf_auditfile_export/__manifest__.py b/l10n_nl_xaf_auditfile_export/__manifest__.py index 713468da1..8a0cfc42e 100644 --- a/l10n_nl_xaf_auditfile_export/__manifest__.py +++ b/l10n_nl_xaf_auditfile_export/__manifest__.py @@ -3,7 +3,7 @@ { "name": "XAF auditfile export", - "version": "11.0.1.1.0", + "version": "11.0.1.2.0", "author": "Therp BV, Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Accounting & Finance", 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 d285f6f1c..12316c04a 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -9,6 +9,8 @@ import psutil import shutil from tempfile import mkdtemp +from io import BytesIO +import zipfile import time from datetime import datetime, timedelta from dateutil.rrule import rrule, MONTHLY @@ -37,10 +39,15 @@ class XafAuditfileExport(models.Model): _inherit = ['mail.thread'] _order = 'date_start desc' - @api.depends('name') + @api.depends('name', 'auditfile') def _compute_auditfile_name(self): for item in self: item.auditfile_name = '%s.xaf' % item.name + if item.auditfile: + auditfile = base64.b64decode(item.auditfile) + zf = BytesIO(auditfile) + if zipfile.is_zipfile(zf): + item.auditfile_name += '.zip' @api.multi def _compute_fiscalyear_name(self): diff --git a/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py b/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py index 7b5381cce..c75f12cec 100644 --- a/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py @@ -5,6 +5,7 @@ from io import BytesIO from zipfile import ZipFile +from odoo.tools import mute_logger from odoo.tests.common import TransactionCase @@ -44,6 +45,9 @@ def test_02_export_success(self): contents = archive.read(filelist[-1]).decode() self.assertTrue(contents.startswith(' Date: Wed, 1 Aug 2018 14:48:53 +0200 Subject: [PATCH 041/112] Avoid warning (in dev mode) --- .../views/templates.xml | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/l10n_nl_xaf_auditfile_export/views/templates.xml b/l10n_nl_xaf_auditfile_export/views/templates.xml index 8a15f5caa..aab194f39 100644 --- a/l10n_nl_xaf_auditfile_export/views/templates.xml +++ b/l10n_nl_xaf_auditfile_export/views/templates.xml @@ -4,27 +4,27 @@