Skip to content

Commit

Permalink
[16.0][MIG] l10n_nl_xaf_auditfile_export
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe committed Jan 17, 2023
1 parent 9e5b4c0 commit a4f5d20
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 49 deletions.
16 changes: 8 additions & 8 deletions l10n_nl_xaf_auditfile_export/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ XAF auditfile export
: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/14.0/l10n_nl_xaf_auditfile_export
:target: https://github.com/OCA/l10n-netherlands/tree/16.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-14-0/l10n-netherlands-14-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/14.0
:target: https://runbot.odoo-community.org/runbot/176/16.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
|badge1| |badge2| |badge3| |badge4| |badge5|

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

Expand All @@ -39,7 +39,7 @@ An option allows to export the XAF audit files in a format that is accepted by U
Configuration
=============

The exporting feature is available to the users who have `Accountant` or `Adviser` rights for accounting.
The exporting feature is available to the users who have `Billing Administrator` or `Accountant` 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
Expand All @@ -52,8 +52,8 @@ 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`
* be sure that you have `Billing Administrator` or `Accountant` rights for accounting
* go to `Invoicing`/`Reporting`/`Auditfile export`
* create a new record, adjust values if the defaults are not appropriate
* click `Generate auditfile`
* click `Download` on the field `Auditfile`
Expand All @@ -69,7 +69,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-netherlands/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 <https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_xaf_auditfile_export%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_xaf_auditfile_export%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Expand Down Expand Up @@ -110,6 +110,6 @@ 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 <https://github.com/OCA/l10n-netherlands/tree/14.0/l10n_nl_xaf_auditfile_export>`_ project on GitHub.
This module is part of the `OCA/l10n-netherlands <https://github.com/OCA/l10n-netherlands/tree/16.0/l10n_nl_xaf_auditfile_export>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion l10n_nl_xaf_auditfile_export/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "XAF auditfile export",
"version": "15.0.1.3.0",
"version": "16.0.1.0.0",
"author": "Therp BV, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-netherlands",
"license": "AGPL-3",
Expand Down
39 changes: 16 additions & 23 deletions l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,16 @@ def button_generate(self):
m0 = memory_info()
self.date_generated = fields.Datetime.now()
auditfile_template = self._get_auditfile_template()
xml = self.env["ir.ui.view"]._render_template(
auditfile_template, values={"self": self}
xml = self.env["ir.qweb"]._render(
auditfile_template, {"self": self}, minimal_qcontext=True
)
# the following is dealing with the fact that qweb templates don't like
# namespaces, but we need the correct namespaces for validation
# convert to string and prepend XML encoding declaration
xml = (
xml.decode()
xml.unescape()
.strip()
.replace(
"<auditfile>",
'<?xml version="1.0" encoding="UTF-8"?>'
'<auditfile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
'xmlns="http://www.auditfiles.nl/XAF/3.2">',
"<auditfile ",
'<?xml version="1.0" encoding="UTF-8"?>\n<auditfile ',
1,
)
)
Expand Down Expand Up @@ -198,11 +195,11 @@ def get_partners(self):
)
.ids
)
self.env.cache.invalidate()
self.env["res.partner"].invalidate_model()
for chunk in chunks(partner_ids):
for partner in self.env["res.partner"].browse(chunk):
yield partner
self.env.cache.invalidate()
self.env["res.partner"].invalidate_model()

def get_accounts(self):
"""return recordset of accounts"""
Expand Down Expand Up @@ -257,14 +254,12 @@ def get_ob_totals(self):
"""return totals of opening balance"""
self.env.cr.execute(
"select sum(l.credit), sum(l.debit), count(distinct a.id) "
"from account_move_line l, account_account a, "
" account_account_type t "
"where a.user_type_id = t.id "
"and l.account_id = a.id "
"from account_move_line l, account_account a "
"where l.account_id = a.id "
"and l.parent_state = 'posted' "
"and l.date < %s "
"and l.company_id=%s "
"and t.include_initial_balance = true ",
"and a.include_initial_balance = true ",
(self.date_start, self.company_id.id),
)
row = self.env.cr.fetchall()[0]
Expand All @@ -278,13 +273,11 @@ def get_ob_lines(self):
"""return opening balance entries"""
self.env.cr.execute(
"select a.id, a.code, sum(l.balance) "
"from account_move_line l, account_account a, "
" account_account_type t "
"where a.user_type_id = t.id "
"and a.id = l.account_id and l.date < %s "
"from account_move_line l, account_account a "
"where a.id = l.account_id and l.date < %s "
"and l.company_id=%s "
"and l.parent_state = 'posted' "
"and t.include_initial_balance = true "
"and a.include_initial_balance = true "
"group by a.id, a.code",
(self.date_start, self.company_id.id),
)
Expand Down Expand Up @@ -353,11 +346,11 @@ def get_moves(self, journal):
)
.ids
)
self.env.cache.invalidate()
self.env["account.move"].invalidate_model()
for chunk in chunks(move_ids):
for move in self.env["account.move"].browse(chunk):
yield move
self.env.cache.invalidate()
self.env["account.move"].invalidate_model()

@api.model
def get_move_period_number(self, move):
Expand Down
12 changes: 6 additions & 6 deletions l10n_nl_xaf_auditfile_export/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">XAF auditfile export</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/l10n-netherlands/tree/14.0/l10n_nl_xaf_auditfile_export"><img alt="OCA/l10n-netherlands" src="https://img.shields.io/badge/github-OCA%2Fl10n--netherlands-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/l10n-netherlands-14-0/l10n-netherlands-14-0-l10n_nl_xaf_auditfile_export"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/176/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/l10n-netherlands/tree/16.0/l10n_nl_xaf_auditfile_export"><img alt="OCA/l10n-netherlands" src="https://img.shields.io/badge/github-OCA%2Fl10n--netherlands-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/l10n-netherlands-14-0/l10n-netherlands-14-0-l10n_nl_xaf_auditfile_export"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/176/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to export XAF audit files for the Dutch tax authorities (Belastingdienst).</p>
<p>The currently exported version is 3.2</p>
<p>An option allows to export the XAF audit files in a format that is accepted by Unit4.</p>
Expand All @@ -392,7 +392,7 @@ <h1 class="title">XAF auditfile export</h1>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>The exporting feature is available to the users who have <cite>Accountant</cite> or <cite>Adviser</cite> rights for accounting.</p>
<p>The exporting feature is available to the users who have <cite>Billing Administrator</cite> or <cite>Accountant</cite> rights for accounting.</p>
<p>To configure the default start and end dates of the actual fiscal year, go to <cite>accounting</cite>/<cite>settings</cite> 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.
Expand All @@ -403,8 +403,8 @@ <h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
<p>To use this module, you need to:</p>
<ul class="simple">
<li>be sure that you have <cite>Accountant</cite> or <cite>Adviser</cite> rights for accounting</li>
<li>go to <cite>Invoicing</cite>/<cite>Reports</cite>/<cite>Auditfile export</cite></li>
<li>be sure that you have <cite>Billing Administrator</cite> or <cite>Accountant</cite> rights for accounting</li>
<li>go to <cite>Invoicing</cite>/<cite>Reporting</cite>/<cite>Auditfile export</cite></li>
<li>create a new record, adjust values if the defaults are not appropriate</li>
<li>click <cite>Generate auditfile</cite></li>
<li>click <cite>Download</cite> on the field <cite>Auditfile</cite></li>
Expand All @@ -421,7 +421,7 @@ <h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/l10n-netherlands/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_xaf_auditfile_export%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_xaf_auditfile_export%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -455,7 +455,7 @@ <h2><a class="toc-backref" href="#id10">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-netherlands/tree/14.0/l10n_nl_xaf_auditfile_export">OCA/l10n-netherlands</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-netherlands/tree/16.0/l10n_nl_xaf_auditfile_export">OCA/l10n-netherlands</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,35 @@ def get_transaction_line_count_from_xml(auditfile):


class TestXafAuditfileExport(TransactionCase):
def setUp(self):
super().setUp()

self.env.user.company_id.country_id = (self.env.ref("base.nl").id,)
@classmethod
def setUpClass(cls):
super().setUpClass()

cls.eur = cls.env["res.currency"].search([("name", "=", "EUR")])
cls.coa = cls.env.ref("l10n_nl.l10nnl_chart_template", raise_if_not_found=False)
cls.coa = cls.coa or cls.env.ref("l10n_generic_coa.configurable_chart_template")
cls.company_nl = cls.env["res.company"].create(
{
"name": "XAF Company1",
"country_id": cls.env.ref("base.nl").id,
"currency_id": cls.eur.id,
}
)
cls.env.user.company_id = cls.company_nl
cls.coa.try_loading(cls.company_nl, install_demo=False)

# create an invoice and post it, to ensure that there's some data to export
move_form = Form(
self.env["account.move"].with_context(default_move_type="out_invoice")
cls.env["account.move"].with_context(default_move_type="out_invoice")
)
move_form.invoice_date = fields.Date().today()
move_form.partner_id = self.env["res.partner"].create({"name": "Partner Test"})
move_form.partner_id = cls.env["res.partner"].create({"name": "Partner Test"})
with move_form.invoice_line_ids.new() as line_form:
line_form.product_id = self.env["product.product"].create(
line_form.product_id = cls.env["product.product"].create(
{"name": "product test", "standard_price": 800.0}
)
self.invoice = move_form.save()
self.invoice.post()
cls.invoice = move_form.save()
cls.invoice.action_post()

def test_01_default_values(self):
"""Check that the default values are filled on creation"""
Expand Down
7 changes: 5 additions & 2 deletions l10n_nl_xaf_auditfile_export/views/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<odoo>

<template id="auditfile_template">
<auditfile>
<auditfile
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.auditfiles.nl/XAF/3.2"
>
<header>
<fiscalYear><t
t-esc="self.fiscalyear_name"
Expand Down Expand Up @@ -146,7 +149,7 @@
t-options='{"widget": "auditfile.string999"}'
/></accDesc>
<accTp><t
t-esc="'P' if a.user_type_id.type in ['income', 'expense'] else 'B' if a.user_type_id.type in ['asset', 'liability'] else 'M'"
t-esc="'P' if a.internal_group in ['income', 'expense'] else 'B' if a.internal_group in ['asset', 'liability'] else 'M'"
/></accTp>
<!-- don't export the following for now
<leadCode>String</leadCode>
Expand Down

0 comments on commit a4f5d20

Please sign in to comment.