Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][ADD] customer_mail_reply_stage #1553

Draft
wants to merge 1 commit into
base: 15.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions customer_mail_reply_stage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
12 changes: 12 additions & 0 deletions customer_mail_reply_stage/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Quartile Limited
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Customer Mail Reply Stage",
"category": "Tools",
"version": "15.0.1.0.0",
"author": "Quartile Limited",
"website": "https://www.quartile.co",
"license": "AGPL-3",
"depends": ["mail"],
"installable": True,
}
1 change: 1 addition & 0 deletions customer_mail_reply_stage/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mail_message
63 changes: 63 additions & 0 deletions customer_mail_reply_stage/models/mail_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2025 Quartile Limited
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

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:

if not (
message.model == self._resource_model()
and message.subtype_id
and not message.subtype_id.internal
):
continue
resource = self.env[self._resource_model()].browse(message.res_id)
if getattr(resource, self._remain_state_field()) == self._remain_state_value():
continue
user = message.author_id.user_ids[:1]
if user and user.has_group("base.group_user"):
continue
parent = resource[self._parent_field()]
reply_stage = getattr(parent, self._reply_stage_field())
if reply_stage:
resource.sudo().write({'stage_id': reply_stage.id})
continue
reply_stage_id = int(
self.env["ir.config_parameter"]
.sudo()
.get_param(self._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`.")

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`.")

def _config_key(self):
"""Override this method in child models to specify the config parameter key."""
raise NotImplementedError("Subclasses must implement `_config_key`.")
Empty file.
Loading