diff --git a/l10n_es_vat_book_oss/README.rst b/l10n_es_vat_book_oss/README.rst new file mode 100644 index 00000000000..3349ac54e16 --- /dev/null +++ b/l10n_es_vat_book_oss/README.rst @@ -0,0 +1,100 @@ +================ +Libro de IVA OSS +================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a83488a292a2dbad1693329ad4f07ed16fb5f9caa2a8dfe83187824cf57a2004 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_vat_book_oss + :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_vat_book_oss + :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| + +Módulo que tiene en cuenta los impuestos OSS en el cálculo del libro de +IVA. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +Para instalar este modulo necesitas: + +- l10n_es_vat_book +- l10n_eu_oss + +Configuration +============= + +Los impuestos OSS pueden verse en Contabilidad -> Configuración -> +Impuestos. Son aquellos que tienen el campo oss_country_id definido. No +es necesario incluir los impuestos en los mapeos del libro de IVA. + +Usage +===== + +1. Vaya a *Contabilidad > Declaraciones AEAT > Libro de IVA*. +2. Cree un nuevo registro. +3. Escoja el periodo de tiempo para el libro. +4. Pulse en "Calcular". Se tendrán en cuenta los impuestos OSS. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Sygel + +Contributors +------------ + +- Manuel Regidor + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_es_vat_book_oss/__init__.py b/l10n_es_vat_book_oss/__init__.py new file mode 100644 index 00000000000..6d410b3fe62 --- /dev/null +++ b/l10n_es_vat_book_oss/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2021 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/l10n_es_vat_book_oss/__manifest__.py b/l10n_es_vat_book_oss/__manifest__.py new file mode 100644 index 00000000000..ef45bf9dc49 --- /dev/null +++ b/l10n_es_vat_book_oss/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2021 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Libro de IVA OSS", + "version": "17.0.1.0.0", + "development_status": "Beta", + "author": "Sygel, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-spain", + "license": "AGPL-3", + "category": "Accounting", + "depends": ["l10n_es_vat_book", "l10n_eu_oss_oca"], + "installable": True, + "autoinstall": True, +} diff --git a/l10n_es_vat_book_oss/i18n/es.po b/l10n_es_vat_book_oss/i18n/es.po new file mode 100644 index 00000000000..5657afe9c5b --- /dev/null +++ b/l10n_es_vat_book_oss/i18n/es.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_vat_book_oss +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-09 05:30+0000\n" +"Last-Translator: Ivorra78 \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_es_vat_book_oss +#: model:ir.model,name:l10n_es_vat_book_oss.model_aeat_vat_book_map_line +msgid "AEAT Vat Book Map Line" +msgstr "Linea Mapeo libro de IVA AEAT" + +#. module: l10n_es_vat_book_oss +#: model:ir.model,name:l10n_es_vat_book_oss.model_l10n_es_vat_book +msgid "Spanish VAT book report" +msgstr "Informe sobre el libro de IVA en español" diff --git a/l10n_es_vat_book_oss/i18n/l10n_es_vat_book_oss.pot b/l10n_es_vat_book_oss/i18n/l10n_es_vat_book_oss.pot new file mode 100644 index 00000000000..9987932b952 --- /dev/null +++ b/l10n_es_vat_book_oss/i18n/l10n_es_vat_book_oss.pot @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_vat_book_oss +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_es_vat_book_oss +#: model:ir.model,name:l10n_es_vat_book_oss.model_aeat_vat_book_map_line +msgid "AEAT Vat Book Map Line" +msgstr "" + +#. module: l10n_es_vat_book_oss +#: model:ir.model,name:l10n_es_vat_book_oss.model_l10n_es_vat_book +msgid "Spanish VAT book report" +msgstr "" diff --git a/l10n_es_vat_book_oss/models/__init__.py b/l10n_es_vat_book_oss/models/__init__.py new file mode 100644 index 00000000000..8ac2907e33b --- /dev/null +++ b/l10n_es_vat_book_oss/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2021 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import l10n_es_vat_book +from . import aeat_vat_book_map_lines diff --git a/l10n_es_vat_book_oss/models/aeat_vat_book_map_lines.py b/l10n_es_vat_book_oss/models/aeat_vat_book_map_lines.py new file mode 100644 index 00000000000..a73f97e05a9 --- /dev/null +++ b/l10n_es_vat_book_oss/models/aeat_vat_book_map_lines.py @@ -0,0 +1,21 @@ +# Copyright 2021 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class AeatVatBookMapLines(models.Model): + _inherit = "aeat.vat.book.map.line" + + def get_taxes_for_company(self, company): + self.ensure_one() + s_iva_map_line = self.env.ref("l10n_es_vat_book.aeat_vat_book_map_line_s_iva") + taxes = super().get_taxes_for_company(company) + if s_iva_map_line == self: + taxes += self.env["account.tax"].search( + [ + ("oss_country_id", "!=", False), + ("company_id", "=", company.id), + ] + ) + return taxes diff --git a/l10n_es_vat_book_oss/models/l10n_es_vat_book.py b/l10n_es_vat_book_oss/models/l10n_es_vat_book.py new file mode 100644 index 00000000000..f2ff4335319 --- /dev/null +++ b/l10n_es_vat_book_oss/models/l10n_es_vat_book.py @@ -0,0 +1,17 @@ +# Copyright 2021 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class L10nEsVatBook(models.Model): + _inherit = "l10n.es.vat.book" + + def _prepare_book_line_tax_vals(self, move_line, vat_book_line): + values = super()._prepare_book_line_tax_vals(move_line, vat_book_line) + oss_taxes = self.env["account.tax"].search( + [("oss_country_id", "!=", False), ("company_id", "=", self.company_id.id)] + ) + if move_line.tax_line_id in oss_taxes: + values.update({"tax_amount": 0, "total_amount": values.get("base_amount")}) + return values diff --git a/l10n_es_vat_book_oss/pyproject.toml b/l10n_es_vat_book_oss/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/l10n_es_vat_book_oss/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_es_vat_book_oss/readme/CONFIGURE.md b/l10n_es_vat_book_oss/readme/CONFIGURE.md new file mode 100644 index 00000000000..37852be0328 --- /dev/null +++ b/l10n_es_vat_book_oss/readme/CONFIGURE.md @@ -0,0 +1,3 @@ +Los impuestos OSS pueden verse en Contabilidad -\> Configuración -\> +Impuestos. Son aquellos que tienen el campo oss_country_id definido. No +es necesario incluir los impuestos en los mapeos del libro de IVA. diff --git a/l10n_es_vat_book_oss/readme/CONTRIBUTORS.md b/l10n_es_vat_book_oss/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..5db0048fc94 --- /dev/null +++ b/l10n_es_vat_book_oss/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Manuel Regidor \<\> diff --git a/l10n_es_vat_book_oss/readme/DESCRIPTION.md b/l10n_es_vat_book_oss/readme/DESCRIPTION.md new file mode 100644 index 00000000000..f2975df9268 --- /dev/null +++ b/l10n_es_vat_book_oss/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +Módulo que tiene en cuenta los impuestos OSS en el cálculo del libro de +IVA. diff --git a/l10n_es_vat_book_oss/readme/INSTALL.md b/l10n_es_vat_book_oss/readme/INSTALL.md new file mode 100644 index 00000000000..f8058488193 --- /dev/null +++ b/l10n_es_vat_book_oss/readme/INSTALL.md @@ -0,0 +1,4 @@ +Para instalar este modulo necesitas: + +- l10n_es_vat_book +- l10n_eu_oss diff --git a/l10n_es_vat_book_oss/readme/USAGE.md b/l10n_es_vat_book_oss/readme/USAGE.md new file mode 100644 index 00000000000..14c2883578f --- /dev/null +++ b/l10n_es_vat_book_oss/readme/USAGE.md @@ -0,0 +1,4 @@ +1. Vaya a *Contabilidad \> Declaraciones AEAT \> Libro de IVA*. +2. Cree un nuevo registro. +3. Escoja el periodo de tiempo para el libro. +4. Pulse en "Calcular". Se tendrán en cuenta los impuestos OSS. diff --git a/l10n_es_vat_book_oss/static/description/icon.png b/l10n_es_vat_book_oss/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/l10n_es_vat_book_oss/static/description/icon.png differ diff --git a/l10n_es_vat_book_oss/static/description/index.html b/l10n_es_vat_book_oss/static/description/index.html new file mode 100644 index 00000000000..4b184d5a43c --- /dev/null +++ b/l10n_es_vat_book_oss/static/description/index.html @@ -0,0 +1,450 @@ + + + + + +Libro de IVA OSS + + + +
+

