Skip to content

Commit

Permalink
Merge PR #596 into 18.0
Browse files Browse the repository at this point in the history
Signed-off-by alexis-via
  • Loading branch information
OCA-git-bot committed Jan 2, 2025
2 parents af1e1b0 + 93812a7 commit 9510219
Show file tree
Hide file tree
Showing 13 changed files with 664 additions and 0 deletions.
85 changes: 85 additions & 0 deletions l10n_fr_account_tax_unece/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
=========================
L10n FR Account Tax UNECE
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a6c2430b713cf3d449ac2642a226dbef650250759493d0ba495a5649056c9782
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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--france-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-france/tree/18.0/l10n_fr_account_tax_unece
:alt: OCA/l10n-france
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-france-18-0/l10n-france-18-0-l10n_fr_account_tax_unece
: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-france&target_branch=18.0
:alt: Try me on Runboat

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

This module will auto-configure the parameters *UNECE Tax Type* and
*UNECE Tax Category* on taxes defined in the *l10n_fr* module.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-france/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-france/issues/new?body=module:%20l10n_fr_account_tax_unece%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.

Credits
=======

Authors
-------

* Akretion

Contributors
------------

- Alexis de Lattre <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-alexis-via| image:: https://github.com/alexis-via.png?size=40px
:target: https://github.com/alexis-via
:alt: alexis-via

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-alexis-via|

This module is part of the `OCA/l10n-france <https://github.com/OCA/l10n-france/tree/18.0/l10n_fr_account_tax_unece>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions l10n_fr_account_tax_unece/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .post_install import set_unece_on_taxes
18 changes: 18 additions & 0 deletions l10n_fr_account_tax_unece/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2017-2022 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "L10n FR Account Tax UNECE",
"summary": "Auto-configure UNECE params on French taxes",
"version": "18.0.1.0.0",
"category": "French Localization",
"author": "Akretion,Odoo Community Association (OCA)",
"maintainers": ["alexis-via"],
"website": "https://github.com/OCA/l10n-france",
"license": "AGPL-3",
"depends": ["l10n_fr_account", "account_tax_unece"],
"post_init_hook": "set_unece_on_taxes",
"installable": True,
"auto_installable": True,
}
22 changes: 22 additions & 0 deletions l10n_fr_account_tax_unece/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_fr_account_tax_unece
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-03-20 19:33+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: l10n_fr_account_tax_unece
#: model:ir.model,name:l10n_fr_account_tax_unece.model_account_chart_template
msgid "Account Chart Template"
msgstr "Plantilla del Plan Contable"
19 changes: 19 additions & 0 deletions l10n_fr_account_tax_unece/i18n/l10n_fr_account_tax_unece.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_fr_account_tax_unece
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.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_fr_account_tax_unece
#: model:ir.model,name:l10n_fr_account_tax_unece.model_account_chart_template
msgid "Account Chart Template"
msgstr ""
1 change: 1 addition & 0 deletions l10n_fr_account_tax_unece/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_chart_template
41 changes: 41 additions & 0 deletions l10n_fr_account_tax_unece/models/account_chart_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2024 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models

from odoo.addons.account.models.chart_template import template


class AccountChartTemplate(models.AbstractModel):
_inherit = "account.chart.template"

def _fr_account_tax_unece_data(self):
xmlid2id = {
"type_vat": self.env.ref("account_tax_unece.tax_type_vat").id,
"categ_s": self.env.ref("account_tax_unece.tax_categ_s").id,
"categ_k": self.env.ref("account_tax_unece.tax_categ_k").id,
"categ_g": self.env.ref("account_tax_unece.tax_categ_g").id,
"categ_e": self.env.ref("account_tax_unece.tax_categ_e").id,
}
res = {}
tax_data = self._parse_csv("fr", "account.tax")
for tax_xmlid in tax_data.keys():
res[tax_xmlid] = {
"unece_type_id": xmlid2id["type_vat"],
}
if "_intra_" in tax_xmlid:
res[tax_xmlid]["unece_categ_id"] = xmlid2id["categ_k"]
elif "_export" in tax_xmlid or "_import" in tax_xmlid:
res[tax_xmlid]["unece_categ_id"] = xmlid2id["categ_g"]
elif "_imm_" in tax_xmlid or "_fuel" in tax_xmlid:
res[tax_xmlid]["unece_categ_id"] = False
elif tax_xmlid.endswith(("_good_0", "_service_0")):
res[tax_xmlid]["unece_categ_id"] = xmlid2id["categ_e"]
else:
res[tax_xmlid]["unece_categ_id"] = xmlid2id["categ_s"]
return res

@template("fr", "account.tax")
def _get_fr_account_tax(self):
return self._fr_account_tax_unece_data()
44 changes: 44 additions & 0 deletions l10n_fr_account_tax_unece/post_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2016-2022 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

logger = logging.getLogger(__name__)


def set_unece_on_taxes(env):
data = env["account.chart.template"]._fr_account_tax_unece_data()
logger.debug("set_unece_on_taxes data=%s", data)
companies = env["res.company"].search([])
for company in companies:
# country_id is NOT a stored field on res.company
if company.country_id and company.country_id != env.ref("base.fr"):
continue
logger.debug(
"set_unece_on_taxes working on company %s ID %d",
company.display_name,
company.id,
)
taxes = (
env["account.tax"]
.with_context(active_test=False)
.search([("company_id", "=", company.id)])
)
for tax in taxes:
xmlid_obj = env["ir.model.data"].search(
[
("model", "=", "account.tax"),
("module", "=", "account"),
("res_id", "=", tax.id),
],
limit=1,
)
if xmlid_obj and xmlid_obj.name and len(xmlid_obj.name.split("_", 1)) == 2:
# Remove the 'companyID_' prefix from XMLID of tax
vals = data.get(xmlid_obj.name.split("_", 1)[1])
if vals:
logger.debug(
"set_unece_on_taxes writing vals=%s on tax ID %d", vals, tax.id
)
tax.write(vals)
3 changes: 3 additions & 0 deletions l10n_fr_account_tax_unece/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions l10n_fr_account_tax_unece/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Alexis de Lattre \<<[email protected]>\>
2 changes: 2 additions & 0 deletions l10n_fr_account_tax_unece/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module will auto-configure the parameters *UNECE Tax Type* and
*UNECE Tax Category* on taxes defined in the *l10n_fr* module.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9510219

Please sign in to comment.