Skip to content

Commit

Permalink
[MIG] l10n_nl_xaf_auditfile_export: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanRijnhart committed Feb 28, 2025
1 parent c6232b2 commit e53740d
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 42 deletions.
10 changes: 5 additions & 5 deletions l10n_nl_xaf_auditfile_export/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ 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/17.0/l10n_nl_xaf_auditfile_export
:target: https://github.com/OCA/l10n-netherlands/tree/18.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-17-0/l10n-netherlands-17-0-l10n_nl_xaf_auditfile_export
:target: https://translation.odoo-community.org/projects/l10n-netherlands-18-0/l10n-netherlands-18-0-l10n_nl_xaf_auditfile_export
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-netherlands&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-netherlands&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -80,7 +80,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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_xaf_auditfile_export%0Aversion:%2017.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:%2018.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 @@ -121,6 +121,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/17.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/18.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": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Therp BV, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-netherlands",
"license": "AGPL-3",
Expand Down
29 changes: 17 additions & 12 deletions l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from lxml import etree

from odoo import _, api, exceptions, fields, models, modules, release
from odoo.tools import file_path


def chunks(items, n=None):
Expand Down Expand Up @@ -80,7 +81,7 @@ class XafAuditfileExport(models.Model):
@api.depends("name", "auditfile")
def _compute_auditfile_name(self):
for item in self:
item.auditfile_name = "%s.xaf" % item.name
item.auditfile_name = f"{item.name}.xaf"
if item.auditfile:
auditfile = base64.b64decode(item.auditfile)
zf = BytesIO(auditfile)
Expand Down Expand Up @@ -150,6 +151,7 @@ def _get_auditfile_template():
return "l10n_nl_xaf_auditfile_export.auditfile_template"

