diff --git a/purchase_invoice_method/README.rst b/purchase_invoice_method/README.rst new file mode 100644 index 00000000000..c35619cbf50 --- /dev/null +++ b/purchase_invoice_method/README.rst @@ -0,0 +1,106 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +======================= +Purchase Invoice Method +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:871c0424c65bae40d58b8151b86776a7cd7b8eb4f7d537160b5691801702383f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/19.0/purchase_invoice_method + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-19-0/purchase-workflow-19-0-purchase_invoice_method + :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/purchase-workflow&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the possibility for users to force the invoice status +of the purchase orders to 'Waiting Bills' so they can create a bill. +Also, you can force an "On ordered quantites" invoice method to "On +received quantites". + +Example: you can bill a purchase even when you haven't received the +product/service. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +1. Create a purchase order and confirm it. +2. Go to page "Other information" and select an option of the "Invoice + Method" field. +3. + + 1. If "On ordered quantited" is selected you can bill a purchase even + you haven't received the product. + +4. + + 1. If "On received quantited" is selected you cannot bill a purchase + if you haven't received the product. + +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 +------- + +* CreuBlanca + +Contributors +------------ + +- Enric Tobella +- Kevin Luna +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia + +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/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_invoice_method/__init__.py b/purchase_invoice_method/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/purchase_invoice_method/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_invoice_method/__manifest__.py b/purchase_invoice_method/__manifest__.py new file mode 100644 index 00000000000..960f63972da --- /dev/null +++ b/purchase_invoice_method/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2023 CreuBlanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Purchase Invoice Method", + "summary": """ + Allow to force the invoice method of a purchase""", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "author": "CreuBlanca, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/purchase-workflow", + "depends": ["purchase"], + "data": [ + "views/purchase_order.xml", + ], + "demo": [], +} diff --git a/purchase_invoice_method/i18n/es.po b/purchase_invoice_method/i18n/es.po new file mode 100644 index 00000000000..b167943ce9e --- /dev/null +++ b/purchase_invoice_method/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_invoice_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-04-18 08:37+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: purchase_invoice_method +#: model:ir.model.fields,field_description:purchase_invoice_method.field_purchase_order__invoice_method +msgid "Invoice Method" +msgstr "Método de Facturación" + +#. module: purchase_invoice_method +#: model:ir.model,name:purchase_invoice_method.model_purchase_order +msgid "Purchase Order" +msgstr "Orden de Compra" + +#. module: purchase_invoice_method +#: model:ir.model,name:purchase_invoice_method.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Línea Orden de Compra" diff --git a/purchase_invoice_method/i18n/es_MX.po b/purchase_invoice_method/i18n/es_MX.po new file mode 100644 index 00000000000..9dfda5c01c8 --- /dev/null +++ b/purchase_invoice_method/i18n/es_MX.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_invoice_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-07-17 21:00+0000\n" +"Last-Translator: Jesús Alan Ramos Rodríguez \n" +"Language-Team: none\n" +"Language: es_MX\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: purchase_invoice_method +#: model:ir.model.fields,field_description:purchase_invoice_method.field_purchase_order__invoice_method +msgid "Invoice Method" +msgstr "Método de Factruación" + +#. module: purchase_invoice_method +#: model:ir.model,name:purchase_invoice_method.model_purchase_order +msgid "Purchase Order" +msgstr "Orden de Compra" + +#. module: purchase_invoice_method +#: model:ir.model,name:purchase_invoice_method.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Línea de Orden de Compra" diff --git a/purchase_invoice_method/i18n/it.po b/purchase_invoice_method/i18n/it.po new file mode 100644 index 00000000000..66fb39da024 --- /dev/null +++ b/purchase_invoice_method/i18n/it.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_invoice_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-24 15:34+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 4.17\n" + +#. module: purchase_invoice_method +#: model:ir.model.fields,field_description:purchase_invoice_method.field_purchase_order__invoice_method +msgid "Invoice Method" +msgstr "Metodo fatturazione" + +#. module: purchase_invoice_method +#: model:ir.model,name:purchase_invoice_method.model_purchase_order +msgid "Purchase Order" +msgstr "Ordine di acquisto" + +#. module: purchase_invoice_method +#: model:ir.model,name:purchase_invoice_method.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Riga ordine di acquisto" diff --git a/purchase_invoice_method/i18n/pt_BR.po b/purchase_invoice_method/i18n/pt_BR.po new file mode 100644 index 00000000000..ce4af3482e1 --- /dev/null +++ b/purchase_invoice_method/i18n/pt_BR.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_invoice_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: pt_BR\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" + +#. module: purchase_invoice_method +#: model:ir.model.fields,field_description:purchase_invoice_method.field_purchase_order__invoice_method +msgid "Invoice Method" +msgstr "" + +#. module: purchase_invoice_method +#: model:ir.model,name:purchase_invoice_method.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: purchase_invoice_method +#: model:ir.model,name:purchase_invoice_method.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "" diff --git a/purchase_invoice_method/i18n/purchase_invoice_method.pot b/purchase_invoice_method/i18n/purchase_invoice_method.pot new file mode 100644 index 00000000000..8f7f0d8f1d9 --- /dev/null +++ b/purchase_invoice_method/i18n/purchase_invoice_method.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_invoice_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: purchase_invoice_method +#: model:ir.model.fields,field_description:purchase_invoice_method.field_purchase_order__invoice_method +msgid "Invoice Method" +msgstr "" + +#. module: purchase_invoice_method +#: model:ir.model,name:purchase_invoice_method.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: purchase_invoice_method +#: model:ir.model,name:purchase_invoice_method.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "" diff --git a/purchase_invoice_method/models/__init__.py b/purchase_invoice_method/models/__init__.py new file mode 100644 index 00000000000..9f03530643d --- /dev/null +++ b/purchase_invoice_method/models/__init__.py @@ -0,0 +1 @@ +from . import purchase_order diff --git a/purchase_invoice_method/models/purchase_order.py b/purchase_invoice_method/models/purchase_order.py new file mode 100644 index 00000000000..fbda726b1fd --- /dev/null +++ b/purchase_invoice_method/models/purchase_order.py @@ -0,0 +1,36 @@ +# Copyright 2023 CreuBlanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + invoice_method = fields.Selection( + lambda r: r.env["product.template"]._fields["purchase_method"].selection + ) + + +class PurchaseOrderLine(models.Model): + _inherit = "purchase.order.line" + + @api.depends( + "invoice_lines.move_id.state", + "invoice_lines.quantity", + "qty_received", + "product_uom_qty", + "order_id.state", + "order_id.invoice_method", + ) + def _compute_qty_invoiced(self): + ret = super()._compute_qty_invoiced() + for line in self.filtered( + lambda r: r.order_id.invoice_method + and r.order_id.state in ["purchase", "done"] + ): + if line.order_id.invoice_method == "purchase": + line.qty_to_invoice = line.product_qty - line.qty_invoiced + elif line.order_id.invoice_method == "receive": + line.qty_to_invoice = line.qty_received - line.qty_invoiced + return ret diff --git a/purchase_invoice_method/pyproject.toml b/purchase_invoice_method/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/purchase_invoice_method/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_invoice_method/readme/CONTRIBUTORS.md b/purchase_invoice_method/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..a0a6dd6c92a --- /dev/null +++ b/purchase_invoice_method/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Enric Tobella \<\> +- Kevin Luna \<\> +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia diff --git a/purchase_invoice_method/readme/DESCRIPTION.md b/purchase_invoice_method/readme/DESCRIPTION.md new file mode 100644 index 00000000000..ac5c1cd869c --- /dev/null +++ b/purchase_invoice_method/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +This module adds the possibility for users to force the invoice status +of the purchase orders to 'Waiting Bills' so they can create a bill. +Also, you can force an "On ordered quantites" invoice method to "On +received quantites". + +Example: you can bill a purchase even when you haven't received the +product/service. diff --git a/purchase_invoice_method/readme/USAGE.md b/purchase_invoice_method/readme/USAGE.md new file mode 100644 index 00000000000..7594bf62762 --- /dev/null +++ b/purchase_invoice_method/readme/USAGE.md @@ -0,0 +1,7 @@ +1. Create a purchase order and confirm it. +2. Go to page "Other information" and select an option of the "Invoice + Method" field. +3. 1. If "On ordered quantited" is selected you can bill a purchase + even you haven't received the product. +4. 1. If "On received quantited" is selected you cannot bill a + purchase if you haven't received the product. diff --git a/purchase_invoice_method/static/description/icon.png b/purchase_invoice_method/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_invoice_method/static/description/icon.png differ diff --git a/purchase_invoice_method/static/description/index.html b/purchase_invoice_method/static/description/index.html new file mode 100644 index 00000000000..b2da3724569 --- /dev/null +++ b/purchase_invoice_method/static/description/index.html @@ -0,0 +1,458 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Purchase Invoice Method

