forked from OCA/l10n-spain
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
==================== | ||
Product: Plastic Tax | ||
==================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:b8a616c5bc45477fa9fa318899275f24d88655356e82151e935355901e93f025 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/16.0/product_plastic_tax | ||
: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-16-0/l10n-spain-16-0-product_plastic_tax | ||
: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=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Módulo para implementar los campos necesarios a nivel de producto para presentar el "Impuesto especial sobre los envases de plástico no reutilizables" https://www.boe.es/buscar/act.php?id=BOE-A-2022-5809. | ||
|
||
Los campos a nivel de producto y variante son: | ||
|
||
* Código de producto: A, B ó C | ||
* Total peso plástico: peso de plástico total que contiene el producto. | ||
* Peso plástico no reutilizable: peso de plástico total no reutilizable que contiene el producto. | ||
|
||
Si se añaden o modifican estos valores en la plantilla de producto, se modifican de manera automática todas sus variantes, pero **no** a la inversa. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
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 to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/l10n-spain/issues/new?body=module:%20product_plastic_tax%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. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* FactorLibre | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Hugo Córdoba <[email protected]> | ||
* Luis J. Salvatierra <[email protected]> | ||
* Aritz Olea <[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. | ||
|
||
This module is part of the `OCA/l10n-spain <https://github.com/OCA/l10n-spain/tree/16.0/product_plastic_tax>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# © 2022 FactorLibre - Hugo Córdoba <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# © 2022 FactorLibre - Hugo Córdoba <[email protected]> | ||
# © 2023 FactorLibre - Luis J. Salvatierra <[email protected]> | ||
# © 2023 FactorLibre - Aritz Olea <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Product: Plastic Tax", | ||
"version": "16.0.1.0.0", | ||
"category": "Product", | ||
"author": "FactorLibre, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"depends": ["product"], | ||
"website": "https://github.com/OCA/l10n-spain", | ||
"data": [ | ||
"views/product_template_views.xml", | ||
], | ||
"installable": True, | ||
"application": False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * l10n_es_product_plastic_tax | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2023-10-09 11:59+0000\n" | ||
"PO-Revision-Date: 2023-10-09 14:01+0200\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"Language: es\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: \n" | ||
"X-Generator: Poedit 3.0.1\n" | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#: model_terms:ir.ui.view,arch_db:l10n_es_product_plastic_tax.view_template_property_form_inherit_plastic_tax | ||
msgid "<span>kg</span>" | ||
msgstr "" | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#: model:ir.model.fields.selection,name:l10n_es_product_plastic_tax.selection__product_product__plastic_tax_product_code__a | ||
#: model:ir.model.fields.selection,name:l10n_es_product_plastic_tax.selection__product_template__plastic_tax_product_code__a | ||
msgid "A - Non-reusable containers containing plastic" | ||
msgstr "A - Envases no reutilizables que contengan plástico" | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#: model:ir.model.fields.selection,name:l10n_es_product_plastic_tax.selection__product_product__plastic_tax_product_code__b | ||
#: model:ir.model.fields.selection,name:l10n_es_product_plastic_tax.selection__product_template__plastic_tax_product_code__b | ||
msgid "B - Semi-finished plastic products intended to obtain type A plastics" | ||
msgstr "" | ||
"B - Productos plásticos semielaborados destinados a la obtención de " | ||
"plásticos de tipo A" | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#: model:ir.model.fields.selection,name:l10n_es_product_plastic_tax.selection__product_product__plastic_tax_product_code__c | ||
#: model:ir.model.fields.selection,name:l10n_es_product_plastic_tax.selection__product_template__plastic_tax_product_code__c | ||
msgid "" | ||
"C - Products containing plastic intended to allow closure, marketing or " | ||
"otherwise of non-reusable packaging" | ||
msgstr "" | ||
"C - Productos que contengan plástico destinados a permitir el cierre, la " | ||
"comercialización u otros de envases no reutilizables" | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#: model:ir.model.fields,field_description:l10n_es_product_plastic_tax.field_product_product__non_reusable_plastic_weight | ||
#: model:ir.model.fields,field_description:l10n_es_product_plastic_tax.field_product_template__non_reusable_plastic_weight | ||
msgid "Non Reusable Plastic Weight" | ||
msgstr "Peso plástico no reutilizable" | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#. odoo-python | ||
#: code:addons/l10n_es_product_plastic_tax/models/product.py:0 | ||
#: code:addons/l10n_es_product_plastic_tax/models/product_template.py:0 | ||
#, python-format | ||
msgid "Non reusable plastic weight cannot exceed total plastic weight." | ||
msgstr "" | ||
"La cantidad de peso de plástico no reutilizable no puede superar al peso " | ||
"total de plástico." | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#: model_terms:ir.ui.view,arch_db:l10n_es_product_plastic_tax.view_template_property_form_inherit_plastic_tax | ||
msgid "Plastic" | ||
msgstr "Plástico" | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#: model:ir.model.fields,field_description:l10n_es_product_plastic_tax.field_product_product__plastic_tax_product_code | ||
#: model:ir.model.fields,field_description:l10n_es_product_plastic_tax.field_product_template__plastic_tax_product_code | ||
msgid "Plastic Tax Product Code" | ||
msgstr "Código de impuesto sobre plásticos del producto" | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#: model:ir.model.fields,field_description:l10n_es_product_plastic_tax.field_product_product__total_plastic_weight | ||
#: model:ir.model.fields,field_description:l10n_es_product_plastic_tax.field_product_template__total_plastic_weight | ||
msgid "Plastic Total Weight" | ||
msgstr "Peso total plástico" | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#: model:ir.model,name:l10n_es_product_plastic_tax.model_product_template | ||
msgid "Product" | ||
msgstr "Producto" | ||
|
||
#. module: l10n_es_product_plastic_tax | ||
#: model:ir.model,name:l10n_es_product_plastic_tax.model_product_product | ||
msgid "Product Variant" | ||
msgstr "Variante de producto" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# © 2022 FactorLibre - Hugo Córdoba <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from . import product_template | ||
from . import product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# © 2022 FactorLibre - Hugo Córdoba <[email protected]> | ||
# © 2022 FactorLibre - Luis J. Salvatierra <[email protected]> | ||
# © 2023 FactorLibre - Aritz Olea <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = "product.product" | ||
|
||
@api.constrains("total_plastic_weight", "non_reusable_plastic_weight") | ||
def _check_plastic_weight(self): | ||
for template in self: | ||
if template.non_reusable_plastic_weight > template.total_plastic_weight: | ||
raise ValidationError( | ||
_("Non reusable plastic weight cannot exceed total plastic weight.") | ||
) | ||
|
||
plastic_tax_product_code = fields.Selection( | ||
selection=[ | ||
("A", "A - Non-reusable containers containing plastic"), | ||
( | ||
"B", | ||
"B - Semi-finished plastic products intended to obtain type A " | ||
"plastics", | ||
), | ||
( | ||
"C", | ||
"C - Products containing plastic intended to allow closure, " | ||
"marketing or otherwise of non-reusable packaging", | ||
), | ||
], | ||
inverse="_inverse_set_plastic_tax_product_code", | ||
) | ||
total_plastic_weight = fields.Float( | ||
string="Plastic Total Weight", | ||
inverse="_inverse_set_total_plastic_weight", | ||
digits="Stock Weight", | ||
) | ||
non_reusable_plastic_weight = fields.Float( | ||
inverse="_inverse_set_non_reusable_plastic_weight", | ||
digits="Stock Weight", | ||
) | ||
|
||
def _inverse_set_plastic_tax_product_code(self): | ||
for variant in self: | ||
if 1 == len(variant.product_tmpl_id.product_variant_ids) or ( | ||
variant.plastic_tax_product_code | ||
and not variant.product_tmpl_id.plastic_tax_product_code | ||
): | ||
variant.product_tmpl_id.plastic_tax_product_code = ( | ||
variant.plastic_tax_product_code | ||
) | ||
|
||
def _inverse_set_total_plastic_weight(self): | ||
for variant in self: | ||
if 1 == len(variant.product_tmpl_id.product_variant_ids) or ( | ||
variant.total_plastic_weight | ||
and not variant.product_tmpl_id.total_plastic_weight | ||
): | ||
variant.product_tmpl_id.total_plastic_weight = ( | ||
variant.total_plastic_weight | ||
) | ||
|
||
def _inverse_set_non_reusable_plastic_weight(self): | ||
for variant in self: | ||
if 1 == len(variant.product_tmpl_id.product_variant_ids) or ( | ||
variant.non_reusable_plastic_weight | ||
and not variant.product_tmpl_id.non_reusable_plastic_weight | ||
): | ||
variant.product_tmpl_id.non_reusable_plastic_weight = ( | ||
variant.non_reusable_plastic_weight | ||
) | ||
|
||
def set_plastic_tax_from_template(self): | ||
for variant in self: | ||
template = variant.product_tmpl_id | ||
variant.write( | ||
{ | ||
"plastic_tax_product_code": template.plastic_tax_product_code, | ||
"total_plastic_weight": template.total_plastic_weight, | ||
"non_reusable_plastic_weight": template.non_reusable_plastic_weight, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# © 2022 FactorLibre - Hugo Córdoba <[email protected]> | ||
# © 2023 FactorLibre - Luis J. Salvatierra <[email protected]> | ||
# © 2023 FactorLibre - Aritz Olea <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
@api.constrains("total_plastic_weight", "non_reusable_plastic_weight") | ||
def _check_plastic_weight(self): | ||
for template in self: | ||
if template.non_reusable_plastic_weight > template.total_plastic_weight: | ||
raise ValidationError( | ||
_("Non reusable plastic weight cannot exceed total plastic weight.") | ||
) | ||
|
||
plastic_tax_product_code = fields.Selection( | ||
selection=[ | ||
("A", "A - Non-reusable containers containing plastic"), | ||
( | ||
"B", | ||
"B - Semi-finished plastic products intended to obtain type A " | ||
"plastics", | ||
), | ||
( | ||
"C", | ||
"C - Products containing plastic intended to allow closure, " | ||
"marketing or otherwise of non-reusable packaging", | ||
), | ||
], | ||
inverse="_inverse_set_plastic_tax_product_code", | ||
) | ||
total_plastic_weight = fields.Float( | ||
string="Plastic Total Weight", | ||
inverse="_inverse_set_total_plastic_weight", | ||
digits="Stock Weight", | ||
) | ||
non_reusable_plastic_weight = fields.Float( | ||
inverse="_inverse_set_non_reusable_plastic_weight", | ||
digits="Stock Weight", | ||
) | ||
|
||
def _create_variant_ids(self): | ||
template_variants = {} | ||
for template in self.with_context(active_test=False): | ||
template_variants[template] = template.product_variant_ids | ||
res = super()._create_variant_ids() | ||
for template, existing_variants in template_variants.items(): | ||
to_update_variants = template.product_variant_ids - existing_variants | ||
if 0 < len(to_update_variants): | ||
to_update_variants.set_plastic_tax_from_template() | ||
return res | ||
|
||
def _inverse_set_plastic_tax_product_code(self): | ||
for template in self: | ||
template.product_variant_ids.filtered( | ||
lambda x, t=template: x.plastic_tax_product_code | ||
!= t.plastic_tax_product_code | ||
).write({"plastic_tax_product_code": template.plastic_tax_product_code}) | ||
|
||
def _inverse_set_total_plastic_weight(self): | ||
for template in self: | ||
template.product_variant_ids.filtered( | ||
lambda x, t=template: x.total_plastic_weight != t.total_plastic_weight | ||
).write({"total_plastic_weight": template.total_plastic_weight}) | ||
|
||
def _inverse_set_non_reusable_plastic_weight(self): | ||
for template in self: | ||
template.product_variant_ids.filtered( | ||
lambda x, t=template: x.non_reusable_plastic_weight | ||
!= t.non_reusable_plastic_weight | ||
).write( | ||
{"non_reusable_plastic_weight": template.non_reusable_plastic_weight} | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Hugo Córdoba <[email protected]> | ||
* Luis J. Salvatierra <[email protected]> | ||
* Aritz Olea <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Módulo para implementar los campos necesarios a nivel de producto para presentar el "Impuesto especial sobre los envases de plástico no reutilizables" https://www.boe.es/buscar/act.php?id=BOE-A-2022-5809. | ||
|
||
Los campos a nivel de producto y variante son: | ||
|
||
* Código de producto: A, B ó C | ||
* Total peso plástico: peso de plástico total que contiene el producto. | ||
* Peso plástico no reutilizable: peso de plástico total no reutilizable que contiene el producto. | ||
|
||
Si se añaden o modifican estos valores en la plantilla de producto, se modifican de manera automática todas sus variantes, pero **no** a la inversa. |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.