diff --git a/purchase_warn_option/README.rst b/purchase_warn_option/README.rst new file mode 100644 index 00000000000..05c04d561b6 --- /dev/null +++ b/purchase_warn_option/README.rst @@ -0,0 +1,119 @@ +==================== +Purchase Warn Option +==================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:37fde3f6af32026973ea02a550fad260f0738a51d8ffab62d63ff1fe08b38b3c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_warn_option + :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-18-0/purchase-workflow-18-0-purchase_warn_option + :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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of Supplier and Product blocking +messages to support more consistency between messages and to allow you +to set a blocking message quickly. + +.. 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: + +Use Cases / Context +=================== + +This module has been developed to maintain consistency in the messages +used when blocking suppliers or products in purchase models. + +If you need this module for those reasons, these might interest you too: + +- sale_warn_option +- account_warn_option +- stock_warn_option + +Usage +===== + +To use this module, you need to: + +- Go to Purchase App > Configuration Menu > Settings +- Under *Orders* check **Warnings** checkbox +- Go to Orders > Vendors > Internal Notes Tab +- Select Warn Options under *Warning on the Purchase Order* +- Go to a Product > Purchase Tab +- Select Warn Options under *Warning when Purchasing this 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 +------- + +* Moduon + +Contributors +------------ + +- Eduardo de Miguel (`Moduon `__) +- Sabrina Rodriguez (`Moduon `__) + +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. + +.. |maintainer-Shide| image:: https://github.com/Shide.png?size=40px + :target: https://github.com/Shide + :alt: Shide +.. |maintainer-rafaelbn| image:: https://github.com/rafaelbn.png?size=40px + :target: https://github.com/rafaelbn + :alt: rafaelbn + +Current `maintainers `__: + +|maintainer-Shide| |maintainer-rafaelbn| + +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_warn_option/__init__.py b/purchase_warn_option/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/purchase_warn_option/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_warn_option/__manifest__.py b/purchase_warn_option/__manifest__.py new file mode 100644 index 00000000000..534ea7c89a6 --- /dev/null +++ b/purchase_warn_option/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2024 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +{ + "name": "Purchase Warn Option", + "summary": "Add Options to Purchase Warn Messages", + "version": "18.0.1.0.0", + "development_status": "Alpha", + "category": "Inventory/Purchase", + "website": "https://github.com/OCA/purchase-workflow", + "author": "Moduon, Odoo Community Association (OCA)", + "maintainers": ["Shide", "rafaelbn"], + "license": "LGPL-3", + "application": False, + "installable": True, + "auto_install": True, + "depends": ["purchase", "base_warn_option"], + "data": [ + "views/res_partner_views.xml", + "views/product_template_views.xml", + ], +} diff --git a/purchase_warn_option/i18n/es.po b/purchase_warn_option/i18n/es.po new file mode 100644 index 00000000000..e479caa5446 --- /dev/null +++ b/purchase_warn_option/i18n/es.po @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_warn_option +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-04-11 09:09+0000\n" +"PO-Revision-Date: 2024-04-11 11:11+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.4.2\n" + +#. module: purchase_warn_option +#: model:ir.model.fields.selection,name:purchase_warn_option.selection__warn_option__allowed_warning_usage__partner_purchase_warn +msgid "(Partner) Warning on the Purchase Order" +msgstr "(Contacto) Aviso en el pedido de compra" + +#. module: purchase_warn_option +#: model:ir.model.fields.selection,name:purchase_warn_option.selection__warn_option__allowed_warning_usage__product_purchase_warn +msgid "(Product) Warning when Purchasing this Product" +msgstr "(Producto) Aviso cuando compra este producto" + +#. module: purchase_warn_option +#: model:ir.model.fields,field_description:purchase_warn_option.field_warn_option__allowed_warning_usage +msgid "Allowed Warning Usage" +msgstr "Uso de la alerta permitida" + +#. module: purchase_warn_option +#: model:ir.model.fields,help:purchase_warn_option.field_warn_option__allowed_warning_usage +msgid "Allows to choose where the message can be selected" +msgstr "Permite elegir dónde puede ser seleccionado el mensaje" + +#. module: purchase_warn_option +#: model:ir.model,name:purchase_warn_option.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: purchase_warn_option +#: model:ir.model,name:purchase_warn_option.model_product_template +msgid "Product Template" +msgstr "Plantilla de producto" + +#. module: purchase_warn_option +#: model:ir.model.fields,field_description:purchase_warn_option.field_product_product__purchase_line_warn_option +#: model:ir.model.fields,field_description:purchase_warn_option.field_product_template__purchase_line_warn_option +msgid "Purchase Line Warn Option" +msgstr "Opción de alerta en líneas de compras" + +#. module: purchase_warn_option +#: model:ir.model.fields,field_description:purchase_warn_option.field_res_partner__purchase_warn_option +#: model:ir.model.fields,field_description:purchase_warn_option.field_res_users__purchase_warn_option +msgid "Purchase Warn Option" +msgstr "Opción de alerta en compras" + +#. module: purchase_warn_option +#: model_terms:ir.ui.view,arch_db:purchase_warn_option.purchase_warn_option_partner_form +#: model_terms:ir.ui.view,arch_db:purchase_warn_option.purchase_warn_option_product_form +msgid "Select a warning option" +msgstr "Selecciona una opción de alerta" + +#. module: purchase_warn_option +#: model:ir.model,name:purchase_warn_option.model_warn_option +msgid "Warn Option" +msgstr "Opción de alerta" diff --git a/purchase_warn_option/i18n/purchase_warn_option.pot b/purchase_warn_option/i18n/purchase_warn_option.pot new file mode 100644 index 00000000000..c5b0e2b1fbb --- /dev/null +++ b/purchase_warn_option/i18n/purchase_warn_option.pot @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_warn_option +# +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: purchase_warn_option +#: model:ir.model.fields.selection,name:purchase_warn_option.selection__warn_option__allowed_warning_usage__partner_purchase_warn +msgid "(Partner) Warning on the Purchase Order" +msgstr "" + +#. module: purchase_warn_option +#: model:ir.model.fields.selection,name:purchase_warn_option.selection__warn_option__allowed_warning_usage__product_purchase_warn +msgid "(Product) Warning when Purchasing this Product" +msgstr "" + +#. module: purchase_warn_option +#: model:ir.model.fields,field_description:purchase_warn_option.field_warn_option__allowed_warning_usage +msgid "Allowed Warning Usage" +msgstr "" + +#. module: purchase_warn_option +#: model:ir.model.fields,help:purchase_warn_option.field_warn_option__allowed_warning_usage +msgid "Allows to choose where the message can be selected" +msgstr "" + +#. module: purchase_warn_option +#: model:ir.model,name:purchase_warn_option.model_res_partner +msgid "Contact" +msgstr "" + +#. module: purchase_warn_option +#: model:ir.model,name:purchase_warn_option.model_product_template +msgid "Product Template" +msgstr "" + +#. module: purchase_warn_option +#: model:ir.model.fields,field_description:purchase_warn_option.field_product_product__purchase_line_warn_option +#: model:ir.model.fields,field_description:purchase_warn_option.field_product_template__purchase_line_warn_option +msgid "Purchase Line Warn Option" +msgstr "" + +#. module: purchase_warn_option +#: model:ir.model.fields,field_description:purchase_warn_option.field_res_partner__purchase_warn_option +#: model:ir.model.fields,field_description:purchase_warn_option.field_res_users__purchase_warn_option +msgid "Purchase Warn Option" +msgstr "" + +#. module: purchase_warn_option +#: model_terms:ir.ui.view,arch_db:purchase_warn_option.purchase_warn_option_partner_form +#: model_terms:ir.ui.view,arch_db:purchase_warn_option.purchase_warn_option_product_form +msgid "Select a warning option" +msgstr "" + +#. module: purchase_warn_option +#: model:ir.model,name:purchase_warn_option.model_warn_option +msgid "Warn Option" +msgstr "" diff --git a/purchase_warn_option/models/__init__.py b/purchase_warn_option/models/__init__.py new file mode 100644 index 00000000000..83dc48bdcf6 --- /dev/null +++ b/purchase_warn_option/models/__init__.py @@ -0,0 +1,3 @@ +from . import warn_option +from . import res_partner +from . import product_template diff --git a/purchase_warn_option/models/product_template.py b/purchase_warn_option/models/product_template.py new file mode 100644 index 00000000000..578898d6bf6 --- /dev/null +++ b/purchase_warn_option/models/product_template.py @@ -0,0 +1,17 @@ +# Copyright 2024 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + purchase_line_warn_option = fields.Many2one( + comodel_name="warn.option", + ) + + @api.onchange("purchase_line_warn_option") + def _onchange_purchase_line_warn_option(self): + if self.purchase_line_warn != "no-message" and self.purchase_line_warn_option: + self.purchase_line_warn_msg = self.purchase_line_warn_option.name diff --git a/purchase_warn_option/models/res_partner.py b/purchase_warn_option/models/res_partner.py new file mode 100644 index 00000000000..6cc42200bcc --- /dev/null +++ b/purchase_warn_option/models/res_partner.py @@ -0,0 +1,17 @@ +# Copyright 2024 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from odoo import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + purchase_warn_option = fields.Many2one( + comodel_name="warn.option", + ) + + @api.onchange("purchase_warn_option") + def _onchange_purchase_warn_option(self): + if self.purchase_warn != "no-message" and self.purchase_warn_option: + self.purchase_warn_msg = self.purchase_warn_option.name diff --git a/purchase_warn_option/models/warn_option.py b/purchase_warn_option/models/warn_option.py new file mode 100644 index 00000000000..626f0b85907 --- /dev/null +++ b/purchase_warn_option/models/warn_option.py @@ -0,0 +1,19 @@ +# Copyright 2024 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from odoo import fields, models + + +class WarnOption(models.Model): + _inherit = "warn.option" + + allowed_warning_usage = fields.Selection( + selection_add=[ + ("partner_purchase_warn", "(Partner) Warning on the Purchase Order"), + ("product_purchase_warn", "(Product) Warning when Purchasing this Product"), + ], + ondelete={ + "partner_purchase_warn": "set default", + "product_purchase_warn": "set default", + }, + ) diff --git a/purchase_warn_option/pyproject.toml b/purchase_warn_option/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/purchase_warn_option/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_warn_option/readme/CONTEXT.md b/purchase_warn_option/readme/CONTEXT.md new file mode 100644 index 00000000000..2840df674b5 --- /dev/null +++ b/purchase_warn_option/readme/CONTEXT.md @@ -0,0 +1,8 @@ +This module has been developed to maintain consistency in the messages used when +blocking suppliers or products in purchase models. + +If you need this module for those reasons, these might interest you too: + +- sale_warn_option +- account_warn_option +- stock_warn_option diff --git a/purchase_warn_option/readme/CONTRIBUTORS.md b/purchase_warn_option/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..ae0aefa7d08 --- /dev/null +++ b/purchase_warn_option/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Eduardo de Miguel ([Moduon](https://www.moduon.team/)) +- Sabrina Rodriguez ([Moduon](https://www.moduon.team/)) diff --git a/purchase_warn_option/readme/DESCRIPTION.md b/purchase_warn_option/readme/DESCRIPTION.md new file mode 100644 index 00000000000..4ccb363f10c --- /dev/null +++ b/purchase_warn_option/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module extends the functionality of Supplier and Product blocking messages to +support more consistency between messages and to allow you to set a blocking message +quickly. diff --git a/purchase_warn_option/readme/USAGE.md b/purchase_warn_option/readme/USAGE.md new file mode 100644 index 00000000000..a5b64b0e740 --- /dev/null +++ b/purchase_warn_option/readme/USAGE.md @@ -0,0 +1,8 @@ +To use this module, you need to: + +- Go to Purchase App > Configuration Menu > Settings +- Under _Orders_ check **Warnings** checkbox +- Go to Orders > Vendors > Internal Notes Tab +- Select Warn Options under _Warning on the Purchase Order_ +- Go to a Product > Purchase Tab +- Select Warn Options under _Warning when Purchasing this Product_ diff --git a/purchase_warn_option/static/description/icon.png b/purchase_warn_option/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_warn_option/static/description/icon.png differ diff --git a/purchase_warn_option/static/description/index.html b/purchase_warn_option/static/description/index.html new file mode 100644 index 00000000000..f1e2ec1047e --- /dev/null +++ b/purchase_warn_option/static/description/index.html @@ -0,0 +1,459 @@ + + + + + +Purchase Warn Option + + + +
+

