From 184604b35fd1efdb912a0be35a5ff3445f6c0283 Mon Sep 17 00:00:00 2001 From: eduezerouali-tecnativa Date: Tue, 26 May 2026 13:12:16 +0200 Subject: [PATCH] [ADD] sale_invoice_product_not_alone: add new module --- sale_invoice_product_not_alone/README.rst | 84 ++++ sale_invoice_product_not_alone/__init__.py | 1 + .../__manifest__.py | 15 + sale_invoice_product_not_alone/i18n/es.po | 32 ++ .../i18n/sale_invoice_product_not_alone.pot | 32 ++ .../models/__init__.py | 2 + .../models/product_template.py | 10 + .../models/sale_order_line.py | 13 + sale_invoice_product_not_alone/pyproject.toml | 3 + .../readme/CONTRIBUTORS.md | 3 + .../readme/DESCRIPTION.md | 1 + .../static/description/index.html | 433 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/test_not_invoice_alone.py | 64 +++ .../views/product_template_views.xml | 13 + 15 files changed, 707 insertions(+) create mode 100644 sale_invoice_product_not_alone/README.rst create mode 100644 sale_invoice_product_not_alone/__init__.py create mode 100644 sale_invoice_product_not_alone/__manifest__.py create mode 100644 sale_invoice_product_not_alone/i18n/es.po create mode 100644 sale_invoice_product_not_alone/i18n/sale_invoice_product_not_alone.pot create mode 100644 sale_invoice_product_not_alone/models/__init__.py create mode 100644 sale_invoice_product_not_alone/models/product_template.py create mode 100644 sale_invoice_product_not_alone/models/sale_order_line.py create mode 100644 sale_invoice_product_not_alone/pyproject.toml create mode 100644 sale_invoice_product_not_alone/readme/CONTRIBUTORS.md create mode 100644 sale_invoice_product_not_alone/readme/DESCRIPTION.md create mode 100644 sale_invoice_product_not_alone/static/description/index.html create mode 100644 sale_invoice_product_not_alone/tests/__init__.py create mode 100644 sale_invoice_product_not_alone/tests/test_not_invoice_alone.py create mode 100644 sale_invoice_product_not_alone/views/product_template_views.xml diff --git a/sale_invoice_product_not_alone/README.rst b/sale_invoice_product_not_alone/README.rst new file mode 100644 index 00000000000..a39601330de --- /dev/null +++ b/sale_invoice_product_not_alone/README.rst @@ -0,0 +1,84 @@ +========================= +Product not invoice alone +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d5d66bc2b9bb2275c721bcf662e197984d0da299b1d132c735b4c8adaf407e54 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/18.0/product_not_invoice_alone + :alt: OCA/sale-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-product_not_invoice_alone + :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/sale-workflow&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to set on product if it can be invoice alone. This +make those sale order not to appear on orders to invoice. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +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 +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__ : + + - Eduardo Ezerouali + +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/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_invoice_product_not_alone/__init__.py b/sale_invoice_product_not_alone/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/sale_invoice_product_not_alone/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_invoice_product_not_alone/__manifest__.py b/sale_invoice_product_not_alone/__manifest__.py new file mode 100644 index 00000000000..4a4ae6cc752 --- /dev/null +++ b/sale_invoice_product_not_alone/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2026 Tecnativa - Eduardo Ezerouali +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Sale invoice product not invoice alone", + "summary": "Set products to not invoice alone", + "version": "18.0.1.0.0", + "development_status": "Alpha", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/sale-workflow", + "category": "Sales Management", + "license": "AGPL-3", + "depends": ["sale"], + "data": ["views/product_template_views.xml"], + "installable": True, +} diff --git a/sale_invoice_product_not_alone/i18n/es.po b/sale_invoice_product_not_alone/i18n/es.po new file mode 100644 index 00000000000..dc4d479c9b3 --- /dev/null +++ b/sale_invoice_product_not_alone/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_invoice_product_not_alone +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-05-27 07:45+0000\n" +"PO-Revision-Date: 2026-05-27 07:45+0000\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: sale_invoice_product_not_alone +#: model:ir.model.fields,field_description:sale_invoice_product_not_alone.field_product_product__avoid_invoice_alone +#: model:ir.model.fields,field_description:sale_invoice_product_not_alone.field_product_template__avoid_invoice_alone +msgid "Avoid Invoice Alone" +msgstr "No Facturar Solo" + +#. module: sale_invoice_product_not_alone +#: model:ir.model,name:sale_invoice_product_not_alone.model_product_template +msgid "Product" +msgstr "Producto" + +#. module: sale_invoice_product_not_alone +#: model:ir.model,name:sale_invoice_product_not_alone.model_sale_order_line +msgid "Sales Order Line" +msgstr "LĂ­nea de pedido de venta" diff --git a/sale_invoice_product_not_alone/i18n/sale_invoice_product_not_alone.pot b/sale_invoice_product_not_alone/i18n/sale_invoice_product_not_alone.pot new file mode 100644 index 00000000000..2b6074db44a --- /dev/null +++ b/sale_invoice_product_not_alone/i18n/sale_invoice_product_not_alone.pot @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_invoice_product_not_alone +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-05-27 07:44+0000\n" +"PO-Revision-Date: 2026-05-27 07:44+0000\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: sale_invoice_product_not_alone +#: model:ir.model.fields,field_description:sale_invoice_product_not_alone.field_product_product__avoid_invoice_alone +#: model:ir.model.fields,field_description:sale_invoice_product_not_alone.field_product_template__avoid_invoice_alone +msgid "Avoid Invoice Alone" +msgstr "" + +#. module: sale_invoice_product_not_alone +#: model:ir.model,name:sale_invoice_product_not_alone.model_product_template +msgid "Product" +msgstr "" + +#. module: sale_invoice_product_not_alone +#: model:ir.model,name:sale_invoice_product_not_alone.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/sale_invoice_product_not_alone/models/__init__.py b/sale_invoice_product_not_alone/models/__init__.py new file mode 100644 index 00000000000..83527162d00 --- /dev/null +++ b/sale_invoice_product_not_alone/models/__init__.py @@ -0,0 +1,2 @@ +from . import product_template +from . import sale_order_line diff --git a/sale_invoice_product_not_alone/models/product_template.py b/sale_invoice_product_not_alone/models/product_template.py new file mode 100644 index 00000000000..b0684748633 --- /dev/null +++ b/sale_invoice_product_not_alone/models/product_template.py @@ -0,0 +1,10 @@ +# Copyright 2026 Tecnativa - Eduardo Ezerouali +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + avoid_invoice_alone = fields.Boolean() diff --git a/sale_invoice_product_not_alone/models/sale_order_line.py b/sale_invoice_product_not_alone/models/sale_order_line.py new file mode 100644 index 00000000000..9892e49c253 --- /dev/null +++ b/sale_invoice_product_not_alone/models/sale_order_line.py @@ -0,0 +1,13 @@ +# Copyright 2026 Tecnativa - Eduardo Ezerouali +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + def _can_be_invoiced_alone(self): + return ( + super()._can_be_invoiced_alone() and not self.product_id.avoid_invoice_alone + ) diff --git a/sale_invoice_product_not_alone/pyproject.toml b/sale_invoice_product_not_alone/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/sale_invoice_product_not_alone/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_invoice_product_not_alone/readme/CONTRIBUTORS.md b/sale_invoice_product_not_alone/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..0211491e471 --- /dev/null +++ b/sale_invoice_product_not_alone/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Tecnativa](https://www.tecnativa.com) : + - Eduardo Ezerouali + - Carlos Dauden \ No newline at end of file diff --git a/sale_invoice_product_not_alone/readme/DESCRIPTION.md b/sale_invoice_product_not_alone/readme/DESCRIPTION.md new file mode 100644 index 00000000000..72b7c48ec27 --- /dev/null +++ b/sale_invoice_product_not_alone/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module allows to set on product if it can be invoiced alone. This makes those sale orders not to appear. \ No newline at end of file diff --git a/sale_invoice_product_not_alone/static/description/index.html b/sale_invoice_product_not_alone/static/description/index.html new file mode 100644 index 00000000000..4b5a322deba --- /dev/null +++ b/sale_invoice_product_not_alone/static/description/index.html @@ -0,0 +1,433 @@ + + + + + +Product not invoice alone + + + +
+

