diff --git a/account_invoice_warn_message/README.rst b/account_invoice_warn_message/README.rst new file mode 100644 index 00000000000..9b2e5e5f997 --- /dev/null +++ b/account_invoice_warn_message/README.rst @@ -0,0 +1,79 @@ +============================ +Account Invoice Warn Message +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:eca5433430d160325f358354f076943cfe552784afde295c9959682e98ddee0b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/18.0/account_invoice_warn_message + :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-18-0/account-invoicing-18-0-account_invoice_warn_message + :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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module add a warning popup on invoice to ensure warning is +populated no only when partner is changed. + +**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 +------- + +* ForgeFlow + +Contributors +------------ + +- Héctor Villarreal +- Manuel Regidor +- ``Heliconia Solutions Pvt. Ltd. ``\ \_ + +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/account_invoice_warn_message/__init__.py b/account_invoice_warn_message/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/account_invoice_warn_message/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_invoice_warn_message/__manifest__.py b/account_invoice_warn_message/__manifest__.py new file mode 100644 index 00000000000..dddbeda7718 --- /dev/null +++ b/account_invoice_warn_message/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Account Invoice Warn Message", + "summary": """ + Add a popup warning on invoice to ensure warning is populated""", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-invoicing", + "depends": ["account"], + "data": ["views/account_move_views.xml"], +} diff --git a/account_invoice_warn_message/i18n/account_invoice_warn_message.pot b/account_invoice_warn_message/i18n/account_invoice_warn_message.pot new file mode 100644 index 00000000000..111f144a619 --- /dev/null +++ b/account_invoice_warn_message/i18n/account_invoice_warn_message.pot @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_warn_message +# +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: account_invoice_warn_message +#: model_terms:ir.ui.view,arch_db:account_invoice_warn_message.view_move_form +msgid "" +"\n" +" &nbsp;" +msgstr "" + +#. module: account_invoice_warn_message +#: model:ir.model.fields,field_description:account_invoice_warn_message.field_account_bank_statement_line__invoice_warn_msg +#: model:ir.model.fields,field_description:account_invoice_warn_message.field_account_move__invoice_warn_msg +#: model:ir.model.fields,field_description:account_invoice_warn_message.field_account_payment__invoice_warn_msg +msgid "Invoice Warn Msg" +msgstr "" + +#. module: account_invoice_warn_message +#: model:ir.model,name:account_invoice_warn_message.model_account_move +msgid "Journal Entry" +msgstr "" diff --git a/account_invoice_warn_message/i18n/es.po b/account_invoice_warn_message/i18n/es.po new file mode 100644 index 00000000000..07f2803c342 --- /dev/null +++ b/account_invoice_warn_message/i18n/es.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_warn_message +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-01 21: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: account_invoice_warn_message +#: model_terms:ir.ui.view,arch_db:account_invoice_warn_message.view_move_form +msgid "" +"\n" +" &nbsp;" +msgstr "" +"\n" +" &nbsp;" + +#. module: account_invoice_warn_message +#: model:ir.model.fields,field_description:account_invoice_warn_message.field_account_bank_statement_line__invoice_warn_msg +#: model:ir.model.fields,field_description:account_invoice_warn_message.field_account_move__invoice_warn_msg +#: model:ir.model.fields,field_description:account_invoice_warn_message.field_account_payment__invoice_warn_msg +msgid "Invoice Warn Msg" +msgstr "Mensaje Aviso Factura" + +#. module: account_invoice_warn_message +#: model:ir.model,name:account_invoice_warn_message.model_account_move +msgid "Journal Entry" +msgstr "Entrada Diaria" + +#~ msgid "Journal Entries" +#~ msgstr "Asientos contables" diff --git a/account_invoice_warn_message/i18n/it.po b/account_invoice_warn_message/i18n/it.po new file mode 100644 index 00000000000..7e5d8bd67ac --- /dev/null +++ b/account_invoice_warn_message/i18n/it.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_warn_message +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-05-03 09:36+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: account_invoice_warn_message +#: model_terms:ir.ui.view,arch_db:account_invoice_warn_message.view_move_form +msgid "" +"\n" +" &nbsp;" +msgstr "" +"\n" +" &nbsp;" + +#. module: account_invoice_warn_message +#: model:ir.model.fields,field_description:account_invoice_warn_message.field_account_bank_statement_line__invoice_warn_msg +#: model:ir.model.fields,field_description:account_invoice_warn_message.field_account_move__invoice_warn_msg +#: model:ir.model.fields,field_description:account_invoice_warn_message.field_account_payment__invoice_warn_msg +msgid "Invoice Warn Msg" +msgstr "Messaggio avviso fattura" + +#. module: account_invoice_warn_message +#: model:ir.model,name:account_invoice_warn_message.model_account_move +msgid "Journal Entry" +msgstr "Registrazione contabile" diff --git a/account_invoice_warn_message/models/__init__.py b/account_invoice_warn_message/models/__init__.py new file mode 100644 index 00000000000..9c0a4213854 --- /dev/null +++ b/account_invoice_warn_message/models/__init__.py @@ -0,0 +1 @@ +from . import account_move diff --git a/account_invoice_warn_message/models/account_move.py b/account_invoice_warn_message/models/account_move.py new file mode 100644 index 00000000000..dd39f926d9e --- /dev/null +++ b/account_invoice_warn_message/models/account_move.py @@ -0,0 +1,36 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + invoice_warn_msg = fields.Text(compute="_compute_invoice_warn_msg") + + @api.depends( + "move_type", + "state", + "partner_id.invoice_warn", + "partner_id.parent_id.invoice_warn", + ) + def _compute_invoice_warn_msg(self): + for rec in self: + if ( + rec.partner_id + and rec.move_type in ("out_invoice", "out_refund") + and rec.state == "draft" + ): + if ( + rec.partner_id.parent_id + and rec.partner_id.parent_id.invoice_warn == "warning" + ): + rec.invoice_warn_msg = rec.partner_id.parent_id.invoice_warn_msg + if rec.partner_id.invoice_warn == "warning": + rec.invoice_warn_msg += f"\n{rec.partner_id.invoice_warn_msg}" + continue + elif rec.partner_id.invoice_warn == "warning": + rec.invoice_warn_msg = rec.partner_id.invoice_warn_msg + continue + rec.invoice_warn_msg = False diff --git a/account_invoice_warn_message/pyproject.toml b/account_invoice_warn_message/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/account_invoice_warn_message/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_invoice_warn_message/readme/CONTRIBUTORS.md b/account_invoice_warn_message/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..7098d2c610d --- /dev/null +++ b/account_invoice_warn_message/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Héctor Villarreal \<\> +- Manuel Regidor \<\> +- `Heliconia Solutions Pvt. Ltd. `_ diff --git a/account_invoice_warn_message/readme/DESCRIPTION.md b/account_invoice_warn_message/readme/DESCRIPTION.md new file mode 100644 index 00000000000..d59e662c4d5 --- /dev/null +++ b/account_invoice_warn_message/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module add a warning popup on invoice to ensure warning is +populated no only when partner is changed. diff --git a/account_invoice_warn_message/static/description/icon.png b/account_invoice_warn_message/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/account_invoice_warn_message/static/description/icon.png differ diff --git a/account_invoice_warn_message/static/description/index.html b/account_invoice_warn_message/static/description/index.html new file mode 100644 index 00000000000..81f3b14e0df --- /dev/null +++ b/account_invoice_warn_message/static/description/index.html @@ -0,0 +1,426 @@ + + + + + +Account Invoice Warn Message + + + +
+

Account Invoice Warn Message

+ + +

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

+

This module add a warning popup on invoice to ensure warning is +populated no only when partner is changed.

+

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

+
    +
  • ForgeFlow
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/account_invoice_warn_message/tests/__init__.py b/account_invoice_warn_message/tests/__init__.py new file mode 100644 index 00000000000..a468325792e --- /dev/null +++ b/account_invoice_warn_message/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_invoice_warn_message diff --git a/account_invoice_warn_message/tests/test_account_invoice_warn_message.py b/account_invoice_warn_message/tests/test_account_invoice_warn_message.py new file mode 100644 index 00000000000..9b694f62b9d --- /dev/null +++ b/account_invoice_warn_message/tests/test_account_invoice_warn_message.py @@ -0,0 +1,187 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestAccountInvoiceWarnMessage(TransactionCase): + def setUp(self): + super().setUp() + self.warn_msg_parent = "This customer has a warn from parent" + self.parent = self.env["res.partner"].create( + { + "name": "Customer with a warn", + "email": "customer@warn.com", + "invoice_warn": "warning", + "invoice_warn_msg": self.warn_msg_parent, + } + ) + self.warn_msg = "This customer has a warn" + self.partner = self.env["res.partner"].create( + { + "name": "Customer with a warn", + "email": "customer@warn.com", + "invoice_warn": "warning", + "invoice_warn_msg": self.warn_msg, + } + ) + + def test_compute_invoice_warn_msg(self): + invoice = self.env["account.move"].create( + { + "move_type": "out_invoice", + "partner_id": self.partner.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": self.env.ref("product.product_product_4").id, + "quantity": 1, + "price_unit": 42, + }, + ), + ], + } + ) + self.assertEqual(invoice.invoice_warn_msg, self.warn_msg) + + def test_compute_invoice_warn_msg_parent(self): + self.partner.update({"parent_id": self.parent.id}) + invoice = self.env["account.move"].create( + { + "move_type": "out_invoice", + "partner_id": self.partner.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": self.env.ref("product.product_product_4").id, + "quantity": 1, + "price_unit": 42, + }, + ), + ], + } + ) + self.assertEqual( + invoice.invoice_warn_msg, self.warn_msg_parent + "\n" + self.warn_msg + ) + + def test_compute_invoice_warn_msg_parent_but_not_partner(self): + self.partner.update({"invoice_warn": "no-message", "parent_id": self.parent.id}) + invoice = self.env["account.move"].create( + { + "move_type": "out_invoice", + "partner_id": self.partner.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": self.env.ref("product.product_product_4").id, + "quantity": 1, + "price_unit": 42, + }, + ), + ], + } + ) + self.assertEqual(invoice.invoice_warn_msg, self.warn_msg_parent) + + def test_compute_invoice_warn_msg_in_invoice(self): + invoice = self.env["account.move"].create( + { + "move_type": "in_invoice", + "partner_id": self.partner.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": self.env.ref("product.product_product_4").id, + "quantity": 1, + "price_unit": 42, + }, + ), + ], + } + ) + self.assertFalse(invoice.invoice_warn_msg) + + def test_compute_invoice_warn_msg_posted_state(self): + invoice = self.env["account.move"].create( + { + "move_type": "out_invoice", + "partner_id": self.partner.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": self.env.ref("product.product_product_4").id, + "quantity": 1, + "price_unit": 42, + }, + ), + ], + } + ) + invoice.action_post() + self.assertFalse(invoice.invoice_warn_msg) + + def test_compute_invoice_warn_msg_no_partner(self): + invoice = self.env["account.move"].create( + { + "move_type": "out_invoice", + "invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": self.env.ref("product.product_product_4").id, + "quantity": 1, + "price_unit": 42, + }, + ), + ], + } + ) + self.assertFalse(invoice.invoice_warn_msg) + + def test_compute_invoice_warn_msg_no_warnings(self): + partner_no_warn = self.env["res.partner"].create( + { + "name": "Customer without warning", + "email": "customer@nowarn.com", + "invoice_warn": "no-message", + } + ) + parent_no_warn = self.env["res.partner"].create( + { + "name": "Parent without warning", + "email": "parent@nowarn.com", + "invoice_warn": "no-message", + } + ) + partner_no_warn.parent_id = parent_no_warn.id + + invoice = self.env["account.move"].create( + { + "move_type": "out_invoice", + "partner_id": partner_no_warn.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": self.env.ref("product.product_product_4").id, + "quantity": 1, + "price_unit": 42, + }, + ), + ], + } + ) + self.assertFalse(invoice.invoice_warn_msg) diff --git a/account_invoice_warn_message/views/account_move_views.xml b/account_invoice_warn_message/views/account_move_views.xml new file mode 100644 index 00000000000..2e1dcfb2d35 --- /dev/null +++ b/account_invoice_warn_message/views/account_move_views.xml @@ -0,0 +1,26 @@ + + + + + account.move.form (in account_invoice_warn_message) + account.move + + +
+ +
+
+
+