Purchase Warn Option

+ + +

Alpha License: LGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

+

This module extends the functionality of Supplier and Product blocking +messages to support more consistency between messages and to allow you +to set a blocking message quickly.

+
+

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

+ +
+

Use Cases / Context

+

This module has been developed to maintain consistency in the messages +used when blocking suppliers or products in purchase models.

+

If you need this module for those reasons, these might interest you too:

+
    +
  • sale_warn_option
  • +
  • account_warn_option
  • +
  • stock_warn_option
  • +
+
+
+

Usage

+

To use this module, you need to:

+
    +
  • Go to Purchase App > Configuration Menu > Settings
  • +
  • Under Orders check Warnings checkbox
  • +
  • Go to Orders > Vendors > Internal Notes Tab
  • +
  • Select Warn Options under Warning on the Purchase Order
  • +
  • Go to a Product > Purchase Tab
  • +
  • Select Warn Options under Warning when Purchasing this 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

+
    +
  • Moduon
  • +
+
+
+

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.

+

Current maintainers:

+

Shide rafaelbn

+

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_warn_option/tests/__init__.py b/purchase_warn_option/tests/__init__.py new file mode 100644 index 00000000000..77e8919bd14 --- /dev/null +++ b/purchase_warn_option/tests/__init__.py @@ -0,0 +1 @@ +from . import test_warn_options diff --git a/purchase_warn_option/tests/test_warn_options.py b/purchase_warn_option/tests/test_warn_options.py new file mode 100644 index 00000000000..ab6efeedb23 --- /dev/null +++ b/purchase_warn_option/tests/test_warn_options.py @@ -0,0 +1,78 @@ +# Copyright 2024 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from odoo.tests.common import TransactionCase + + +class TestWarnOptions(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner = cls.env["res.partner"].create( + { + "name": "Test Partner", + } + ) + cls.partner_purchase_warn_warning = cls.env["warn.option"].create( + { + "name": "warning", + "allowed_warning_usage": "partner_purchase_warn", + "allowed_warning_type": "warning", + } + ) + cls.partner_purchase_warn_blocking = cls.env["warn.option"].create( + { + "name": "block", + "allowed_warning_usage": "partner_purchase_warn", + "allowed_warning_type": "block", + } + ) + cls.product = cls.env["product.template"].create( + { + "name": "Test Product", + } + ) + cls.product_purchase_warn_warning = cls.env["warn.option"].create( + { + "name": "warning", + "allowed_warning_usage": "product_purchase_warn", + "allowed_warning_type": "warning", + } + ) + cls.product_purchase_warn_blocking = cls.env["warn.option"].create( + { + "name": "block", + "allowed_warning_usage": "product_purchase_warn", + "allowed_warning_type": "block", + } + ) + + def test_partner_warn_options(self): + """Test Warn Options on Partner Form""" + partner_f = self.env["res.partner"].new( + { + "purchase_warn": "warning", + "purchase_warn_option": self.partner_purchase_warn_warning.id, + } + ) + partner_f._onchange_purchase_warn_option() + self.assertEqual(partner_f.purchase_warn_msg, "warning") + partner_f.purchase_warn = "block" + partner_f.purchase_warn_option = self.partner_purchase_warn_blocking.id + partner_f._onchange_purchase_warn_option() + self.assertEqual(partner_f.purchase_warn_msg, "block") + + def test_product_warn_options(self): + """Test Warn Options on Product Form""" + product_f = self.env["product.template"].new( + { + "purchase_line_warn": "warning", + "purchase_line_warn_option": self.product_purchase_warn_warning.id, + } + ) + product_f._onchange_purchase_line_warn_option() + self.assertEqual(product_f.purchase_line_warn_msg, "warning") + product_f.purchase_line_warn = "block" + product_f.purchase_line_warn_option = self.product_purchase_warn_blocking.id + product_f._onchange_purchase_line_warn_option() + self.assertEqual(product_f.purchase_line_warn_msg, "block") diff --git a/purchase_warn_option/views/product_template_views.xml b/purchase_warn_option/views/product_template_views.xml new file mode 100644 index 00000000000..7d3938d740b --- /dev/null +++ b/purchase_warn_option/views/product_template_views.xml @@ -0,0 +1,24 @@ + + + + + purchase.warn.option.product.form + product.template + + + + + + + + diff --git a/purchase_warn_option/views/res_partner_views.xml b/purchase_warn_option/views/res_partner_views.xml new file mode 100644 index 00000000000..303f8094e2f --- /dev/null +++ b/purchase_warn_option/views/res_partner_views.xml @@ -0,0 +1,24 @@ + + + + + purchase.warn.option.partner.form + res.partner + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt index 66bc2cbae3f..2beb7e8f84d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1,2 @@ odoo_test_helper +odoo-addon-base_warn_option @ git+https://github.com/OCA/server-ux.git@refs/pull/1204/head#subdirectory=base_warn_option