-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
135667f
commit d12c41b
Showing
13 changed files
with
681 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://github.com/OCA/social/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 <https://github.com/OCA/social/issues/new?body=module:%20customer_mail_reply_stage%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
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 <https://github.com/OCA/social/tree/15.0/customer_mail_reply_stage>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2025 Quartile Limited | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Customer Mail Reply Stage", | ||
"category": "Mail", | ||
"version": "15.0.1.0.0", | ||
"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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import ir_model | ||
from . import mail_message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright 2025 Quartile Limited | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class MailMessage(models.Model): | ||
_inherit = "mail.message" | ||
|
||
@api.model_create_multi | ||
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) | ||
) | ||
if not res_model.use_reply_stage: | ||
continue | ||
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() | ||
): | ||
continue | ||
user = message.author_id.user_ids[:1] | ||
if user and user.has_group("base.group_user"): | ||
continue | ||
parent = resource[resource._parent_field()] | ||
reply_stage = getattr(parent, resource._reply_stage_field()) | ||
if reply_stage: | ||
resource.sudo().write({"stage_id": reply_stage.id}) | ||
continue | ||
return messages | ||
|
||
def _resource_model(self): | ||
"""Override this method in child models to specify the model name.""" | ||
raise NotImplementedError("Subclasses must implement `_resource_model`.") | ||
|
||
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`.") | ||
|
||
def _reply_stage_field(self): | ||
"""Override this method in child models to specify the reply stage field name.""" | ||
raise NotImplementedError("Subclasses must implement `_reply_stage_field`.") | ||
|
||
def _parent_field(self): | ||
"""Override this method in child models to specify the parent field name.""" | ||
raise NotImplementedError("Subclasses must implement `_parent_field`.") | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
Oops, something went wrong.