diff --git a/purchase_request_cancel_confirm/README.rst b/purchase_request_cancel_confirm/README.rst new file mode 100644 index 00000000000..e13356e75ad --- /dev/null +++ b/purchase_request_cancel_confirm/README.rst @@ -0,0 +1,89 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=============================== +Purchase Request Cancel Confirm +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a677c02f1dfcffc396d39dbc28e3f7fbe72bff8d5c0394a169b6ad9b507dc5cb + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_request_cancel_confirm + :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_request_cancel_confirm + :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| + +When user click to cancel purchase request, a confirmation wizard will +be show, with reason as optional. + +**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 +------- + +* Ecosoft + +Contributors +------------ + +- Kitti U. + +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-kittiu| image:: https://github.com/kittiu.png?size=40px + :target: https://github.com/kittiu + :alt: kittiu + +Current `maintainer `__: + +|maintainer-kittiu| + +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_request_cancel_confirm/__init__.py b/purchase_request_cancel_confirm/__init__.py new file mode 100644 index 00000000000..c48585cc61f --- /dev/null +++ b/purchase_request_cancel_confirm/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import model diff --git a/purchase_request_cancel_confirm/__manifest__.py b/purchase_request_cancel_confirm/__manifest__.py new file mode 100644 index 00000000000..6df37c6ffba --- /dev/null +++ b/purchase_request_cancel_confirm/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2020 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Purchase Request Cancel Confirm", + "version": "19.0.1.0.0", + "author": "Ecosoft, Odoo Community Association (OCA)", + "category": "Usability", + "license": "AGPL-3", + "website": "https://github.com/OCA/purchase-workflow", + "depends": ["base_cancel_confirm", "purchase_request"], + "auto_install": False, + "installable": True, + "maintainers": ["kittiu"], +} diff --git a/purchase_request_cancel_confirm/i18n/es.po b/purchase_request_cancel_confirm/i18n/es.po new file mode 100644 index 00000000000..aed756b8347 --- /dev/null +++ b/purchase_request_cancel_confirm/i18n/es.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_request_cancel_confirm +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-11 13:36+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_request_cancel_confirm +#: model:ir.model.fields,help:purchase_request_cancel_confirm.field_purchase_request__cancel_confirm +msgid "A flag signify that this document is confirmed for cancellation" +msgstr "" +"Una bandera significa que este documento está confirmado para su anulación" + +#. module: purchase_request_cancel_confirm +#: model:ir.model.fields,help:purchase_request_cancel_confirm.field_purchase_request__cancel_reason +msgid "An optional cancel reason" +msgstr "Un motivo de cancelación opcional" + +#. module: purchase_request_cancel_confirm +#: model:ir.model.fields,field_description:purchase_request_cancel_confirm.field_purchase_request__cancel_confirm +msgid "Cancel Confirmed" +msgstr "Cancelar Confirmado" + +#. module: purchase_request_cancel_confirm +#: model:ir.model.fields,field_description:purchase_request_cancel_confirm.field_purchase_request__cancel_reason +msgid "Cancel Reason" +msgstr "Cancelar Razón" + +#. module: purchase_request_cancel_confirm +#: model:ir.model,name:purchase_request_cancel_confirm.model_purchase_request +msgid "Purchase Request" +msgstr "Solicitud de Compra" diff --git a/purchase_request_cancel_confirm/i18n/it.po b/purchase_request_cancel_confirm/i18n/it.po new file mode 100644 index 00000000000..a940322847a --- /dev/null +++ b/purchase_request_cancel_confirm/i18n/it.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_request_cancel_confirm +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-08-02 16:25+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.10.4\n" + +#. module: purchase_request_cancel_confirm +#: model:ir.model.fields,help:purchase_request_cancel_confirm.field_purchase_request__cancel_confirm +msgid "A flag signify that this document is confirmed for cancellation" +msgstr "Una spunta indica che questo documento è confermato per l'annullamento" + +#. module: purchase_request_cancel_confirm +#: model:ir.model.fields,help:purchase_request_cancel_confirm.field_purchase_request__cancel_reason +msgid "An optional cancel reason" +msgstr "Un motivo di annullamento opzionale" + +#. module: purchase_request_cancel_confirm +#: model:ir.model.fields,field_description:purchase_request_cancel_confirm.field_purchase_request__cancel_confirm +msgid "Cancel Confirmed" +msgstr "Annullamento confermato" + +#. module: purchase_request_cancel_confirm +#: model:ir.model.fields,field_description:purchase_request_cancel_confirm.field_purchase_request__cancel_reason +msgid "Cancel Reason" +msgstr "Causale annullamento" + +#. module: purchase_request_cancel_confirm +#: model:ir.model,name:purchase_request_cancel_confirm.model_purchase_request +msgid "Purchase Request" +msgstr "Richiesta di acquisto" diff --git a/purchase_request_cancel_confirm/i18n/purchase_request_cancel_confirm.pot b/purchase_request_cancel_confirm/i18n/purchase_request_cancel_confirm.pot new file mode 100644 index 00000000000..de20e56b1df --- /dev/null +++ b/purchase_request_cancel_confirm/i18n/purchase_request_cancel_confirm.pot @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_request_cancel_confirm +# +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_request_cancel_confirm +#: model:ir.model.fields,help:purchase_request_cancel_confirm.field_purchase_request__cancel_confirm +msgid "A flag signify that this document is confirmed for cancellation" +msgstr "" + +#. module: purchase_request_cancel_confirm +#: model:ir.model.fields,help:purchase_request_cancel_confirm.field_purchase_request__cancel_reason +msgid "An optional cancel reason" +msgstr "" + +#. module: purchase_request_cancel_confirm +#: model:ir.model.fields,field_description:purchase_request_cancel_confirm.field_purchase_request__cancel_confirm +msgid "Cancel Confirmed" +msgstr "" + +#. module: purchase_request_cancel_confirm +#: model:ir.model.fields,field_description:purchase_request_cancel_confirm.field_purchase_request__cancel_reason +msgid "Cancel Reason" +msgstr "" + +#. module: purchase_request_cancel_confirm +#: model:ir.model,name:purchase_request_cancel_confirm.model_purchase_request +msgid "Purchase Request" +msgstr "" diff --git a/purchase_request_cancel_confirm/model/__init__.py b/purchase_request_cancel_confirm/model/__init__.py new file mode 100644 index 00000000000..9a558ab9799 --- /dev/null +++ b/purchase_request_cancel_confirm/model/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import purchase_request diff --git a/purchase_request_cancel_confirm/model/purchase_request.py b/purchase_request_cancel_confirm/model/purchase_request.py new file mode 100644 index 00000000000..28f618e3ff1 --- /dev/null +++ b/purchase_request_cancel_confirm/model/purchase_request.py @@ -0,0 +1,20 @@ +# Copyright 2020 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class PurchaseRequest(models.Model): + _name = "purchase.request" + _inherit = ["purchase.request", "base.cancel.confirm"] + + _has_cancel_reason = "optional" # ["no", "optional", "required"] + + def button_rejected(self): + if not self.filtered("cancel_confirm"): + return self.open_cancel_confirm_wizard() + return super().button_rejected() + + def button_draft(self): + self.clear_cancel_confirm_data() + return super().button_draft() diff --git a/purchase_request_cancel_confirm/pyproject.toml b/purchase_request_cancel_confirm/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/purchase_request_cancel_confirm/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_request_cancel_confirm/readme/CONTRIBUTORS.md b/purchase_request_cancel_confirm/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..f55e2894eb0 --- /dev/null +++ b/purchase_request_cancel_confirm/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Kitti U. \ diff --git a/purchase_request_cancel_confirm/readme/DESCRIPTION.md b/purchase_request_cancel_confirm/readme/DESCRIPTION.md new file mode 100644 index 00000000000..3e8fedf3dd3 --- /dev/null +++ b/purchase_request_cancel_confirm/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +When user click to cancel purchase request, a confirmation wizard will +be show, with reason as optional. diff --git a/purchase_request_cancel_confirm/static/description/icon.png b/purchase_request_cancel_confirm/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_request_cancel_confirm/static/description/icon.png differ diff --git a/purchase_request_cancel_confirm/static/description/index.html b/purchase_request_cancel_confirm/static/description/index.html new file mode 100644 index 00000000000..e81075ba574 --- /dev/null +++ b/purchase_request_cancel_confirm/static/description/index.html @@ -0,0 +1,432 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Purchase Request Cancel Confirm

