diff --git a/sale_order_whole_delivered_invoiceability/README.rst b/sale_order_whole_delivered_invoiceability/README.rst new file mode 100644 index 00000000000..4784d05b607 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/README.rst @@ -0,0 +1,100 @@ +========================================= +Sale Order Whole Delivered Invoiceability +========================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d41a21754b0e3e1281e8d05a8276d9b5aff794c2e7d2959ce8e04d5e055fa7e5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Faccount--invoicing-lightgray.png?logo=github + :target: https://github.com/OCA/account-invoicing/tree/17.0/sale_order_whole_delivered_invoiceability + :alt: OCA/account-invoicing +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-invoicing-17-0/account-invoicing-17-0-sale_order_whole_delivered_invoiceability + :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/account-invoicing&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module prevents the invoiceability of the sale orders until all the +stockable products has been delivered. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +1. Create a new storable product +2. Set its invoicing policy as "Delivered Quantities". + +Usage +===== + +To use this module you need to: + +1. Go to a customer that you do not want to invoice for incomplete + deliveries and check the option ‘Whole Delivered Invoiceability’. +2. Create a sales order and do a partial delivery. + +Although it is possible to create an invoice from the order itself, the +‘Create invoice’ button will remain white and the order will not appear +in the list of orders to be invoiced, which can be consulted from the +‘To invoice’ menu. + +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 `__: + + - Pedro M. Baeza + - Pilar Vargas + +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/account-invoicing `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_order_whole_delivered_invoiceability/__init__.py b/sale_order_whole_delivered_invoiceability/__init__.py new file mode 100644 index 00000000000..69f7babdfb1 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/sale_order_whole_delivered_invoiceability/__manifest__.py b/sale_order_whole_delivered_invoiceability/__manifest__.py new file mode 100644 index 00000000000..34f715ed866 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2024 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Sale Order Whole Delivered Invoiceability", + "version": "17.0.1.0.0", + "category": "Sales Management", + "license": "AGPL-3", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-invoicing", + "depends": ["sale"], + "data": ["views/res_partner_view.xml", "views/sale_order_view.xml"], + "installable": True, +} diff --git a/sale_order_whole_delivered_invoiceability/i18n/es.po b/sale_order_whole_delivered_invoiceability/i18n/es.po new file mode 100644 index 00000000000..dca211a3975 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/i18n/es.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_order_whole_delivered_invoiceability +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-09-03 16:50+0000\n" +"PO-Revision-Date: 2024-09-03 18:54+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: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.0.1\n" + +#. module: sale_order_whole_delivered_invoiceability +#: model:ir.model,name:sale_order_whole_delivered_invoiceability.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: sale_order_whole_delivered_invoiceability +#: model_terms:ir.ui.view,arch_db:sale_order_whole_delivered_invoiceability.view_sales_order_filter +msgid "Partial orders not invoiced" +msgstr "Pedidos parciales no facturados" + +#. module: sale_order_whole_delivered_invoiceability +#: model:ir.model.fields,help:sale_order_whole_delivered_invoiceability.field_res_partner__whole_delivered_invoiceability +#: model:ir.model.fields,help:sale_order_whole_delivered_invoiceability.field_res_users__whole_delivered_invoiceability +msgid "Prevent invoicing until everything has been delivered." +msgstr "Evitar la facturación hasta que se haya entregado todo." + +#. module: sale_order_whole_delivered_invoiceability +#: model:ir.model,name:sale_order_whole_delivered_invoiceability.model_sale_order +msgid "Sales Order" +msgstr "Órdenes de Venta" + +#. module: sale_order_whole_delivered_invoiceability +#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_res_partner__whole_delivered_invoiceability +#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_res_users__whole_delivered_invoiceability +#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_sale_order__whole_delivered_invoiceability +msgid "Whole Delivered Invoiceability" +msgstr "Facturación de entregas completas" diff --git a/sale_order_whole_delivered_invoiceability/i18n/sale_order_whole_delivered_invoiceability.pot b/sale_order_whole_delivered_invoiceability/i18n/sale_order_whole_delivered_invoiceability.pot new file mode 100644 index 00000000000..c92d8631fef --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/i18n/sale_order_whole_delivered_invoiceability.pot @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_order_whole_delivered_invoiceability +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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: sale_order_whole_delivered_invoiceability +#: model:ir.model,name:sale_order_whole_delivered_invoiceability.model_res_partner +msgid "Contact" +msgstr "" + +#. module: sale_order_whole_delivered_invoiceability +#: model_terms:ir.ui.view,arch_db:sale_order_whole_delivered_invoiceability.view_sales_order_filter +msgid "Partial orders not invoiced" +msgstr "" + +#. module: sale_order_whole_delivered_invoiceability +#: model:ir.model.fields,help:sale_order_whole_delivered_invoiceability.field_res_partner__whole_delivered_invoiceability +#: model:ir.model.fields,help:sale_order_whole_delivered_invoiceability.field_res_users__whole_delivered_invoiceability +msgid "Prevent invoicing until everything has been delivered." +msgstr "" + +#. module: sale_order_whole_delivered_invoiceability +#: model:ir.model,name:sale_order_whole_delivered_invoiceability.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_order_whole_delivered_invoiceability +#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_res_partner__whole_delivered_invoiceability +#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_res_users__whole_delivered_invoiceability +#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_sale_order__whole_delivered_invoiceability +msgid "Whole Delivered Invoiceability" +msgstr "" diff --git a/sale_order_whole_delivered_invoiceability/models/__init__.py b/sale_order_whole_delivered_invoiceability/models/__init__.py new file mode 100644 index 00000000000..b66355c63c1 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import res_partner +from . import sale_order diff --git a/sale_order_whole_delivered_invoiceability/models/res_partner.py b/sale_order_whole_delivered_invoiceability/models/res_partner.py new file mode 100644 index 00000000000..0ae03ea239c --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/models/res_partner.py @@ -0,0 +1,18 @@ +# Copyright 2024 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + whole_delivered_invoiceability = fields.Boolean( + help="Prevent invoicing until everything has been delivered." + ) + + @api.model + def _commercial_fields(self): + """Add this field to commercial fields, as it should be propagated + to children. + """ + return super()._commercial_fields() + ["whole_delivered_invoiceability"] diff --git a/sale_order_whole_delivered_invoiceability/models/sale_order.py b/sale_order_whole_delivered_invoiceability/models/sale_order.py new file mode 100644 index 00000000000..18d0d6a3e66 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/models/sale_order.py @@ -0,0 +1,40 @@ +# Copyright 2024 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, fields, models +from odoo.tools import float_compare + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + whole_delivered_invoiceability = fields.Boolean( + compute="_compute_whole_delivered_invoiceability", + store=True, + readonly=False, + ) + + @api.depends("partner_id") + def _compute_whole_delivered_invoiceability(self): + for record in self: + if record.partner_id.whole_delivered_invoiceability: + record.whole_delivered_invoiceability = True + + @api.depends("whole_delivered_invoiceability") + def _compute_invoice_status(self): + # Intercept the invoice_status computed method to + # set it as not invoiceable if the delivered quantity + # is less than the ordered quantity. + res = super()._compute_invoice_status() + for order in self.filtered("whole_delivered_invoiceability"): + uncomplete_lines = order.order_line.filtered( + lambda line: line.product_id.invoice_policy == "delivery" + and float_compare( + line.product_uom_qty, + line.qty_delivered, + precision_rounding=line.product_uom.rounding, + ) + > 0 + ) + if uncomplete_lines: + order.invoice_status = "no" + return res diff --git a/sale_order_whole_delivered_invoiceability/pyproject.toml b/sale_order_whole_delivered_invoiceability/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_order_whole_delivered_invoiceability/readme/CONFIGURE.md b/sale_order_whole_delivered_invoiceability/readme/CONFIGURE.md new file mode 100644 index 00000000000..e91f5b7d601 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/readme/CONFIGURE.md @@ -0,0 +1,2 @@ +1. Create a new storable product +2. Set its invoicing policy as "Delivered Quantities". diff --git a/sale_order_whole_delivered_invoiceability/readme/CONTRIBUTORS.md b/sale_order_whole_delivered_invoiceability/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..a064898e338 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Tecnativa](https://www.tecnativa.com): + - Pedro M. Baeza + - Pilar Vargas diff --git a/sale_order_whole_delivered_invoiceability/readme/DESCRIPTION.md b/sale_order_whole_delivered_invoiceability/readme/DESCRIPTION.md new file mode 100644 index 00000000000..c18fab7df4e --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module prevents the invoiceability of the sale orders until all the +stockable products has been delivered. diff --git a/sale_order_whole_delivered_invoiceability/readme/USAGE.md b/sale_order_whole_delivered_invoiceability/readme/USAGE.md new file mode 100644 index 00000000000..05f50d413d3 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/readme/USAGE.md @@ -0,0 +1,10 @@ +To use this module you need to: + +1. Go to a customer that you do not want to invoice for incomplete + deliveries and check the option ‘Whole Delivered Invoiceability’. +2. Create a sales order and do a partial delivery. + +Although it is possible to create an invoice from the order itself, the +‘Create invoice’ button will remain white and the order will not appear +in the list of orders to be invoiced, which can be consulted from the +‘To invoice’ menu. diff --git a/sale_order_whole_delivered_invoiceability/static/description/icon.png b/sale_order_whole_delivered_invoiceability/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_order_whole_delivered_invoiceability/static/description/icon.png differ diff --git a/sale_order_whole_delivered_invoiceability/static/description/index.html b/sale_order_whole_delivered_invoiceability/static/description/index.html new file mode 100644 index 00000000000..d9c896c64d1 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/static/description/index.html @@ -0,0 +1,450 @@ + + + + + +Sale Order Whole Delivered Invoiceability + + + +
+