def button_generate(self):
self = self.with_company(self.company_id)
t0 = time.time()
m0 = memory_info()
self.date_generated = fields.Datetime.now()
Expand Down Expand Up @@ -203,10 +205,9 @@ def button_generate(self):
xsd = etree.XMLSchema(
etree.parse(
open(
modules.get_resource_path(
"l10n_nl_xaf_auditfile_export",
"data",
"XmlAuditfileFinancieel3.2.xsd",
file_path(
"l10n_nl_xaf_auditfile_export/data"
"/XmlAuditfileFinancieel3.2.xsd",
)
)
)
Expand Down Expand Up @@ -255,7 +256,7 @@ def get_partners(self):
def get_accounts(self):
"""return recordset of accounts"""
return self.env["account.account"].search(
[("company_id", "=", self.company_id.id)]
[("company_ids", "=", self.company_id.id)]
)

@api.model
Expand Down Expand Up @@ -316,15 +317,19 @@ def get_ob_totals(self):
def get_ob_lines(self):
"""return opening balance entries"""
self.env.cr.execute(
"select a.id, a.code, sum(l.balance) "
"select a.id, a.code_store->>%(company_id)s as code, sum(l.balance) "
"from account_move_line l, account_account a "
"where a.id = l.account_id and l.date < %s "
"and l.company_id=%s "
"where a.id = l.account_id and l.date < %(date_start)s "
"and l.company_id=%(company_id)s "
"and l.parent_state = 'posted' "
"and l.display_type NOT IN ('line_section', 'line_note') "
"and a.include_initial_balance = true "
"group by a.id, a.code",
(self.date_start, self.company_id.id),
# Select by unstored, computed field include_initial_balance
"and split_part(a.account_type, '_', 1) not in ('income', 'expense') "
"group by a.id, a.code_store->>%(company_id)s ",
{
"date_start": self.date_start,
"company_id": self.company_id.id,
},
)
for result in self.env.cr.fetchall():
yield dict(
Expand Down
17 changes: 10 additions & 7 deletions l10n_nl_xaf_auditfile_export/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -368,7 +369,7 @@ <h1 class="title">XAF auditfile export</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:54206bd1d3c12a3ab4b06da0a60957936c43d7e936e7e5088837c305fc0f98e4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/l10n-netherlands/tree/17.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 image-reference" href="https://translation.odoo-community.org/projects/l10n-netherlands-17-0/l10n-netherlands-17-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-netherlands&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/l10n-netherlands/tree/18.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 image-reference" href="https://translation.odoo-community.org/projects/l10n-netherlands-18-0/l10n-netherlands-18-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-netherlands&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-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>
Expand Down Expand Up @@ -430,7 +431,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">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 to smash 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:%2017.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:%2018.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 @@ -460,11 +461,13 @@ <h3><a class="toc-backref" href="#toc-entry-9">Icon</a></h3>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<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/17.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/18.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 @@ -10,7 +10,7 @@
from lxml import etree

from odoo import fields
from odoo.tests.common import Form, tagged
from odoo.tests import Form, tagged
from odoo.tools import mute_logger

from odoo.addons.account.tests.common import AccountTestInvoicingCommon
Expand Down Expand Up @@ -50,9 +50,11 @@ def get_transaction_line_count_from_xml(auditfile):

@tagged("post_install_l10n", "post_install", "-at_install")
class TestXafAuditfileExport(AccountTestInvoicingCommon):
chart_template = "nl"

@classmethod
def setUpClass(cls, chart_template_ref="nl"):
super().setUpClass(chart_template_ref=chart_template_ref)
def setUpClass(cls):
super().setUpClass()

cls.env.user.company_id = cls.company_data["company"]

Expand Down Expand Up @@ -152,7 +154,7 @@ def test_04_export_success_unit4(self):
def test_05_export_success(self):
"""Export auditfile with / character in filename"""
record = self.env["xaf.auditfile.export"].create({})
record.name += "%s01" % os.sep
record.name += f"{os.sep}01"
record.button_generate()
self.assertTrue(record)

Expand Down Expand Up @@ -230,21 +232,21 @@ def test_09_opening_balance(self):
"=",
"asset_receivable",
),
("company_id", "=", self.env.company.id),
("company_ids", "=", self.env.company.id),
],
limit=1,
)
acc_payable = self.env["account.account"].search(
[
("account_type", "=", "liability_payable"),
("company_id", "=", self.env.company.id),
("company_ids", "=", self.env.company.id),
],
limit=1,
)
acc_revenue = self.env["account.account"].search(
[
("account_type", "=", "income"),
("company_id", "=", self.env.company.id),
("company_ids", "=", self.env.company.id),
],
limit=1,
)
Expand Down
9 changes: 6 additions & 3 deletions l10n_nl_xaf_auditfile_export/views/templates.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>

<template id="auditfile_template">
<!--
Make sure this file is added to .prettierignore to prevent validation errors
caused by the additional whitespace in length limited values.
-->
<template id="auditfile_template">
<auditfile
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.auditfiles.nl/XAF/3.2"
Expand Down Expand Up @@ -293,5 +296,5 @@
</transactions>
</company>
</auditfile>
</template>
</template>
</odoo>
11 changes: 4 additions & 7 deletions l10n_nl_xaf_auditfile_export/views/xaf_auditfile_export.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<record id="tree_xaf_auditfile_export" model="ir.ui.view">
<field name="model">xaf.auditfile.export</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="date_start" />
<field name="date_end" />
<field name="date_generated" />
</tree>
</list>
</field>
</record>
<record id="form_xaf_auditfile_export" model="ir.ui.view">
Expand Down Expand Up @@ -49,17 +49,14 @@
<field name="auditfile_name" invisible="1" />
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" />
<field name="message_ids" />
</div>
<chatter />
</form>
</field>
</record>
<record id="action_auditfiles" model="ir.actions.act_window">
<field name="name">Auditfile export</field>
<field name="res_model">xaf.auditfile.export</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="view_id" ref="tree_xaf_auditfile_export" />
<field name="target">current</field>
</record>
Expand Down

0 comments on commit e53740d

Please sign in to comment.