diff --git a/l10n_es_sigaus_stock_picking_report_valued/README.rst b/l10n_es_sigaus_stock_picking_report_valued/README.rst new file mode 100644 index 00000000000..a59ff23ecba --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/README.rst @@ -0,0 +1,89 @@ +============================ +SIGAUS Report Picking Valued +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c9f800b5f26497407e26da0525efaa1c2a389d31dba205ecadec991edc604950 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_sigaus_stock_picking_report_valued + :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_sigaus_stock_picking_report_valued + :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| + +Mostrar la aportación SIGAUS en los albaranes valorados que proceden de +un pedido de ventas. Los cálculos se realizan según el valor de cantidad +hecha si este es distinto a 0. En caso contrario, los calculos se +realizan según la cantidad reservada. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +Para que la aportación SIGAUS aparezca en el albarán valorado, el +contacto del albarán tiene que tener activada la opción "Albarán +valorado" de la pestaña "Venta y compra" de su ficha. + +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 +------------ + +- `Sygel `__: + + - Manuel Regidor + - Harald Panten + +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_sigaus_stock_picking_report_valued/__init__.py b/l10n_es_sigaus_stock_picking_report_valued/__init__.py new file mode 100644 index 00000000000..a6aeb406c0f --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2024 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/l10n_es_sigaus_stock_picking_report_valued/__manifest__.py b/l10n_es_sigaus_stock_picking_report_valued/__manifest__.py new file mode 100644 index 00000000000..734578573ae --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "SIGAUS Report Picking Valued", + "summary": "Show SIGAUS amount in valued stock pickings.", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "author": "Sygel, Odoo Community Association (OCA)", + "category": "Stock", + "website": "https://github.com/OCA/l10n-spain", + "depends": [ + "stock_picking_report_valued", + "l10n_es_sigaus_sale", + ], + "data": ["report/report_deliveryslip.xml"], + "installable": True, +} diff --git a/l10n_es_sigaus_stock_picking_report_valued/i18n/es.po b/l10n_es_sigaus_stock_picking_report_valued/i18n/es.po new file mode 100644 index 00000000000..eea67918cb8 --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/i18n/es.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_sigaus_stock_picking_report_valued +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-02-27 12:24+0000\n" +"PO-Revision-Date: 2024-02-29 00:13+0000\n" +"Last-Translator: Ivorra78 \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: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model_terms:ir.ui.view,arch_db:l10n_es_sigaus_stock_picking_report_valued.l10n_es_sigaus_report_delivery_document +msgid "SIGAUS Taxes" +msgstr "Impuesto SIGAUS" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model_terms:ir.ui.view,arch_db:l10n_es_sigaus_stock_picking_report_valued.l10n_es_sigaus_report_delivery_document +msgid "SIGAUS Untaxed Amount" +msgstr "SIGAUS Imponible" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model_terms:ir.ui.view,arch_db:l10n_es_sigaus_stock_picking_report_valued.l10n_es_sigaus_report_delivery_document +msgid "Total Picking" +msgstr "TOTAL ALBARÁN" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model_terms:ir.ui.view,arch_db:l10n_es_sigaus_stock_picking_report_valued.l10n_es_sigaus_report_delivery_document +msgid "Total SIGAUS" +msgstr "Total SIGAUS" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model_terms:ir.ui.view,arch_db:l10n_es_sigaus_stock_picking_report_valued.l10n_es_sigaus_stock_report_delivery_has_serial_move_line_sigaus +msgid "Aportación SIGAUS (RD 679/2006):" +msgstr "Aportación SIGAUS (RD 679/2006):" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_picking__picking_total_with_sigaus +msgid "Picking Total With Sigaus" +msgstr "Total de albarán con SIGAUS" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model,name:l10n_es_sigaus_stock_picking_report_valued.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "Movimientos de Producto (Stock Move Line)" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_move_line__sigaus_amount_subtotal +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_picking__sigaus_amount_subtotal +msgid "Sigaus Amount Subtotal" +msgstr "Subtotal SIGAUS" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_move_line__sigaus_amount_tax +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_picking__sigaus_amount_tax +msgid "Sigaus Amount Tax" +msgstr "Impuesto SIGAUS" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_move_line__sigaus_amount_total +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_picking__sigaus_amount_total +msgid "Sigaus Amount Total" +msgstr "Total SIGAUS" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model,name:l10n_es_sigaus_stock_picking_report_valued.model_stock_picking +msgid "Transfer" +msgstr "Albarán" diff --git a/l10n_es_sigaus_stock_picking_report_valued/i18n/l10n_es_sigaus_stock_picking_report_valued.pot b/l10n_es_sigaus_stock_picking_report_valued/i18n/l10n_es_sigaus_stock_picking_report_valued.pot new file mode 100644 index 00000000000..0497a3eb9cb --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/i18n/l10n_es_sigaus_stock_picking_report_valued.pot @@ -0,0 +1,72 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_sigaus_stock_picking_report_valued +# +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_sigaus_stock_picking_report_valued +#: model_terms:ir.ui.view,arch_db:l10n_es_sigaus_stock_picking_report_valued.l10n_es_sigaus_report_delivery_document +msgid "SIGAUS Taxes" +msgstr "" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model_terms:ir.ui.view,arch_db:l10n_es_sigaus_stock_picking_report_valued.l10n_es_sigaus_report_delivery_document +msgid "SIGAUS Untaxed Amount" +msgstr "" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model_terms:ir.ui.view,arch_db:l10n_es_sigaus_stock_picking_report_valued.l10n_es_sigaus_report_delivery_document +msgid "Total Picking" +msgstr "" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model_terms:ir.ui.view,arch_db:l10n_es_sigaus_stock_picking_report_valued.l10n_es_sigaus_report_delivery_document +msgid "Total SIGAUS" +msgstr "" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model_terms:ir.ui.view,arch_db:l10n_es_sigaus_stock_picking_report_valued.l10n_es_sigaus_stock_report_delivery_has_serial_move_line_sigaus +msgid "Aportación SIGAUS (RD 679/2006):" +msgstr "" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_picking__picking_total_with_sigaus +msgid "Picking Total With Sigaus" +msgstr "" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model,name:l10n_es_sigaus_stock_picking_report_valued.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_move_line__sigaus_amount_subtotal +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_picking__sigaus_amount_subtotal +msgid "Sigaus Amount Subtotal" +msgstr "" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_move_line__sigaus_amount_tax +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_picking__sigaus_amount_tax +msgid "Sigaus Amount Tax" +msgstr "" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_move_line__sigaus_amount_total +#: model:ir.model.fields,field_description:l10n_es_sigaus_stock_picking_report_valued.field_stock_picking__sigaus_amount_total +msgid "Sigaus Amount Total" +msgstr "" + +#. module: l10n_es_sigaus_stock_picking_report_valued +#: model:ir.model,name:l10n_es_sigaus_stock_picking_report_valued.model_stock_picking +msgid "Transfer" +msgstr "" diff --git a/l10n_es_sigaus_stock_picking_report_valued/models/__init__.py b/l10n_es_sigaus_stock_picking_report_valued/models/__init__.py new file mode 100644 index 00000000000..29c35f6c391 --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2024 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import stock_picking +from . import stock_move_line diff --git a/l10n_es_sigaus_stock_picking_report_valued/models/stock_move_line.py b/l10n_es_sigaus_stock_picking_report_valued/models/stock_move_line.py new file mode 100644 index 00000000000..07f097e499f --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/models/stock_move_line.py @@ -0,0 +1,73 @@ +# Copyright 2024 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + sigaus_amount_subtotal = fields.Monetary( + compute="_compute_sigaus_amount", compute_sudo=True + ) + sigaus_amount_tax = fields.Monetary( + compute="_compute_sigaus_amount", compute_sudo=True + ) + sigaus_amount_total = fields.Monetary( + compute="_compute_sigaus_amount", compute_sudo=True + ) + + def _get_sigaus_product_taxes(self, sigaus_product): + self.ensure_one() + taxes = sigaus_product.taxes_id + if not taxes: + return False + fiscal_position = self.sale_line.order_id.fiscal_position_id + return fiscal_position.map_tax(taxes) + + def _get_sigaus_product_taxes_values(self, sigaus_product, price, qty): + self.ensure_one() + return self.env["account.tax"]._convert_to_tax_base_line_dict( + self, + partner=self.sale_line.order_partner_id, + currency=self.currency_id, + product=sigaus_product, + taxes=self._get_sigaus_product_taxes(sigaus_product), + price_unit=price, + quantity=qty, + ) + + @api.depends("product_id", "date", "quantity_product_uom") + def _compute_sigaus_amount(self): + for line in self: + subtotal = 0.0 + tax_amount = 0.0 + total = 0.0 + if ( + line.product_id + and line.sale_line + and line.sale_line.order_id.is_sigaus + and line.product_id.sigaus_has_amount + ): + sigaus_product_id = self.env.ref( + "l10n_es_sigaus_account.aportacion_sigaus_product_template" + ) + price = self.env["l10n.es.sigaus.amount"].get_sigaus_amount( + line.sale_line.order_id.date_order + ) + quantity = line._get_report_valued_quantity() + weight = quantity * line.product_id.weight + tax_results = self.env["account.tax"]._compute_taxes( + [ + line._get_sigaus_product_taxes_values( + sigaus_product_id, price, weight + ) + ] + ) + totals = list(tax_results["totals"].values())[0] + subtotal = totals["amount_untaxed"] + tax_amount = totals["amount_tax"] + total = subtotal + tax_amount + line.sigaus_amount_subtotal = subtotal + line.sigaus_amount_tax = tax_amount + line.sigaus_amount_total = total diff --git a/l10n_es_sigaus_stock_picking_report_valued/models/stock_picking.py b/l10n_es_sigaus_stock_picking_report_valued/models/stock_picking.py new file mode 100644 index 00000000000..0f8d06f0975 --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/models/stock_picking.py @@ -0,0 +1,41 @@ +# Copyright 2024 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + sigaus_amount_subtotal = fields.Monetary( + compute="_compute_sigaus_amount", compute_sudo=True + ) + sigaus_amount_tax = fields.Monetary( + compute="_compute_sigaus_amount", compute_sudo=True + ) + sigaus_amount_total = fields.Monetary( + compute="_compute_sigaus_amount", compute_sudo=True + ) + picking_total_with_sigaus = fields.Monetary( + compute="_compute_sigaus_amount", compute_sudo=True + ) + + @api.depends( + "amount_total", + "move_line_ids.sigaus_amount_subtotal", + "move_line_ids.sigaus_amount_tax", + "move_line_ids.sigaus_amount_total", + ) + def _compute_sigaus_amount(self): + for pick in self: + sigaus_amount_subtotal = sigaus_amount_tax = sigaus_amount_total = 0.0 + for line in pick.move_line_ids: + sigaus_amount_subtotal += line.sigaus_amount_subtotal + sigaus_amount_tax += line.sigaus_amount_tax + sigaus_amount_total += line.sigaus_amount_total + pick.sigaus_amount_subtotal = sigaus_amount_subtotal + pick.sigaus_amount_tax = sigaus_amount_tax + pick.sigaus_amount_total = sigaus_amount_total + pick.picking_total_with_sigaus = ( + pick.sigaus_amount_total + pick.amount_total + ) diff --git a/l10n_es_sigaus_stock_picking_report_valued/pyproject.toml b/l10n_es_sigaus_stock_picking_report_valued/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_es_sigaus_stock_picking_report_valued/readme/CONFIGURE.md b/l10n_es_sigaus_stock_picking_report_valued/readme/CONFIGURE.md new file mode 100644 index 00000000000..4e65ce34d7c --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/readme/CONFIGURE.md @@ -0,0 +1,3 @@ +Para que la aportación SIGAUS aparezca en el albarán valorado, el +contacto del albarán tiene que tener activada la opción "Albarán +valorado" de la pestaña "Venta y compra" de su ficha. diff --git a/l10n_es_sigaus_stock_picking_report_valued/readme/CONTRIBUTORS.md b/l10n_es_sigaus_stock_picking_report_valued/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..a145e20869a --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Sygel](https://www.sygel.es): + - Manuel Regidor \<\> + - Harald Panten \<\> diff --git a/l10n_es_sigaus_stock_picking_report_valued/readme/DESCRIPTION.md b/l10n_es_sigaus_stock_picking_report_valued/readme/DESCRIPTION.md new file mode 100644 index 00000000000..c58189a8150 --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +Mostrar la aportación SIGAUS en los albaranes valorados que proceden de +un pedido de ventas. Los cálculos se realizan según el valor de cantidad +hecha si este es distinto a 0. En caso contrario, los calculos se +realizan según la cantidad reservada. diff --git a/l10n_es_sigaus_stock_picking_report_valued/report/report_deliveryslip.xml b/l10n_es_sigaus_stock_picking_report_valued/report/report_deliveryslip.xml new file mode 100644 index 00000000000..e1d25a74c69 --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/report/report_deliveryslip.xml @@ -0,0 +1,71 @@ + + + + + diff --git a/l10n_es_sigaus_stock_picking_report_valued/static/description/icon.png b/l10n_es_sigaus_stock_picking_report_valued/static/description/icon.png new file mode 100644 index 00000000000..af0c57f04d6 Binary files /dev/null and b/l10n_es_sigaus_stock_picking_report_valued/static/description/icon.png differ diff --git a/l10n_es_sigaus_stock_picking_report_valued/static/description/icon.svg b/l10n_es_sigaus_stock_picking_report_valued/static/description/icon.svg new file mode 100644 index 00000000000..43822ac2c88 --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/static/description/icon.svg @@ -0,0 +1,350 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/l10n_es_sigaus_stock_picking_report_valued/static/description/index.html b/l10n_es_sigaus_stock_picking_report_valued/static/description/index.html new file mode 100644 index 00000000000..6f7cc062400 --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +SIGAUS Report Picking Valued + + + +
+