Libro de IVA OSS

+ + +

Beta License: AGPL-3 OCA/l10n-spain Translate me on Weblate Try me on Runboat

+

Módulo que tiene en cuenta los impuestos OSS en el cálculo del libro de +IVA.

+

Table of contents

+ +
+

Installation

+

Para instalar este modulo necesitas:

+
    +
  • l10n_es_vat_book
  • +
  • l10n_eu_oss
  • +
+
+
+

Configuration

+

Los impuestos OSS pueden verse en Contabilidad -> Configuración -> +Impuestos. Son aquellos que tienen el campo oss_country_id definido. No +es necesario incluir los impuestos en los mapeos del libro de IVA.

+
+
+

Usage

+
    +
  1. Vaya a Contabilidad > Declaraciones AEAT > Libro de IVA.
  2. +
  3. Cree un nuevo registro.
  4. +
  5. Escoja el periodo de tiempo para el libro.
  6. +
  7. Pulse en “Calcular”. Se tendrán en cuenta los impuestos OSS.
  8. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Sygel
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_es_vat_book_oss/tests/__init__.py b/l10n_es_vat_book_oss/tests/__init__.py new file mode 100644 index 00000000000..75449348fca --- /dev/null +++ b/l10n_es_vat_book_oss/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2024 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_l10n_es_aeat_vat_book_oss diff --git a/l10n_es_vat_book_oss/tests/test_l10n_es_aeat_vat_book_oss.py b/l10n_es_vat_book_oss/tests/test_l10n_es_aeat_vat_book_oss.py new file mode 100644 index 00000000000..08f7b553d9f --- /dev/null +++ b/l10n_es_vat_book_oss/tests/test_l10n_es_aeat_vat_book_oss.py @@ -0,0 +1,160 @@ +# Copyright 2024 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.addons.l10n_es_vat_book.tests.test_l10n_es_aeat_vat_book import ( + TestL10nEsAeatVatBook, +) + + +class TestL10nEsAeatVatBookOss(TestL10nEsAeatVatBook): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.belgium_customer = cls.env["res.partner"].create( + { + "company_id": cls.company.id, + "name": "Test customer Belgium", + "country_id": cls.env.ref("base.be").id, + } + ) + cls.portugal_customer = cls.env["res.partner"].create( + { + "company_id": cls.company.id, + "name": "Test customer Portugal", + "country_id": cls.env.ref("base.pt").id, + } + ) + cls.spain_customer = cls.env["res.partner"].create( + { + "company_id": cls.company.id, + "name": "Test customer Spain", + "country_id": cls.env.ref("base.es").id, + } + ) + cls.company.write({"vat": "ESA12345674"}) + cls.general_tax = cls.env.ref( + f"account.{cls.company.id}_account_tax_template_s_iva21b" + ) + cls.accounts["700000"].write({"tax_ids": [(4, cls.general_tax.id)]}) + + def test_model_vat_book_oss(self): + sp_fiscal_position = self.env.ref(f"account.{self.company.id}_fp_nacional") + wizard_vals = { + "company_id": self.company.id, + "general_tax": self.general_tax.id, + } + wizard = self.env["l10n.eu.oss.wizard"].create(wizard_vals) + wizard.todo_country_ids = [ + (6, 0, [self.env.ref("base.be").id, self.env.ref("base.pt").id]) + ] + wizard.generate_eu_oss_taxes() + + # Invoice for Spanish customer + data = { + "company_id": self.company.id, + "partner_id": self.spain_customer.id, + "move_type": "out_invoice", + "journal_id": self.journal_sale.id, + "fiscal_position_id": sp_fiscal_position.id, + "invoice_date": "2024-01-01", + "invoice_line_ids": [ + ( + 0, + 0, + { + "name": "Test SP Tax", + "account_id": self.accounts["700000"].id, + "price_unit": 10, + "quantity": 1, + }, + ) + ], + } + inv_es = self.env["account.move"].with_company(self.company).create(data) + inv_es.action_post() + + # Customer Invoice for Belgian customer + data = { + "company_id": self.company.id, + "partner_id": self.belgium_customer.id, + "move_type": "out_invoice", + "journal_id": self.journal_sale.id, + "invoice_date": "2024-01-01", + "invoice_line_ids": [ + ( + 0, + 0, + { + "name": "Test BE Tax", + "account_id": self.accounts["700000"].id, + "price_unit": 20, + "quantity": 2, + }, + ) + ], + } + inv_be = self.env["account.move"].with_company(self.company).create(data) + inv_be.action_post() + + # Customer Invoice for Portuguese customer + data = { + "company_id": self.company.id, + "partner_id": self.portugal_customer.id, + "move_type": "out_invoice", + "journal_id": self.journal_sale.id, + "invoice_date": "2024-01-01", + "invoice_line_ids": [ + ( + 0, + 0, + { + "name": "Test PT Tax", + "account_id": self.accounts["700000"].id, + "price_unit": 30, + "quantity": 3, + }, + ) + ], + } + inv_pt = self.env["account.move"].with_company(self.company).create(data) + inv_pt.action_post() + + vat_book = self.env["l10n.es.vat.book"].create( + { + "name": "Test VAT Book", + "company_id": self.company.id, + "company_vat": "ESA12345674", + "contact_name": "Test owner", + "statement_type": "N", + "support_type": "T", + "contact_phone": "911234455", + "year": "2024", + "period_type": "1T", + "date_start": "2024-01-01", + "date_end": "2024-03-31", + } + ) + vat_book.button_calculate() + + # Test Issued Tax Summary + self.assertEqual(len(vat_book.issued_tax_summary_ids), 3) + es_line = vat_book.issued_tax_summary_ids.filtered( + lambda a: a.tax_id == inv_es.invoice_line_ids.mapped("tax_ids") + ) + self.assertEqual(len(es_line), 1) + self.assertEqual(es_line.base_amount, 10) + self.assertNotEqual(es_line.tax_amount, 0) + + be_line = vat_book.issued_tax_summary_ids.filtered( + lambda a: a.tax_id == inv_be.invoice_line_ids.mapped("tax_ids") + ) + self.assertEqual(len(be_line), 1) + self.assertEqual(be_line.base_amount, 40) + self.assertEqual(be_line.tax_amount, 0) + + pt_line = vat_book.issued_tax_summary_ids.filtered( + lambda a: a.tax_id == inv_pt.invoice_line_ids.mapped("tax_ids") + ) + self.assertEqual(len(pt_line), 1) + self.assertEqual(pt_line.base_amount, 90) + self.assertEqual(pt_line.tax_amount, 0)