diff --git a/customer_mail_reply_stage/README.rst b/customer_mail_reply_stage/README.rst new file mode 100644 index 0000000000..d2731e8e48 --- /dev/null +++ b/customer_mail_reply_stage/README.rst @@ -0,0 +1,104 @@ +========================= +Customer Mail Reply Stage +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3e0a708a7c69ddc0f3b1222b5c268d8d6acc6f32c6de186e7c9a5df995a98bb3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/15.0/customer_mail_reply_stage + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-15-0/social-15-0-customer_mail_reply_stage + :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/social&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module serves as a base for automatically updating the stage of a record when a non-internal user replies. +It controls stage updates based on a parent-child relationship, where the reply stage is defined at the parent model level and applied to its child records. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +You need to configure your model when creating submodules: + +1. Navigate to Settings > Technical > Models. +2. Locate the model and enable the Use Reply Stage option. + +Usage +===== + +An example for a submodule called `module_name` for a model: + +A python class :: + + from odoo import models + + class ModelName(models.Model): + _inheirt = 'model_name' + + def _remain_state_field(self): + return 'stage_field_name' + + def _remain_state_value(self): + return "state_value" + + def _parent_field(self): + return 'parent_field_name' + + def _reply_stage_field(self): + return 'reply_stage_field_name' + +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 +~~~~~~~ + +* Quartile + +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/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/customer_mail_reply_stage/__manifest__.py b/customer_mail_reply_stage/__manifest__.py index 4c0da6b5ec..24f2e3cdbe 100644 --- a/customer_mail_reply_stage/__manifest__.py +++ b/customer_mail_reply_stage/__manifest__.py @@ -2,11 +2,12 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Customer Mail Reply Stage", - "category": "Tools", + "category": "Mail", "version": "15.0.1.0.0", - "author": "Quartile Limited", - "website": "https://www.quartile.co", + "author": "Quartile, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/social", "license": "AGPL-3", "depends": ["mail"], + "data": ["views/ir_model_views.xml"], "installable": True, } diff --git a/customer_mail_reply_stage/models/__init__.py b/customer_mail_reply_stage/models/__init__.py index a2bc21ba53..e08f62b74d 100644 --- a/customer_mail_reply_stage/models/__init__.py +++ b/customer_mail_reply_stage/models/__init__.py @@ -1 +1,2 @@ +from . import ir_model from . import mail_message diff --git a/customer_mail_reply_stage/models/ir_model.py b/customer_mail_reply_stage/models/ir_model.py new file mode 100644 index 0000000000..b8dd6f8e6c --- /dev/null +++ b/customer_mail_reply_stage/models/ir_model.py @@ -0,0 +1,12 @@ +# Copyright 2025 Quartile Limited +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class IrModel(models.Model): + _inherit = "ir.model" + + use_reply_stage = fields.Boolean( + help="If enabled, the reply stage feature will be activated for this model." + ) diff --git a/customer_mail_reply_stage/models/mail_message.py b/customer_mail_reply_stage/models/mail_message.py index c4d78e226a..2ead51fddf 100644 --- a/customer_mail_reply_stage/models/mail_message.py +++ b/customer_mail_reply_stage/models/mail_message.py @@ -1,5 +1,5 @@ # Copyright 2025 Quartile Limited -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). from odoo import api, models @@ -11,16 +11,20 @@ class MailMessage(models.Model): def create(self, values_list): messages = super().create(values_list) for message in messages: - res_model = self.env['ir.model'].sudo().search([('model', '=', message.model)], limit=1) + res_model = ( + self.env["ir.model"] + .sudo() + .search([("model", "=", message.model)], limit=1) + ) if not res_model.use_reply_stage: continue - if not ( - message.subtype_id - and not message.subtype_id.internal - ): + if not (message.subtype_id and not message.subtype_id.internal): continue resource = self.env[message.model].browse(message.res_id) - if getattr(resource, resource._remain_state_field()) == resource._remain_state_value(): + if ( + getattr(resource, resource._remain_state_field()) + == resource._remain_state_value() + ): continue user = message.author_id.user_ids[:1] if user and user.has_group("base.group_user"): @@ -28,17 +32,10 @@ def create(self, values_list): parent = resource[resource._parent_field()] reply_stage = getattr(parent, resource._reply_stage_field()) if reply_stage: - resource.sudo().write({'stage_id': reply_stage.id}) + resource.sudo().write({"stage_id": reply_stage.id}) continue - reply_stage_id = int( - self.env["ir.config_parameter"] - .sudo() - .get_param(resource._config_key(), 0) - ) - if reply_stage_id in getattr(parent, 'type_ids').ids: - resource.sudo().write({'stage_id': reply_stage_id}) return messages - + def _resource_model(self): """Override this method in child models to specify the model name.""" raise NotImplementedError("Subclasses must implement `_resource_model`.") @@ -46,7 +43,7 @@ def _resource_model(self): def _remain_state_field(self): """Override this method in child models to specify the remain state.""" raise NotImplementedError("Subclasses must implement `_remain_state_field`.") - + def _remain_state_value(self): """Override this method in child models to specify the remain state value.""" raise NotImplementedError("Subclasses must implement `_remain_state_value`.") @@ -58,7 +55,3 @@ def _reply_stage_field(self): def _parent_field(self): """Override this method in child models to specify the parent field name.""" raise NotImplementedError("Subclasses must implement `_parent_field`.") - - def _config_key(self): - """Override this method in child models to specify the config parameter key.""" - raise NotImplementedError("Subclasses must implement `_config_key`.") diff --git a/customer_mail_reply_stage/readme/CONFIGURE.rst b/customer_mail_reply_stage/readme/CONFIGURE.rst new file mode 100644 index 0000000000..cedb1874a4 --- /dev/null +++ b/customer_mail_reply_stage/readme/CONFIGURE.rst @@ -0,0 +1,4 @@ +You need to configure your model when creating submodules: + +1. Navigate to Settings > Technical > Models. +2. Locate the model and enable the Use Reply Stage option. diff --git a/customer_mail_reply_stage/readme/DESCRIPTION.rst b/customer_mail_reply_stage/readme/DESCRIPTION.rst index e69de29bb2..40c4dcdf90 100644 --- a/customer_mail_reply_stage/readme/DESCRIPTION.rst +++ b/customer_mail_reply_stage/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module serves as a base for automatically updating the stage of a record when a non-internal user replies. +It controls stage updates based on a parent-child relationship, where the reply stage is defined at the parent model level and applied to its child records. diff --git a/customer_mail_reply_stage/readme/USAGE.rst b/customer_mail_reply_stage/readme/USAGE.rst new file mode 100644 index 0000000000..3cbe990792 --- /dev/null +++ b/customer_mail_reply_stage/readme/USAGE.rst @@ -0,0 +1,20 @@ +An example for a submodule called `module_name` for a model: + +A python class :: + + from odoo import models + + class ModelName(models.Model): + _inheirt = 'model_name' + + def _remain_state_field(self): + return 'stage_field_name' + + def _remain_state_value(self): + return "state_value" + + def _parent_field(self): + return 'parent_field_name' + + def _reply_stage_field(self): + return 'reply_stage_field_name' diff --git a/customer_mail_reply_stage/static/description/index.html b/customer_mail_reply_stage/static/description/index.html new file mode 100644 index 0000000000..f9cb3d9b4d --- /dev/null +++ b/customer_mail_reply_stage/static/description/index.html @@ -0,0 +1,447 @@ + + + + + +Customer Mail Reply Stage + + + +
+