SIGAUS Report Picking Valued

+ + +

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

+

Mostrar la aportación SIGAUS en los albaranes valorados que proceden de +un pedido de ventas. Los cálculos se realizan según el valor de cantidad +hecha si este es distinto a 0. En caso contrario, los calculos se +realizan según la cantidad reservada.

+

Table of contents

+ +
+

Configuration

+

Para que la aportación SIGAUS aparezca en el albarán valorado, el +contacto del albarán tiene que tener activada la opción “Albarán +valorado” de la pestaña “Venta y compra” de su ficha.

+
+
+

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_sigaus_stock_picking_report_valued/tests/__init__.py b/l10n_es_sigaus_stock_picking_report_valued/tests/__init__.py new file mode 100644 index 00000000000..4de10d36be9 --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/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_sigaus_stock_picking_report_valued diff --git a/l10n_es_sigaus_stock_picking_report_valued/tests/test_l10n_es_sigaus_stock_picking_report_valued.py b/l10n_es_sigaus_stock_picking_report_valued/tests/test_l10n_es_sigaus_stock_picking_report_valued.py new file mode 100644 index 00000000000..c9b666a94e3 --- /dev/null +++ b/l10n_es_sigaus_stock_picking_report_valued/tests/test_l10n_es_sigaus_stock_picking_report_valued.py @@ -0,0 +1,84 @@ +# Copyright 2024 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.addons.l10n_es_sigaus_account.tests.common import TestL10nEsSigausCommon + + +class TestL10nEsSigausStockPickingReportValued(TestL10nEsSigausCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.tax = cls.env["account.tax"].create( + {"name": "Tax 21.0%", "amount": 21.0, "amount_type": "percent"} + ) + cls.env.ref("l10n_es_sigaus_account.aportacion_sigaus_product_template").write( + {"taxes_id": [cls.tax.id]} + ) + + def test_valued_picking_sigaus_amount(self): + sale = self.env["sale.order"].create( + { + "company_id": self.company.id, + "partner_id": self.partner.id, + "date_order": "2023-01-01", + "fiscal_position_id": self.fiscal_position_sigaus.id, + "order_line": [ + ( + 0, + False, + { + "product_id": self.product_sigaus_in_product.id, + "product_uom_qty": 10, + "price_unit": 2, + "tax_id": [self.tax.id], + }, + ) + ], + } + ) + sale.action_confirm() + sale.write({"date_order": "2023-01-01"}) + picking = sale.picking_ids + + # No 'done' quantity + line = picking.move_line_ids + self.assertAlmostEqual(line.sigaus_amount_subtotal, 0.6, places=2) + self.assertAlmostEqual(line.sigaus_amount_tax, 0.126, places=2) + self.assertAlmostEqual(line.sigaus_amount_total, 0.726, places=2) + self.assertAlmostEqual(picking.sigaus_amount_subtotal, 0.6, places=2) + self.assertAlmostEqual(picking.sigaus_amount_tax, 0.126, places=2) + self.assertAlmostEqual(picking.sigaus_amount_total, 0.726, places=2) + self.assertAlmostEqual( + picking.picking_total_with_sigaus, sale.amount_total, places=2 + ) + + # With 'done' quantity + line.write({"quantity_product_uom": 6}) + # Force amounts recomputation, as stock_picking_report_valued module d + # does not do it + line._compute_sale_order_line_fields() + picking._compute_amount_all() + self.assertAlmostEqual(line.sigaus_amount_subtotal, 0.36, places=2) + self.assertAlmostEqual(line.sigaus_amount_tax, 0.0756, places=2) + self.assertAlmostEqual(line.sigaus_amount_total, 0.4356, places=2) + self.assertAlmostEqual(picking.sigaus_amount_subtotal, 0.36, places=2) + self.assertAlmostEqual(picking.sigaus_amount_tax, 0.0756, places=2) + self.assertAlmostEqual(picking.sigaus_amount_total, 0.4356, places=2) + self.assertAlmostEqual(picking.picking_total_with_sigaus, 14.9556, places=2) + + # All 'done' + line.write({"quantity_product_uom": 10}) + # Force amounts recomputation, as stock_picking_report_valued module d + # does not do it + line._compute_sale_order_line_fields() + picking._compute_amount_all() + self.assertAlmostEqual(line.sigaus_amount_subtotal, 0.6, places=2) + self.assertAlmostEqual(line.sigaus_amount_tax, 0.126, places=2) + self.assertAlmostEqual(line.sigaus_amount_total, 0.726, places=2) + self.assertAlmostEqual(picking.sigaus_amount_subtotal, 0.6, places=2) + self.assertAlmostEqual(picking.sigaus_amount_tax, 0.126, places=2) + self.assertAlmostEqual(picking.sigaus_amount_total, 0.726, places=2) + self.assertAlmostEqual( + picking.picking_total_with_sigaus, sale.amount_total, places=2 + )