diff --git a/base_cancel_confirm_selection/README.rst b/base_cancel_confirm_selection/README.rst new file mode 100644 index 0000000000..a89718dfa1 --- /dev/null +++ b/base_cancel_confirm_selection/README.rst @@ -0,0 +1,97 @@ +============================= +Base Cancel Confirm Selection +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:27aca3aeae58b252f6db12e2f9abb388a47be1daa042902839d138712832f66e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fserver--ux-lightgray.png?logo=github + :target: https://github.com/OCA/server-ux/tree/18.0/base_cancel_confirm_selection + :alt: OCA/server-ux +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-ux-18-0/server-ux-18-0-base_cancel_confirm_selection + :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/server-ux&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module introduces a selection field for cancellation reasons +instead of free text, enabling better reporting and analysis of +cancellation causes. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To use cancellation reasons as a selection field, you must first +configure them under **Settings > Technical > Cancel Reason +Configuration** Create all necessary reasons there. they can be defined +and displayed separately for each model. + +After that, when a record is cancelled, it will display a reason field, +and users can select the appropriate reason. + +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 +------------ + +- Saran Lim. + +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-Saran440| image:: https://github.com/Saran440.png?size=40px + :target: https://github.com/Saran440 + :alt: Saran440 + +Current `maintainer `__: + +|maintainer-Saran440| + +This module is part of the `OCA/server-ux `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_cancel_confirm_selection/__init__.py b/base_cancel_confirm_selection/__init__.py new file mode 100644 index 0000000000..b7d72ad142 --- /dev/null +++ b/base_cancel_confirm_selection/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import model +from . import wizard diff --git a/base_cancel_confirm_selection/__manifest__.py b/base_cancel_confirm_selection/__manifest__.py new file mode 100644 index 0000000000..c3a00a70e6 --- /dev/null +++ b/base_cancel_confirm_selection/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2025 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Base Cancel Confirm Selection", + "version": "18.0.1.0.0", + "author": "Ecosoft, Odoo Community Association (OCA)", + "category": "Usability", + "license": "AGPL-3", + "website": "https://github.com/OCA/server-ux", + "depends": ["base_cancel_confirm"], + "data": [ + "security/ir.model.access.csv", + "wizard/cancel_confirm.xml", + "views/cancel_reason_view.xml", + "views/cancel_confirm_template.xml", + ], + "installable": True, + "maintainers": ["Saran440"], +} diff --git a/base_cancel_confirm_selection/model/__init__.py b/base_cancel_confirm_selection/model/__init__.py new file mode 100644 index 0000000000..521ab63c4e --- /dev/null +++ b/base_cancel_confirm_selection/model/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import res_cancel_reason +from . import base_cancel_confirm diff --git a/base_cancel_confirm_selection/model/base_cancel_confirm.py b/base_cancel_confirm_selection/model/base_cancel_confirm.py new file mode 100644 index 0000000000..016e804b10 --- /dev/null +++ b/base_cancel_confirm_selection/model/base_cancel_confirm.py @@ -0,0 +1,19 @@ +# Copyright 2025 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class BaseCancelConfirm(models.AbstractModel): + _inherit = "base.cancel.confirm" + + cancel_reason_id = fields.Many2one( + comodel_name="res.cancel.reason", + string="Cancel Reason Selection", + index=True, + ) + + def _get_value_clear_cancel(self): + vals_cancel = super()._get_value_clear_cancel() + vals_cancel["cancel_reason_id"] = False + return vals_cancel diff --git a/base_cancel_confirm_selection/model/res_cancel_reason.py b/base_cancel_confirm_selection/model/res_cancel_reason.py new file mode 100644 index 0000000000..140e90f3ec --- /dev/null +++ b/base_cancel_confirm_selection/model/res_cancel_reason.py @@ -0,0 +1,17 @@ +# Copyright 2025 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResCancelReason(models.Model): + _name = "res.cancel.reason" + _description = "Cancel Reason" + + name = fields.Char(required=True, translate=True) + description = fields.Text( + help="Explanation of the reason, Why we should select this reason?" + ) + model_id = fields.Many2one(comodel_name="ir.model", string="Referenced Model") + model = fields.Char(related="model_id.model", index=True, store=True) + active = fields.Boolean(default=True) diff --git a/base_cancel_confirm_selection/pyproject.toml b/base_cancel_confirm_selection/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/base_cancel_confirm_selection/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/base_cancel_confirm_selection/readme/CONFIGURE.md b/base_cancel_confirm_selection/readme/CONFIGURE.md new file mode 100644 index 0000000000..22abe6b061 --- /dev/null +++ b/base_cancel_confirm_selection/readme/CONFIGURE.md @@ -0,0 +1,5 @@ +To use cancellation reasons as a selection field, +you must first configure them under **Settings > Technical > Cancel Reason Configuration** +Create all necessary reasons there. they can be defined and displayed separately for each model. + +After that, when a record is cancelled, it will display a reason field, and users can select the appropriate reason. \ No newline at end of file diff --git a/base_cancel_confirm_selection/readme/CONTRIBUTORS.md b/base_cancel_confirm_selection/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..8d0d33151c --- /dev/null +++ b/base_cancel_confirm_selection/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Saran Lim. \<\> diff --git a/base_cancel_confirm_selection/readme/DESCRIPTION.md b/base_cancel_confirm_selection/readme/DESCRIPTION.md new file mode 100644 index 0000000000..3452ec57f9 --- /dev/null +++ b/base_cancel_confirm_selection/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module introduces a selection field for cancellation reasons instead of free text, enabling better reporting and analysis of cancellation causes. \ No newline at end of file diff --git a/base_cancel_confirm_selection/security/ir.model.access.csv b/base_cancel_confirm_selection/security/ir.model.access.csv new file mode 100644 index 0000000000..7b14a53808 --- /dev/null +++ b/base_cancel_confirm_selection/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_res_cancel_reason,access_res_cancel_reason,model_res_cancel_reason,base.group_user,1,1,1,1 diff --git a/base_cancel_confirm_selection/static/description/icon.png b/base_cancel_confirm_selection/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/base_cancel_confirm_selection/static/description/icon.png differ diff --git a/base_cancel_confirm_selection/static/description/index.html b/base_cancel_confirm_selection/static/description/index.html new file mode 100644 index 0000000000..966e53bcb6 --- /dev/null +++ b/base_cancel_confirm_selection/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +Base Cancel Confirm Selection + + + +
+