+ +

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

+

When user click to cancel purchase request, a confirmation wizard will +be show, with reason as optional.

+

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

+
    +
  • Ecosoft
  • +
+
+ +
+

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 maintainer:

+

kittiu

+

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_request_cancel_confirm/tests/__init__.py b/purchase_request_cancel_confirm/tests/__init__.py new file mode 100644 index 00000000000..cfb192eb35c --- /dev/null +++ b/purchase_request_cancel_confirm/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2020 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_purchase_request_cancel_confirm diff --git a/purchase_request_cancel_confirm/tests/test_purchase_request_cancel_confirm.py b/purchase_request_cancel_confirm/tests/test_purchase_request_cancel_confirm.py new file mode 100644 index 00000000000..2d6d8f3f480 --- /dev/null +++ b/purchase_request_cancel_confirm/tests/test_purchase_request_cancel_confirm.py @@ -0,0 +1,57 @@ +# Copyright 2020 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). +from odoo import SUPERUSER_ID +from odoo.tests import Form + +from odoo.addons.base.tests.common import BaseCommon + + +class TestPurchaseRequestCancelConfirm(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.purchase_request_obj = cls.env["purchase.request"] + cls.env["ir.config_parameter"].sudo().set_param( + "purchase.request.cancel_confirm_disable", "False" + ) + cls.purchase_request_line_obj = cls.env["purchase.request.line"] + cls.product = cls.env["product.product"].create( + { + "name": "Test Product", + "is_storable": True, + } + ) + vals = { + "picking_type_id": cls.env.ref("stock.picking_type_in").id, + "requested_by": SUPERUSER_ID, + } + cls.purchase_request = cls.purchase_request_obj.create(vals) + vals = { + "request_id": cls.purchase_request.id, + "product_id": cls.product.id, + "product_uom_id": cls.env.ref("uom.product_uom_unit").id, + "product_qty": 5.0, + } + cls.purchase_request_line_obj.create(vals) + + def test_01_cancel_confirm_purchase_request(self): + """Cancel a document, I expect cancel_reason. + Then, set to draft, I expect cancel_reason is deleted. + """ + self.purchase_request.button_to_approve() + # Click reject, cancel confirm wizard will open. Type in cancel_reason + res = self.purchase_request.button_rejected() + ctx = res.get("context") + self.assertEqual(ctx["cancel_method"], "button_rejected") + self.assertEqual(ctx["default_has_cancel_reason"], "optional") + wizard = Form(self.env["cancel.confirm"].with_context(**ctx)) + wizard.cancel_reason = "Wrong information" + wiz = wizard.save() + # Confirm cancel on wizard + wiz.confirm_cancel() + self.assertEqual(self.purchase_request.cancel_reason, wizard.cancel_reason) + self.assertEqual(self.purchase_request.state, "rejected") + # Set to draft + self.purchase_request.button_draft() + self.assertEqual(self.purchase_request.cancel_reason, False) + self.assertEqual(self.purchase_request.state, "draft")