Sale Order Whole Delivered Invoiceability

+ + +

Beta License: AGPL-3 OCA/account-invoicing Translate me on Weblate Try me on Runboat

+

This module prevents the invoiceability of the sale orders until all the +stockable products has been delivered.

+

Table of contents

+ +
+

Configuration

+
    +
  1. Create a new storable product
  2. +
  3. Set its invoicing policy as “Delivered Quantities”.
  4. +
+
+
+

Usage

+

To use this module you need to:

+
    +
  1. Go to a customer that you do not want to invoice for incomplete +deliveries and check the option ‘Whole Delivered Invoiceability’.
  2. +
  3. Create a sales order and do a partial delivery.
  4. +
+

Although it is possible to create an invoice from the order itself, the +‘Create invoice’ button will remain white and the order will not appear +in the list of orders to be invoiced, which can be consulted from the +‘To invoice’ menu.

+
+
+

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:
      +
    • Pedro M. Baeza
    • +
    • Pilar Vargas
    • +
    +
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/sale_order_whole_delivered_invoiceability/tests/__init__.py b/sale_order_whole_delivered_invoiceability/tests/__init__.py new file mode 100644 index 00000000000..39809b5539d --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_sale_order_whole_delivered_invoiceability diff --git a/sale_order_whole_delivered_invoiceability/tests/test_sale_order_whole_delivered_invoiceability.py b/sale_order_whole_delivered_invoiceability/tests/test_sale_order_whole_delivered_invoiceability.py new file mode 100644 index 00000000000..53d6caa8514 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/tests/test_sale_order_whole_delivered_invoiceability.py @@ -0,0 +1,60 @@ +# Copyright 2024 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import TransactionCase + + +class TestSaleOrderWholeDeliveredInvoiceability(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.partner = cls.env["res.partner"].create( + {"name": "Test partner", "whole_delivered_invoiceability": True} + ) + cls.product_1 = cls.env["product.product"].create( + { + "name": "Test product One", + "invoice_policy": "delivery", + } + ) + cls.product_2 = cls.env["product.product"].create( + { + "name": "Test product Two", + "invoice_policy": "delivery", + } + ) + cls.order = cls.env["sale.order"].create( + { + "partner_id": cls.partner.id, + "order_line": [ + ( + 0, + 0, + { + "name": cls.product_1.name, + "product_id": cls.product_1.id, + "product_uom_qty": 5, + "qty_delivered": 2, + }, + ), + ( + 0, + 0, + { + "name": cls.product_2.name, + "product_id": cls.product_2.id, + "product_uom_qty": 5, + "qty_delivered": 5, + }, + ), + ], + } + ) + + def test_whole_delivered_invoiceability_partner(self): + self.assertTrue(self.order.whole_delivered_invoiceability) + + def test_whole_delivered_invoiceability(self): + self.order.action_confirm() + self.assertEqual(self.order.invoice_status, "no") diff --git a/sale_order_whole_delivered_invoiceability/views/res_partner_view.xml b/sale_order_whole_delivered_invoiceability/views/res_partner_view.xml new file mode 100644 index 00000000000..ee3c7b58390 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/views/res_partner_view.xml @@ -0,0 +1,13 @@ + + + + res.partner.sale_type.form + res.partner + + + + + + + + diff --git a/sale_order_whole_delivered_invoiceability/views/sale_order_view.xml b/sale_order_whole_delivered_invoiceability/views/sale_order_view.xml new file mode 100644 index 00000000000..f9d18ec1106 --- /dev/null +++ b/sale_order_whole_delivered_invoiceability/views/sale_order_view.xml @@ -0,0 +1,19 @@ + + + + sale.order + + + + + + + +