Skip to content

Commit

Permalink
[MIG]l10n_es_cnae: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelregidor committed May 29, 2024
1 parent b304bb9 commit 7425b54
Show file tree
Hide file tree
Showing 14 changed files with 1,052 additions and 302 deletions.
99 changes: 64 additions & 35 deletions l10n_es_cnae/README.rst
Original file line number Diff line number Diff line change
@@ -1,65 +1,94 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

===============================
Categorías de empresa CNAE 2009
===============================

Añade todas las categorías CNAE 2009 (españolas) al listado de categorías de
empresa, además de todas las categorías NACE (europeas).

Instalación
===========

Necesita tener disponible el módulo `l10n_eu_nace
<https://github.com/OCA/community-data-files/tree/9.0/l10n_eu_nace>`_ para que
este funcione.

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

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

Añade todas las categorías CNAE 2009 (españolas) al listado de
categorías de empresa, además de todas las categorías NACE (europeas).

**Table of contents**

.. contents::
:local:

Installation
============

Necesita tener disponible el módulo
``l10n_eu_nace <https://github.com/OCA/community-data-files/tree/17.0/l10n_eu_nace>``\ \_
para que este funcione.

Usage
=====

Para usar este módulo:

#. Vaya a *Ventas > Ventas > Clientes* y edite uno.
#. En el campo *Etiquetas* podrá escoger los CNAE o NACE que quiera aplicarle.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/189/9.0
1. Vaya a *Ventas > Ventas > Clientes* y edite uno.
2. En el campo *Etiquetas* podrá escoger los CNAE o NACE que quiera
aplicarle.

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

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

Images
------
Authors
-------

* Jairo Llopis: Icon.
* Tecnativa

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

* Jairo Llopis <[email protected]>
- Jairo Llopis ([email protected])
- Manuel Regidor ([email protected])

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-spain <https://github.com/OCA/l10n-spain/tree/17.0/l10n_es_cnae>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions l10n_es_cnae/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .hooks import _create_l10n_es_cnae_industries
6 changes: 2 additions & 4 deletions l10n_es_cnae/__openerp__.py → l10n_es_cnae/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Categorías de empresa CNAE 2009",
"summary": "Extiende los códigos NACE europeos con los CNAE españoles",
"version": "9.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Localization",
"website": "https://github.com/OCA/l10n-spain",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand All @@ -13,7 +13,5 @@
"depends": [
"l10n_eu_nace",
],
"data": [
"data/res.partner.category.csv",
],
"post_init_hook": "_create_l10n_es_cnae_industries",
}
26 changes: 0 additions & 26 deletions l10n_es_cnae/data/res.partner.category.csv

This file was deleted.

25 changes: 25 additions & 0 deletions l10n_es_cnae/data/res.partner.industry.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cnae_10_21,10.2,10.21,"Processing of fish, crustaceans and molluscs"
cnae_10_22,10.2,10.22,"Manufacture of preserved fish"
cnae_10_43,10.4,10.43,"Manufacture of olive oil"
cnae_10_44,10.4,10.44,"Manufacture of other oils and fats"
cnae_10_53,10.5,10.53,"Manufacture of cheeses"
cnae_10_54,10.5,10.54,"Manufacture of milk and other dairies"
cnae_35_15,35.1,35.15,"Production of hydro-electric electricity"
cnae_35_16,35.1,35.16,"Production of electric energy of conventional thermal origin"
cnae_35_17,35.1,35.17,"Production of electric energy of nuclear origin"
cnae_35_18,35.1,35.18,"Production of electric energy of eolian origin"
cnae_35_19,35.1,35.19,"Production of electric energy of other types"
cnae_41_21,41.2,41.21,"Construction of residential buildings"
cnae_41_22,41.2,41.22,"Construction of non-residential buildings"
cnae_59_15,59.1,59.15,"Film and video production activities"
cnae_59_16,59.1,59.16,"Television programs production and distribution activities"
cnae_59_17,59.1,59.17,"Film and video distribution activities"
cnae_59_18,59.1,59.18,"Television programs distribution activities"
cnae_85_43,85.4,85.43,"University education"
cnae_85_44,85.4,85.44,"Non-university tertiary education"
cnae_87_31,87.3,87.31,"Residential care activities for the elderly"
cnae_87_32,87.3,87.32,"Residential care activities for the disabled"
cnae_88_11,88.1,88.11,"Social work activities without accommodation for the elderly"
cnae_88_12,88.1,88.12,"Social work activities without accommodation for the disabled"
cnae_91_05,91.0,91.05,"Library activities"
cnae_91_06,91.0,91.06,"Archives activities"
36 changes: 36 additions & 0 deletions l10n_es_cnae/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2024 Manuel Regidor <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo.tools import file_open, pycompat

_logger = logging.getLogger(__name__)


def _create_l10n_es_cnae_industries(env):
try:
with file_open("l10n_es_cnae/data/res.partner.industry.csv", "rb") as csvfile:
reader = pycompat.csv_reader(csvfile, delimiter=",", quotechar='"')
partner_industry_mod = env["res.partner.industry"]
all_naces = partner_industry_mod.search_read(
[("full_name", "like", " - ")], ["full_name"]
)
nace_map = {
nace.get("full_name").split(" - ")[0]: nace.get("id")
for nace in all_naces
}
data_list = []
for row in reader:
vals = {"name": row[3], "full_name": f"{row[2]} - {row[3]}"}
parent = nace_map.get(row[1])
if parent:
vals["parent_id"] = parent

Check warning on line 28 in l10n_es_cnae/hooks.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_cnae/hooks.py#L28

Added line #L28 was not covered by tests
new_industry = partner_industry_mod.create(vals)
data_list.append(
{"xml_id": f"l10n_es_cnae.{row[0]}", "record": new_industry}
)
env["ir.model.data"]._update_xmlids(data_list)

except Exception:
_logger.exception("Could not create industries from module l10n_es_cnae.")

Check warning on line 36 in l10n_es_cnae/hooks.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_cnae/hooks.py#L35-L36

Added lines #L35 - L36 were not covered by tests
149 changes: 0 additions & 149 deletions l10n_es_cnae/i18n/ca.po

This file was deleted.

Loading

0 comments on commit 7425b54

Please sign in to comment.