Customer Mail Reply Stage

+ + +

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

+

This module serves as a base for automatically updating the stage of a record when a non-internal user replies. +It controls stage updates based on a parent-child relationship, where the reply stage is defined at the parent model level and applied to its child records.

+

Table of contents

+ +
+

Configuration

+

You need to configure your model when creating submodules:

+
    +
  1. Navigate to Settings > Technical > Models.
  2. +
  3. Locate the model and enable the Use Reply Stage option.
  4. +
+
+
+

Usage

+

An example for a submodule called module_name for a model:

+

A python class

+
+from odoo import models
+
+class ModelName(models.Model):
+    _inheirt = 'model_name'
+
+    def _remain_state_field(self):
+        return 'stage_field_name'
+
+    def _remain_state_value(self):
+        return "state_value"
+
+    def _parent_field(self):
+        return 'parent_field_name'
+
+    def _reply_stage_field(self):
+        return 'reply_stage_field_name'
+
+
+
+

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

+
    +
  • Quartile
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/customer_mail_reply_stage/views/ir_model_views.xml b/customer_mail_reply_stage/views/ir_model_views.xml new file mode 100644 index 0000000000..4bfcebae12 --- /dev/null +++ b/customer_mail_reply_stage/views/ir_model_views.xml @@ -0,0 +1,12 @@ + + + ir.model.form.inherit + ir.model + + + + + + + + diff --git a/setup/customer_mail_reply_stage/odoo/addons/customer_mail_reply_stage b/setup/customer_mail_reply_stage/odoo/addons/customer_mail_reply_stage new file mode 120000 index 0000000000..d0d89e331d --- /dev/null +++ b/setup/customer_mail_reply_stage/odoo/addons/customer_mail_reply_stage @@ -0,0 +1 @@ +../../../../customer_mail_reply_stage \ No newline at end of file diff --git a/setup/customer_mail_reply_stage/setup.py b/setup/customer_mail_reply_stage/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/customer_mail_reply_stage/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)