+ +

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

+

This module adds the possibility for users to force the invoice status +of the purchase orders to ‘Waiting Bills’ so they can create a bill. +Also, you can force an “On ordered quantites” invoice method to “On +received quantites”.

+

Example: you can bill a purchase even when you haven’t received the +product/service.

+

Table of contents

+ +
+

Usage

+
    +
  1. Create a purchase order and confirm it.
  2. +
  3. Go to page “Other information” and select an option of the “Invoice +Method” field.
  4. +
    1. +
    2. If “On ordered quantited” is selected you can bill a purchase even +you haven’t received the product.
    3. +
    +
  5. +
    1. +
    2. If “On received quantited” is selected you cannot bill a purchase +if you haven’t received the product.
    3. +
    +
  6. +
+
+
+

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

+
    +
  • CreuBlanca
  • +
+
+
+

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

+

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

+
+
+
+
+ + diff --git a/purchase_invoice_method/tests/__init__.py b/purchase_invoice_method/tests/__init__.py new file mode 100644 index 00000000000..bdec84fdfda --- /dev/null +++ b/purchase_invoice_method/tests/__init__.py @@ -0,0 +1 @@ +from . import test_purchase_invoice_method diff --git a/purchase_invoice_method/tests/test_purchase_invoice_method.py b/purchase_invoice_method/tests/test_purchase_invoice_method.py new file mode 100644 index 00000000000..56a27dcf35b --- /dev/null +++ b/purchase_invoice_method/tests/test_purchase_invoice_method.py @@ -0,0 +1,80 @@ +# Copyright 2023 CreuBlanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests import Form + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + + +class TestPurchaseInvoiceMethod(AccountTestInvoicingCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.vendor = cls.partner_a + cls.product = cls.product_a + cls.product.write( + { + "type": "service", + "purchase_method": "receive", + } + ) + + def test_force_create_invoice_receive(self): + purchase_order_form = Form(self.env["purchase.order"]) + purchase_order_form.partner_id = self.vendor + + with purchase_order_form.order_line.new() as line: + line.name = self.product.name + line.product_id = self.product + line.product_qty = 4 + line.price_unit = 500 + + purchase_order = purchase_order_form.save() + purchase_order.button_confirm() + + self.assertEqual(purchase_order.invoice_status, "no") + purchase_order.invoice_method = "purchase" + self.assertEqual(purchase_order.invoice_status, "to invoice") + for line in purchase_order.order_line: + self.assertEqual(line.product_qty, 4) + self.assertEqual(line.qty_invoiced, 0.0) + + purchase_order.action_create_invoice() + self.assertEqual(purchase_order.invoice_status, "invoiced") + for line in purchase_order.order_line: + self.assertEqual(line.qty_to_invoice, 0.0) + self.assertEqual(line.qty_invoiced, 4) + + def test_force_create_invoice_purchase(self): + self.product.purchase_method = "purchase" + purchase_order_form = Form(self.env["purchase.order"]) + purchase_order_form.partner_id = self.vendor + + with purchase_order_form.order_line.new() as line: + line.name = self.product.name + line.product_id = self.product + line.product_qty = 4 + line.price_unit = 500 + + purchase_order = purchase_order_form.save() + purchase_order.button_confirm() + + self.assertEqual(purchase_order.invoice_status, "to invoice") + purchase_order.invoice_method = "receive" + self.assertEqual(purchase_order.invoice_status, "no") + + def test_force_create_invoice_draft(self): + purchase_order_form = Form(self.env["purchase.order"]) + purchase_order_form.partner_id = self.vendor + + with purchase_order_form.order_line.new() as line: + line.name = self.product.name + line.product_id = self.product + line.product_qty = 4 + line.price_unit = 500 + + purchase_order = purchase_order_form.save() + purchase_order.invoice_method = "purchase" + self.assertEqual(purchase_order.invoice_status, "no") + self.assertEqual(purchase_order.order_line.qty_to_invoice, 0) diff --git a/purchase_invoice_method/views/purchase_order.xml b/purchase_invoice_method/views/purchase_order.xml new file mode 100644 index 00000000000..b13328044a0 --- /dev/null +++ b/purchase_invoice_method/views/purchase_order.xml @@ -0,0 +1,15 @@ + + + + + purchase.order.form (in purchase_invoice_method) + purchase.order + + + + + + + +