Product not invoice alone

+ + +

Alpha License: AGPL-3 OCA/sale-workflow Translate me on Weblate Try me on Runboat

+

This module allows to set on product if it can be invoice alone. This +make those sale order not to appear on orders to invoice.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

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

+
    +
  • Tecnativa
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/sale_invoice_product_not_alone/tests/__init__.py b/sale_invoice_product_not_alone/tests/__init__.py new file mode 100644 index 00000000000..6f07ee621d5 --- /dev/null +++ b/sale_invoice_product_not_alone/tests/__init__.py @@ -0,0 +1 @@ +from . import test_not_invoice_alone diff --git a/sale_invoice_product_not_alone/tests/test_not_invoice_alone.py b/sale_invoice_product_not_alone/tests/test_not_invoice_alone.py new file mode 100644 index 00000000000..e685b14796f --- /dev/null +++ b/sale_invoice_product_not_alone/tests/test_not_invoice_alone.py @@ -0,0 +1,64 @@ +# Copyright 2026 Tecnativa - Eduardo Ezerouali +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo.addons.base.tests.common import BaseCommon + + +class TestProductCustomerInfoSale(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product_invoice_alone = cls.env["product.product"].create( + { + "name": "Product invoice alone", + "type": "consu", + "invoice_policy": "delivery", + } + ) + cls.product_not_invoice_alone = cls.env["product.product"].create( + { + "name": "Product not invoice alone", + "type": "service", + "invoice_policy": "order", + "avoid_invoice_alone": True, + } + ) + cls.partner = cls.env["res.partner"].create({"name": "Test Partner"}) + cls.sale = cls.env["sale.order"].create({"partner_id": cls.partner.id}) + + def test_01_invoice_status_no(self): + self.env["sale.order.line"].create( + [ + { + "order_id": self.sale.id, + "product_id": self.product_invoice_alone.id, + "product_uom_qty": 1.0, + }, + { + "order_id": self.sale.id, + "product_id": self.product_not_invoice_alone.id, + "product_uom_qty": 1.0, + }, + ] + ) + self.sale.action_confirm() + self.assertEqual(self.sale.invoice_status, "no") + + def test_01_invoice_status_to_invoice(self): + self.product_not_invoice_alone.avoid_invoice_alone = False + self.env["sale.order.line"].create( + [ + { + "order_id": self.sale.id, + "product_id": self.product_invoice_alone.id, + "product_uom_qty": 1.0, + }, + { + "order_id": self.sale.id, + "product_id": self.product_not_invoice_alone.id, + "product_uom_qty": 1.0, + }, + ] + ) + self.sale.action_confirm() + self.assertEqual(self.sale.invoice_status, "to invoice") diff --git a/sale_invoice_product_not_alone/views/product_template_views.xml b/sale_invoice_product_not_alone/views/product_template_views.xml new file mode 100644 index 00000000000..9be09df7d2a --- /dev/null +++ b/sale_invoice_product_not_alone/views/product_template_views.xml @@ -0,0 +1,13 @@ + + + + product.template.form.view + product.template + + + + + + + +