Base Cancel Confirm Selection

+ + +

Beta License: AGPL-3 OCA/server-ux Translate me on Weblate Try me on Runboat

+

This module introduces a selection field for cancellation reasons +instead of free text, enabling better reporting and analysis of +cancellation causes.

+

Table of contents

+ +
+

Configuration

+

To use cancellation reasons as a selection field, you must first +configure them under Settings > Technical > Cancel Reason +Configuration Create all necessary reasons there. they can be defined +and displayed separately for each model.

+

After that, when a record is cancelled, it will display a reason field, +and users can select the appropriate reason.

+
+
+

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

+ +
+
+

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:

+

Saran440

+

This module is part of the OCA/server-ux project on GitHub.

+

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

+
+
+
+ + diff --git a/base_cancel_confirm_selection/views/cancel_confirm_template.xml b/base_cancel_confirm_selection/views/cancel_confirm_template.xml new file mode 100644 index 0000000000..f3264eafaa --- /dev/null +++ b/base_cancel_confirm_selection/views/cancel_confirm_template.xml @@ -0,0 +1,12 @@ + + + + diff --git a/base_cancel_confirm_selection/views/cancel_reason_view.xml b/base_cancel_confirm_selection/views/cancel_reason_view.xml new file mode 100644 index 0000000000..b4bb5e5e54 --- /dev/null +++ b/base_cancel_confirm_selection/views/cancel_reason_view.xml @@ -0,0 +1,53 @@ + + + + cancel.reason.list.view + res.cancel.reason + + + + + + + + + + cancel.reason.form.view + res.cancel.reason + +
+ + + + + + + + + + + + + +
+
+
+ + + Cancel Reason + res.cancel.reason + list,form + + + +
diff --git a/base_cancel_confirm_selection/wizard/__init__.py b/base_cancel_confirm_selection/wizard/__init__.py new file mode 100644 index 0000000000..e2d99ffc43 --- /dev/null +++ b/base_cancel_confirm_selection/wizard/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import cancel_confirm diff --git a/base_cancel_confirm_selection/wizard/cancel_confirm.py b/base_cancel_confirm_selection/wizard/cancel_confirm.py new file mode 100644 index 0000000000..e57f46cc33 --- /dev/null +++ b/base_cancel_confirm_selection/wizard/cancel_confirm.py @@ -0,0 +1,30 @@ +# Copyright 2025 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class CancelConfirm(models.TransientModel): + _inherit = "cancel.confirm" + + cancel_reason_id = fields.Many2one( + comodel_name="res.cancel.reason", + string="Reason for cancellation", + ) + cancel_res_model = fields.Char( + default=lambda self: self.env.context.get("cancel_res_model") + ) + + @api.onchange("cancel_reason_id") + def _onchange_cancel_reason_id(self): + if self.cancel_reason_id: + self.cancel_reason = self.cancel_reason_id.name + else: + self.cancel_reason = False + + def _get_dict_update(self): + dict_update = super()._get_dict_update() + # Cancel Reason ID + if self.has_cancel_reason in ["optional", "required"]: + dict_update.update({"cancel_reason_id": self.cancel_reason_id.id}) + return dict_update diff --git a/base_cancel_confirm_selection/wizard/cancel_confirm.xml b/base_cancel_confirm_selection/wizard/cancel_confirm.xml new file mode 100644 index 0000000000..4fbf18e0d9 --- /dev/null +++ b/base_cancel_confirm_selection/wizard/cancel_confirm.xml @@ -0,0 +1,17 @@ + + + + Cancel Confirmation + cancel.confirm + + + + + + + + +