diff --git a/sale_force_whole_invoiceability/README.rst b/sale_force_whole_invoiceability/README.rst new file mode 100644 index 00000000000..befc8e508b0 --- /dev/null +++ b/sale_force_whole_invoiceability/README.rst @@ -0,0 +1,106 @@ +=============================== +Sale Force Whole Invoiceability +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c307171123869ac2242cef71c1fe3bc46f5616b8559076c40f7af3a1fda042f5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/17.0/sale_force_whole_invoiceability + :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-17-0/sale-workflow-17-0-sale_force_whole_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/sale-workflow&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to the sale managers to force all the lines to +invoice independently of the invoice policy and the delivered quantities +of the products. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +1. Make a sale order with products with a delivered quantities invoice + policy. +2. Confirm the order. +3. If you try to invoice the order, you can't as the quantities aren't + delivered. +4. But if you are a Sales Manager, you have a new button *Force Invoice + Policy* +5. Once clicked, you can invoice all the lines as if they were already + delivered. + +Known issues / Roadmap +====================== + +- Modifiying the original demand after the forcing could lead to + misscalculations. + +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 `__: + + - David Vidal + +- `Sygel `__: + + - Valentín Vinagre + - Roger Sans + +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_force_whole_invoiceability/__init__.py b/sale_force_whole_invoiceability/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/sale_force_whole_invoiceability/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_force_whole_invoiceability/__manifest__.py b/sale_force_whole_invoiceability/__manifest__.py new file mode 100644 index 00000000000..f04c2fd44e9 --- /dev/null +++ b/sale_force_whole_invoiceability/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2021 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Sale Force Whole Invoiceability", + "version": "18.0.1.0.0", + "category": "Sales", + "author": "Tecnativa," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/sale-workflow", + "license": "AGPL-3", + "depends": ["sale"], + "data": ["views/sale_order_views.xml"], + "installable": True, +} diff --git a/sale_force_whole_invoiceability/i18n/es.po b/sale_force_whole_invoiceability/i18n/es.po new file mode 100644 index 00000000000..592f2678de2 --- /dev/null +++ b/sale_force_whole_invoiceability/i18n/es.po @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_force_whole_invoiceability +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-02-05 16:06+0000\n" +"PO-Revision-Date: 2023-07-25 11:09+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: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: sale_force_whole_invoiceability +#: model_terms:ir.ui.view,arch_db:sale_force_whole_invoiceability.view_order_form +msgid "Force Invoice Policy" +msgstr "Forzar Política de Facturación" + +#. module: sale_force_whole_invoiceability +#. odoo-python +#: code:addons/sale_force_whole_invoiceability/models/sale_order.py:0 +#, python-format +msgid "Only Sales Managers are allowed to force the lines to invoice" +msgstr "" +"Solo los Responsables de Ventas tienen permiso para forzar las líneas a " +"facturar" + +#. module: sale_force_whole_invoiceability +#: model:ir.model,name:sale_force_whole_invoiceability.model_sale_order +msgid "Sales Order" +msgstr "Órdenes de venta" + +#. module: sale_force_whole_invoiceability +#. odoo-python +#: code:addons/sale_force_whole_invoiceability/models/sale_order.py:0 +#, python-format +msgid "" +"You can't perform this action once the order has been invoiced once already" +msgstr "" +"No puedes ejecutar esta acción una vez que el pedido ya ha sido facturado " +"una vez" + +#. module: sale_force_whole_invoiceability +#. odoo-python +#: code:addons/sale_force_whole_invoiceability/models/sale_order.py:0 +#, python-format +msgid "You can't perform this action over a sale order in this state" +msgstr "No puedes ejecutar esta acción sobre una venta que está en este estado" + +#~ msgid "Sale Order" +#~ msgstr "Pedido de venta" diff --git a/sale_force_whole_invoiceability/i18n/it.po b/sale_force_whole_invoiceability/i18n/it.po new file mode 100644 index 00000000000..83285f083ca --- /dev/null +++ b/sale_force_whole_invoiceability/i18n/it.po @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_force_whole_invoiceability +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-07-30 08:58+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\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 5.6.2\n" + +#. module: sale_force_whole_invoiceability +#: model_terms:ir.ui.view,arch_db:sale_force_whole_invoiceability.view_order_form +msgid "Force Invoice Policy" +msgstr "Forza politica fattura" + +#. module: sale_force_whole_invoiceability +#. odoo-python +#: code:addons/sale_force_whole_invoiceability/models/sale_order.py:0 +#, python-format +msgid "Only Sales Managers are allowed to force the lines to invoice" +msgstr "" +"Solo i responsabili vendite sono autorizzati a forzare le righe da fatturare" + +#. module: sale_force_whole_invoiceability +#: model:ir.model,name:sale_force_whole_invoiceability.model_sale_order +msgid "Sales Order" +msgstr "Ordine di vendita" + +#. module: sale_force_whole_invoiceability +#. odoo-python +#: code:addons/sale_force_whole_invoiceability/models/sale_order.py:0 +#, python-format +msgid "" +"You can't perform this action once the order has been invoiced once already" +msgstr "" +"Non si può eseguire questa azione una volta che l'ordine è stato già " +"fatturato" + +#. module: sale_force_whole_invoiceability +#. odoo-python +#: code:addons/sale_force_whole_invoiceability/models/sale_order.py:0 +#, python-format +msgid "You can't perform this action over a sale order in this state" +msgstr "" +"Non si può eseguire questa azione su un ordine di vendita in questo stato" diff --git a/sale_force_whole_invoiceability/i18n/sale_force_whole_invoiceability.pot b/sale_force_whole_invoiceability/i18n/sale_force_whole_invoiceability.pot new file mode 100644 index 00000000000..b8a35e9c599 --- /dev/null +++ b/sale_force_whole_invoiceability/i18n/sale_force_whole_invoiceability.pot @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_force_whole_invoiceability +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_force_whole_invoiceability +#: model_terms:ir.ui.view,arch_db:sale_force_whole_invoiceability.view_order_form +msgid "Force Invoice Policy" +msgstr "" + +#. module: sale_force_whole_invoiceability +#. odoo-python +#: code:addons/sale_force_whole_invoiceability/models/sale_order.py:0 +#, python-format +msgid "Only Sales Managers are allowed to force the lines to invoice" +msgstr "" + +#. module: sale_force_whole_invoiceability +#: model:ir.model,name:sale_force_whole_invoiceability.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_force_whole_invoiceability +#. odoo-python +#: code:addons/sale_force_whole_invoiceability/models/sale_order.py:0 +#, python-format +msgid "" +"You can't perform this action once the order has been invoiced once already" +msgstr "" + +#. module: sale_force_whole_invoiceability +#. odoo-python +#: code:addons/sale_force_whole_invoiceability/models/sale_order.py:0 +#, python-format +msgid "You can't perform this action over a sale order in this state" +msgstr "" diff --git a/sale_force_whole_invoiceability/models/__init__.py b/sale_force_whole_invoiceability/models/__init__.py new file mode 100644 index 00000000000..6aacb753131 --- /dev/null +++ b/sale_force_whole_invoiceability/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order diff --git a/sale_force_whole_invoiceability/models/sale_order.py b/sale_force_whole_invoiceability/models/sale_order.py new file mode 100644 index 00000000000..c31cef0896f --- /dev/null +++ b/sale_force_whole_invoiceability/models/sale_order.py @@ -0,0 +1,31 @@ +# Copyright 2021 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import models +from odoo.exceptions import UserError + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + def force_lines_to_invoice_policy_order(self): + """Wrapper to launch the private method from UI""" + if not self.env.user.has_group("sales_team.group_sale_manager"): + raise UserError( + self.env._( + "Only Sales Managers are allowed to force the lines to invoice" + ) + ) + if self.state != "sale": + raise UserError( + self.env._( + "You can't perform this action over a sale order in this state" + ) + ) + if self.invoice_count: + raise UserError( + self.env._( + "You can't perform this action once the order has been " + "invoiced once already" + ) + ) + self._force_lines_to_invoice_policy_order() diff --git a/sale_force_whole_invoiceability/pyproject.toml b/sale_force_whole_invoiceability/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/sale_force_whole_invoiceability/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_force_whole_invoiceability/readme/CONTRIBUTORS.md b/sale_force_whole_invoiceability/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..75a87892e80 --- /dev/null +++ b/sale_force_whole_invoiceability/readme/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +- [Tecnativa](https://www.tecnativa.com): + - David Vidal + +- [Sygel](https://www.sygel.es): + - Valentín Vinagre + - Roger Sans diff --git a/sale_force_whole_invoiceability/readme/DESCRIPTION.md b/sale_force_whole_invoiceability/readme/DESCRIPTION.md new file mode 100644 index 00000000000..32a7997d0fd --- /dev/null +++ b/sale_force_whole_invoiceability/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module allows to the sale managers to force all the lines to +invoice independently of the invoice policy and the delivered quantities +of the products. diff --git a/sale_force_whole_invoiceability/readme/ROADMAP.md b/sale_force_whole_invoiceability/readme/ROADMAP.md new file mode 100644 index 00000000000..ad3ea8fa81a --- /dev/null +++ b/sale_force_whole_invoiceability/readme/ROADMAP.md @@ -0,0 +1,2 @@ +- Modifiying the original demand after the forcing could lead to + misscalculations. diff --git a/sale_force_whole_invoiceability/readme/USAGE.md b/sale_force_whole_invoiceability/readme/USAGE.md new file mode 100644 index 00000000000..92bf57d18a2 --- /dev/null +++ b/sale_force_whole_invoiceability/readme/USAGE.md @@ -0,0 +1,11 @@ +To use this module, you need to: + +1. Make a sale order with products with a delivered quantities invoice + policy. +2. Confirm the order. +3. If you try to invoice the order, you can't as the quantities aren't + delivered. +4. But if you are a Sales Manager, you have a new button *Force Invoice + Policy* +5. Once clicked, you can invoice all the lines as if they were already + delivered. diff --git a/sale_force_whole_invoiceability/static/description/icon.png b/sale_force_whole_invoiceability/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_force_whole_invoiceability/static/description/icon.png differ diff --git a/sale_force_whole_invoiceability/static/description/index.html b/sale_force_whole_invoiceability/static/description/index.html new file mode 100644 index 00000000000..17dc6fb512f --- /dev/null +++ b/sale_force_whole_invoiceability/static/description/index.html @@ -0,0 +1,457 @@ + + + + + +Sale Force Whole Invoiceability + + + +
+

Sale Force Whole Invoiceability

+ + +

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

+

This module allows to the sale managers to force all the lines to +invoice independently of the invoice policy and the delivered quantities +of the products.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Make a sale order with products with a delivered quantities invoice +policy.
  2. +
  3. Confirm the order.
  4. +
  5. If you try to invoice the order, you can’t as the quantities aren’t +delivered.
  6. +
  7. But if you are a Sales Manager, you have a new button Force Invoice +Policy
  8. +
  9. Once clicked, you can invoice all the lines as if they were already +delivered.
  10. +
+
+
+

Known issues / Roadmap

+
    +
  • Modifiying the original demand after the forcing could lead to +misscalculations.
  • +
+
+
+

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:
      +
    • David Vidal
    • +
    +
  • +
  • Sygel:
      +
    • Valentín Vinagre
    • +
    • Roger Sans
    • +
    +
  • +
+
+
+

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_force_whole_invoiceability/tests/__init__.py b/sale_force_whole_invoiceability/tests/__init__.py new file mode 100644 index 00000000000..d1d4543784a --- /dev/null +++ b/sale_force_whole_invoiceability/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_force_whole diff --git a/sale_force_whole_invoiceability/tests/test_sale_force_whole.py b/sale_force_whole_invoiceability/tests/test_sale_force_whole.py new file mode 100644 index 00000000000..2a7c6c64850 --- /dev/null +++ b/sale_force_whole_invoiceability/tests/test_sale_force_whole.py @@ -0,0 +1,93 @@ +# Copyright 2021 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.exceptions import UserError +from odoo.tests import Form, common, new_test_user, users + + +class SaleOrderForceInvoiceability(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.products = cls.env["product.product"].create( + {"name": "test product 1", "invoice_policy": "order"} + ) + cls.products |= cls.env["product.product"].create( + {"name": "test product 2", "invoice_policy": "delivery"} + ) + new_test_user( + cls.env, + login="test-sale-user", + groups="sales_team.group_sale_salesman_all_leads", + ) + new_test_user( + cls.env, + login="test-sale-manager", + groups="sales_team.group_sale_manager", + ) + sale = Form(cls.env["sale.order"]) + sale.partner_id = cls.env["res.partner"].create({"name": "Mr. Odoo"}) + for product in cls.products: + with sale.order_line.new() as order_line: + order_line.product_id = product + order_line.product_uom_qty = 5 + cls.sale_order = sale.save() + + @users("test-sale-manager") + def test_01_force_invoiceability_draft(self): + """Try to force invoiceability""" + # The order is still not in `sale` mode so we can't force it + self.sale_order = self.env["sale.order"].browse(self.sale_order.id) + with self.assertRaises(UserError) as cm: + self.sale_order.force_lines_to_invoice_policy_order() + self.assertEqual( + "You can't perform this action over a sale order in this state", + cm.exception.args[0], + ) + + @users("test-sale-user") + def test_02_force_invoiceability_no_permissions(self): + # Only users with sales manager permission can force the lines + self.sale_order = self.env["sale.order"].browse(self.sale_order.id) + self.sale_order.action_confirm() + with self.assertRaises(UserError) as cm: + self.sale_order.force_lines_to_invoice_policy_order() + self.assertEqual( + "Only Sales Managers are allowed to force the lines to invoice", + cm.exception.args[0], + ) + + def test_03_force_invoiceable_lines(self): + self.sale_order = self.env["sale.order"].browse(self.sale_order.id) + self.sale_order.action_confirm() + # Only the product with *Ordered quantities* policy has its line + # quantities `to invoice` + self.assertAlmostEqual( + 5, sum(self.sale_order.mapped("order_line.qty_to_invoice")) + ) + self.sale_order.force_lines_to_invoice_policy_order() + # Now the whole order qty is `to invoice` + self.assertAlmostEqual( + 10, sum(self.sale_order.mapped("order_line.qty_to_invoice")) + ) + # Although no quantities are delivered yet + self.assertTrue(not any(self.sale_order.mapped("order_line.qty_delivered"))) + # Let's make the invoice + adv_wiz = ( + self.env["sale.advance.payment.inv"] + .with_context(active_ids=[self.sale_order.id]) + .create({"advance_payment_method": "delivered"}) + ) + adv_wiz.with_context(open_invoices=True).create_invoices() + self.assertEqual(10, sum(self.sale_order.mapped("order_line.qty_invoiced"))) + # We can't use the force action anymore once there's an invoice linked + with self.assertRaises(UserError) as cm: + self.sale_order.force_lines_to_invoice_policy_order() + self.assertEqual( + "You can't perform this action once the order has been invoiced " + "once already", + cm.exception.args[0], + ) + + @users("test-sale-manager") + def test_03_force_invoiceable_lines_extra(self): + self.test_03_force_invoiceable_lines() diff --git a/sale_force_whole_invoiceability/views/sale_order_views.xml b/sale_force_whole_invoiceability/views/sale_order_views.xml new file mode 100644 index 00000000000..fa57132bad5 --- /dev/null +++ b/sale_force_whole_invoiceability/views/sale_order_views.xml @@ -0,0 +1,20 @@ + + + + + sale.order + + + + + +