From 427a80c6d5e0a17e9f6b82bde37f40b3d4cd2551 Mon Sep 17 00:00:00 2001
From: Aungkokolin1997 <lin@quartile.co>
Date: Thu, 23 Jan 2025 10:09:53 +0000
Subject: [PATCH] [ADD] mail_reply_stage

---
 mail_reply_stage/README.rst                   |  87 ++++
 mail_reply_stage/__init__.py                  |   1 +
 mail_reply_stage/__manifest__.py              |  16 +
 mail_reply_stage/models/__init__.py           |   2 +
 mail_reply_stage/models/mail_message.py       |  68 +++
 mail_reply_stage/models/mail_reply_config.py  |  62 +++
 mail_reply_stage/readme/CONFIGURE.rst         |  12 +
 mail_reply_stage/readme/DESCRIPTION.rst       |   1 +
 mail_reply_stage/security/ir.model.access.csv |   3 +
 .../static/description/index.html             | 429 ++++++++++++++++++
 .../views/mail_reply_config_views.xml         |  38 ++
 .../odoo/addons/mail_reply_stage              |   1 +
 setup/mail_reply_stage/setup.py               |   6 +
 13 files changed, 726 insertions(+)
 create mode 100644 mail_reply_stage/README.rst
 create mode 100644 mail_reply_stage/__init__.py
 create mode 100644 mail_reply_stage/__manifest__.py
 create mode 100644 mail_reply_stage/models/__init__.py
 create mode 100644 mail_reply_stage/models/mail_message.py
 create mode 100644 mail_reply_stage/models/mail_reply_config.py
 create mode 100644 mail_reply_stage/readme/CONFIGURE.rst
 create mode 100644 mail_reply_stage/readme/DESCRIPTION.rst
 create mode 100644 mail_reply_stage/security/ir.model.access.csv
 create mode 100644 mail_reply_stage/static/description/index.html
 create mode 100644 mail_reply_stage/views/mail_reply_config_views.xml
 create mode 120000 setup/mail_reply_stage/odoo/addons/mail_reply_stage
 create mode 100644 setup/mail_reply_stage/setup.py

diff --git a/mail_reply_stage/README.rst b/mail_reply_stage/README.rst
new file mode 100644
index 0000000000..2622e1f272
--- /dev/null
+++ b/mail_reply_stage/README.rst
@@ -0,0 +1,87 @@
+================
+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/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-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 has the feature to automatically update the stage of the record when a non-internal user sends an update to the record.
+
+**Table of contents**
+
+.. contents::
+   :local:
+
+Configuration
+=============
+
+Go to **Settings > Mail Reply Configurations** and create records according to your needs.
+
+For each record:
+
+- **Model**: Choose a model (required).
+- **Parent Field**: Select the field for the parent field ID (e.g., if you select the model as project.task, choose project_id as the parent field). If a parent field is selected, the system will update the reply stage based on the parent (e.g., tasks under the project will use the reply stage of the matched configuration). If this field is left empty, all records without a matching configuration for their project will use the configuration record that does not specify a parent field.
+- **Parent Model**: The system will assign this automatically.
+- **Parent Field Value**: Set up the name of the parent record (e.g., project name).
+- **Parent Stage Field**: Choose the stages field from the parent model to verify that the reply stage is within the parent stages.
+- **Reply Stage Field**: Choose the field for the stage that will be automatically updated when a non-internal user sends an update.(required)
+- **Reply Stage**: Set the stage value that will be updated.(required)
+- **No Reply Stage**: Set the stage value. If the record is in this state, updates from the user will not change the stage of the record.(required)
+
+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:%20mail_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/mail_reply_stage>`_ project on GitHub.
+
+You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/mail_reply_stage/__init__.py b/mail_reply_stage/__init__.py
new file mode 100644
index 0000000000..0650744f6b
--- /dev/null
+++ b/mail_reply_stage/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/mail_reply_stage/__manifest__.py b/mail_reply_stage/__manifest__.py
new file mode 100644
index 0000000000..3b23f33c05
--- /dev/null
+++ b/mail_reply_stage/__manifest__.py
@@ -0,0 +1,16 @@
+# Copyright 2025 Quartile Limited
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+{
+    "name": "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": [
+        "security/ir.model.access.csv",
+        "views/mail_reply_config_views.xml",
+    ],
+    "installable": True,
+}
diff --git a/mail_reply_stage/models/__init__.py b/mail_reply_stage/models/__init__.py
new file mode 100644
index 0000000000..ad64cea8ed
--- /dev/null
+++ b/mail_reply_stage/models/__init__.py
@@ -0,0 +1,2 @@
+from . import mail_message
+from . import mail_reply_config
diff --git a/mail_reply_stage/models/mail_message.py b/mail_reply_stage/models/mail_message.py
new file mode 100644
index 0000000000..2ec2681111
--- /dev/null
+++ b/mail_reply_stage/models/mail_message.py
@@ -0,0 +1,68 @@
+# 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:
+            user = message.author_id.user_ids[:1]
+            if user and user.has_group("base.group_user"):
+                continue
+            if message.subtype_id and message.subtype_id.internal:
+                continue
+            res_model = (
+                self.env["ir.model"]
+                .sudo()
+                .search([("model", "=", message.model)], limit=1)
+            )
+            if not res_model:
+                continue
+            resource = self.env[message.model].browse(message.res_id)
+            config_records = self.env["mail.reply.config"].search(
+                [("model_id", "=", res_model.id)]
+            )
+            matched_config = None
+            for config in config_records:
+                if config.parent_field_id:
+                    parent_field_value = getattr(
+                        resource, config.parent_field_id.name, None
+                    )
+                    if (
+                        parent_field_value
+                        and getattr(parent_field_value, "name", None)
+                        == config.parent_field_value
+                    ):
+                        matched_config = config
+                        break
+                else:
+                    matched_config = config
+            if not matched_config:
+                continue
+            current_stage = getattr(
+                resource, matched_config.reply_stage_field_id.name, None
+            )
+            if current_stage == matched_config.remain_stage:
+                continue
+            reply_stage_rec = self.env[
+                matched_config.reply_stage_field_id.relation
+            ].search([("name", "=", matched_config.reply_stage)])
+            if config.parent_stage_field_id:
+                allowed_stages = getattr(
+                    parent_field_value,
+                    config.parent_stage_field_id.name,
+                    self.env[matched_config.parent_stage_field_id.relation],
+                )
+                reply_stage_rec = reply_stage_rec.filtered(
+                    lambda stage: stage in allowed_stages
+                )
+            if reply_stage_rec:
+                resource.sudo().write(
+                    {matched_config.reply_stage_field_id.name: reply_stage_rec.id}
+                )
+        return messages
diff --git a/mail_reply_stage/models/mail_reply_config.py b/mail_reply_stage/models/mail_reply_config.py
new file mode 100644
index 0000000000..b8a93f15b0
--- /dev/null
+++ b/mail_reply_stage/models/mail_reply_config.py
@@ -0,0 +1,62 @@
+# Copyright 2025 Quartile Limited
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
+
+from odoo import api, fields, models
+
+
+class MailReplyStage(models.Model):
+    _name = "mail.reply.config"
+
+    model_id = fields.Many2one(
+        "ir.model", string="Model", required=True, ondelete="cascade"
+    )
+    parent_field_id = fields.Many2one(
+        "ir.model.fields",
+        string="Parent Field",
+        domain="[('model_id', '=', model_id), ('ttype', '=', 'many2one')]",
+        ondelete="cascade",
+    )
+    parent_model_name = fields.Char(
+        related="parent_field_id.relation",
+        string="Parent Model",
+        store=True,
+        help="Automatically stores the model name of the related parent entity.",
+    )
+    parent_stage_field_id = fields.Many2one(
+        "ir.model.fields",
+        string="Parent Stage Field",
+        domain="[('model_id.model', '=', parent_model_name), ('ttype', '=', 'many2many')]",
+        ondelete="cascade",
+        help="A Many2Many field within the parent model that defines "
+        "valid stages for this configuration.",
+    )
+    parent_field_value = fields.Char(
+        help="The specific value of the parent field that this configuration applies to. "
+        "For example, a project name."
+    )
+    reply_stage_field_id = fields.Many2one(
+        "ir.model.fields",
+        domain="[('model_id', '=', model_id), ('ttype', '=', 'many2one')]",
+        required=True,
+        ondelete="cascade",
+    )
+    reply_stage = fields.Char(
+        required=True,
+        help="This stage of record will be changed when a non-internal user "
+        "replies to the record.",
+    )
+    remain_stage = fields.Char(
+        string="No Reply Stage",
+        required=True,
+        help="Record in this stage will not update to the mail reply stage "
+        "when a non-internal user replies to the record.",
+    )
+
+    @api.onchange("model_id")
+    def _onchange_model_id(self):
+        self.reply_stage_field_id = False
+
+    @api.onchange("reply_stage_field_id")
+    def _onchange_reply_stage_field_id(self):
+        self.reply_stage = False
+        self.remain_stage = False
diff --git a/mail_reply_stage/readme/CONFIGURE.rst b/mail_reply_stage/readme/CONFIGURE.rst
new file mode 100644
index 0000000000..4f9817d976
--- /dev/null
+++ b/mail_reply_stage/readme/CONFIGURE.rst
@@ -0,0 +1,12 @@
+Go to **Settings > Mail Reply Configurations** and create records according to your needs.
+
+For each record:
+
+- **Model**: Choose a model (required).
+- **Parent Field**: Select the field for the parent field ID (e.g., if you select the model as project.task, choose project_id as the parent field). If a parent field is selected, the system will update the reply stage based on the parent (e.g., tasks under the project will use the reply stage of the matched configuration). If this field is left empty, all records without a matching configuration for their project will use the configuration record that does not specify a parent field.
+- **Parent Model**: The system will assign this automatically.
+- **Parent Field Value**: Set up the name of the parent record (e.g., project name).
+- **Parent Stage Field**: Choose the stages field from the parent model to verify that the reply stage is within the parent stages.
+- **Reply Stage Field**: Choose the field for the stage that will be automatically updated when a non-internal user sends an update.(required)
+- **Reply Stage**: Set the stage value that will be updated.(required)
+- **No Reply Stage**: Set the stage value. If the record is in this state, updates from the user will not change the stage of the record.(required)
diff --git a/mail_reply_stage/readme/DESCRIPTION.rst b/mail_reply_stage/readme/DESCRIPTION.rst
new file mode 100644
index 0000000000..c1d9deec02
--- /dev/null
+++ b/mail_reply_stage/readme/DESCRIPTION.rst
@@ -0,0 +1 @@
+This module has the feature to automatically update the stage of the record when a non-internal user sends an update to the record.
diff --git a/mail_reply_stage/security/ir.model.access.csv b/mail_reply_stage/security/ir.model.access.csv
new file mode 100644
index 0000000000..7eb425b993
--- /dev/null
+++ b/mail_reply_stage/security/ir.model.access.csv
@@ -0,0 +1,3 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_mail_reply_config_all,mail.reply.config.all,model_mail_reply_config,,1,0,0,0
+access_mail_reply_config_admin,mail.reply.config.admin,model_mail_reply_config,base.group_system,1,1,1,1
diff --git a/mail_reply_stage/static/description/index.html b/mail_reply_stage/static/description/index.html
new file mode 100644
index 0000000000..67e3ebfaf9
--- /dev/null
+++ b/mail_reply_stage/static/description/index.html
@@ -0,0 +1,429 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
+<title>Mail Reply Stage</title>
+<style type="text/css">
+
+/*
+:Author: David Goodger (goodger@python.org)
+:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
+:Copyright: This stylesheet has been placed in the public domain.
+
+Default cascading style sheet for the HTML output of Docutils.
+
+See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
+customize this style sheet.
+*/
+
+/* used to remove borders from tables and images */
+.borderless, table.borderless td, table.borderless th {
+  border: 0 }
+
+table.borderless td, table.borderless th {
+  /* Override padding for "table.docutils td" with "! important".
+     The right padding separates the table cells. */
+  padding: 0 0.5em 0 0 ! important }
+
+.first {
+  /* Override more specific margin styles with "! important". */
+  margin-top: 0 ! important }
+
+.last, .with-subtitle {
+  margin-bottom: 0 ! important }
+
+.hidden {
+  display: none }
+
+.subscript {
+  vertical-align: sub;
+  font-size: smaller }
+
+.superscript {
+  vertical-align: super;
+  font-size: smaller }
+
+a.toc-backref {
+  text-decoration: none ;
+  color: black }
+
+blockquote.epigraph {
+  margin: 2em 5em ; }
+
+dl.docutils dd {
+  margin-bottom: 0.5em }
+
+object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
+  overflow: hidden;
+}
+
+/* Uncomment (and remove this text!) to get bold-faced definition list terms
+dl.docutils dt {
+  font-weight: bold }
+*/
+
+div.abstract {
+  margin: 2em 5em }
+
+div.abstract p.topic-title {
+  font-weight: bold ;
+  text-align: center }
+
+div.admonition, div.attention, div.caution, div.danger, div.error,
+div.hint, div.important, div.note, div.tip, div.warning {
+  margin: 2em ;
+  border: medium outset ;
+  padding: 1em }
+
+div.admonition p.admonition-title, div.hint p.admonition-title,
+div.important p.admonition-title, div.note p.admonition-title,
+div.tip p.admonition-title {
+  font-weight: bold ;
+  font-family: sans-serif }
+
+div.attention p.admonition-title, div.caution p.admonition-title,
+div.danger p.admonition-title, div.error p.admonition-title,
+div.warning p.admonition-title, .code .error {
+  color: red ;
+  font-weight: bold ;
+  font-family: sans-serif }
+
+/* Uncomment (and remove this text!) to get reduced vertical space in
+   compound paragraphs.
+div.compound .compound-first, div.compound .compound-middle {
+  margin-bottom: 0.5em }
+
+div.compound .compound-last, div.compound .compound-middle {
+  margin-top: 0.5em }
+*/
+
+div.dedication {
+  margin: 2em 5em ;
+  text-align: center ;
+  font-style: italic }
+
+div.dedication p.topic-title {
+  font-weight: bold ;
+  font-style: normal }
+
+div.figure {
+  margin-left: 2em ;
+  margin-right: 2em }
+
+div.footer, div.header {
+  clear: both;
+  font-size: smaller }
+
+div.line-block {
+  display: block ;
+  margin-top: 1em ;
+  margin-bottom: 1em }
+
+div.line-block div.line-block {
+  margin-top: 0 ;
+  margin-bottom: 0 ;
+  margin-left: 1.5em }
+
+div.sidebar {
+  margin: 0 0 0.5em 1em ;
+  border: medium outset ;
+  padding: 1em ;
+  background-color: #ffffee ;
+  width: 40% ;
+  float: right ;
+  clear: right }
+
+div.sidebar p.rubric {
+  font-family: sans-serif ;
+  font-size: medium }
+
+div.system-messages {
+  margin: 5em }
+
+div.system-messages h1 {
+  color: red }
+
+div.system-message {
+  border: medium outset ;
+  padding: 1em }
+
+div.system-message p.system-message-title {
+  color: red ;
+  font-weight: bold }
+
+div.topic {
+  margin: 2em }
+
+h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
+h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
+  margin-top: 0.4em }
+
+h1.title {
+  text-align: center }
+
+h2.subtitle {
+  text-align: center }
+
+hr.docutils {
+  width: 75% }
+
+img.align-left, .figure.align-left, object.align-left, table.align-left {
+  clear: left ;
+  float: left ;
+  margin-right: 1em }
+
+img.align-right, .figure.align-right, object.align-right, table.align-right {
+  clear: right ;
+  float: right ;
+  margin-left: 1em }
+
+img.align-center, .figure.align-center, object.align-center {
+  display: block;
+  margin-left: auto;
+  margin-right: auto;
+}
+
+table.align-center {
+  margin-left: auto;
+  margin-right: auto;
+}
+
+.align-left {
+  text-align: left }
+
+.align-center {
+  clear: both ;
+  text-align: center }
+
+.align-right {
+  text-align: right }
+
+/* reset inner alignment in figures */
+div.align-right {
+  text-align: inherit }
+
+/* div.align-center * { */
+/*   text-align: left } */
+
+.align-top    {
+  vertical-align: top }
+
+.align-middle {
+  vertical-align: middle }
+
+.align-bottom {
+  vertical-align: bottom }
+
+ol.simple, ul.simple {
+  margin-bottom: 1em }
+
+ol.arabic {
+  list-style: decimal }
+
+ol.loweralpha {
+  list-style: lower-alpha }
+
+ol.upperalpha {
+  list-style: upper-alpha }
+
+ol.lowerroman {
+  list-style: lower-roman }
+
+ol.upperroman {
+  list-style: upper-roman }
+
+p.attribution {
+  text-align: right ;
+  margin-left: 50% }
+
+p.caption {
+  font-style: italic }
+
+p.credits {
+  font-style: italic ;
+  font-size: smaller }
+
+p.label {
+  white-space: nowrap }
+
+p.rubric {
+  font-weight: bold ;
+  font-size: larger ;
+  color: maroon ;
+  text-align: center }
+
+p.sidebar-title {
+  font-family: sans-serif ;
+  font-weight: bold ;
+  font-size: larger }
+
+p.sidebar-subtitle {
+  font-family: sans-serif ;
+  font-weight: bold }
+
+p.topic-title {
+  font-weight: bold }
+
+pre.address {
+  margin-bottom: 0 ;
+  margin-top: 0 ;
+  font: inherit }
+
+pre.literal-block, pre.doctest-block, pre.math, pre.code {
+  margin-left: 2em ;
+  margin-right: 2em }
+
+pre.code .ln { color: grey; } /* line numbers */
+pre.code, code { background-color: #eeeeee }
+pre.code .comment, code .comment { color: #5C6576 }
+pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
+pre.code .literal.string, code .literal.string { color: #0C5404 }
+pre.code .name.builtin, code .name.builtin { color: #352B84 }
+pre.code .deleted, code .deleted { background-color: #DEB0A1}
+pre.code .inserted, code .inserted { background-color: #A3D289}
+
+span.classifier {
+  font-family: sans-serif ;
+  font-style: oblique }
+
+span.classifier-delimiter {
+  font-family: sans-serif ;
+  font-weight: bold }
+
+span.interpreted {
+  font-family: sans-serif }
+
+span.option {
+  white-space: nowrap }
+
+span.pre {
+  white-space: pre }
+
+span.problematic {
+  color: red }
+
+span.section-subtitle {
+  /* font-size relative to parent (h1..h6 element) */
+  font-size: 80% }
+
+table.citation {
+  border-left: solid 1px gray;
+  margin-left: 1px }
+
+table.docinfo {
+  margin: 2em 4em }
+
+table.docutils {
+  margin-top: 0.5em ;
+  margin-bottom: 0.5em }
+
+table.footnote {
+  border-left: solid 1px black;
+  margin-left: 1px }
+
+table.docutils td, table.docutils th,
+table.docinfo td, table.docinfo th {
+  padding-left: 0.5em ;
+  padding-right: 0.5em ;
+  vertical-align: top }
+
+table.docutils th.field-name, table.docinfo th.docinfo-name {
+  font-weight: bold ;
+  text-align: left ;
+  white-space: nowrap ;
+  padding-left: 0 }
+
+/* "booktabs" style (no vertical lines) */
+table.docutils.booktabs {
+  border: 0px;
+  border-top: 2px solid;
+  border-bottom: 2px solid;
+  border-collapse: collapse;
+}
+table.docutils.booktabs * {
+  border: 0px;
+}
+table.docutils.booktabs th {
+  border-bottom: thin solid;
+  text-align: left;
+}
+
+h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
+h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
+  font-size: 100% }
+
+ul.auto-toc {
+  list-style-type: none }
+
+</style>
+</head>
+<body>
+<div class="document" id="mail-reply-stage">
+<h1 class="title">Mail Reply Stage</h1>
+
+<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! This file is generated by oca-gen-addon-readme !!
+!! changes will be overwritten.                   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! source digest: sha256:3e0a708a7c69ddc0f3b1222b5c268d8d6acc6f32c6de186e7c9a5df995a98bb3
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
+<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/social/tree/15.0/mail_reply_stage"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/social-15-0/social-15-0-mail_reply_stage"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/social&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
+<p>This module has the feature to automatically update the stage of the record when a non-internal user sends an update to the record.</p>
+<p><strong>Table of contents</strong></p>
+<div class="contents local topic" id="contents">
+<ul class="simple">
+<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
+<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
+<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
+<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
+<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
+</ul>
+</li>
+</ul>
+</div>
+<div class="section" id="configuration">
+<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
+<p>Go to <strong>Settings &gt; Mail Reply Configurations</strong> and create records according to your needs.</p>
+<p>For each record:</p>
+<ul class="simple">
+<li><strong>Model</strong>: Choose a model (required).</li>
+<li><strong>Parent Field</strong>: Select the field for the parent field ID (e.g., if you select the model as project.task, choose project_id as the parent field). If a parent field is selected, the system will update the reply stage based on the parent (e.g., tasks under the project will use the reply stage of the matched configuration). If this field is left empty, all records without a matching configuration for their project will use the configuration record that does not specify a parent field.</li>
+<li><strong>Parent Model</strong>: The system will assign this automatically.</li>
+<li><strong>Parent Field Value</strong>: Set up the name of the parent record (e.g., project name).</li>
+<li><strong>Parent Stage Field</strong>: Choose the stages field from the parent model to verify that the reply stage is within the parent stages.</li>
+<li><strong>Reply Stage Field</strong>: Choose the field for the stage that will be automatically updated when a non-internal user sends an update.(required)</li>
+<li><strong>Reply Stage</strong>: Set the stage value that will be updated.(required)</li>
+<li><strong>No Reply Stage</strong>: Set the stage value. If the record is in this state, updates from the user will not change the stage of the record.(required)</li>
+</ul>
+</div>
+<div class="section" id="bug-tracker">
+<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
+<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
+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
+<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_reply_stage%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
+<p>Do not contact contributors directly about support or help with technical issues.</p>
+</div>
+<div class="section" id="credits">
+<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
+<div class="section" id="authors">
+<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
+<ul class="simple">
+<li>Quartile</li>
+</ul>
+</div>
+<div class="section" id="maintainers">
+<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
+<p>This module is maintained by the OCA.</p>
+<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
+<p>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.</p>
+<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/15.0/mail_reply_stage">OCA/social</a> project on GitHub.</p>
+<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
+</div>
+</div>
+</div>
+</body>
+</html>
diff --git a/mail_reply_stage/views/mail_reply_config_views.xml b/mail_reply_stage/views/mail_reply_config_views.xml
new file mode 100644
index 0000000000..005b0fd4f1
--- /dev/null
+++ b/mail_reply_stage/views/mail_reply_config_views.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+    <record id="view_mail_reply_config_tree" model="ir.ui.view">
+        <field name="name">mail.reply.config.tree</field>
+        <field name="model">mail.reply.config</field>
+        <field name="arch" type="xml">
+            <tree editable="top">
+                <field name="model_id" />
+                <field name="parent_field_id" />
+                <field name="parent_model_name" />
+                <field
+                    name="parent_field_value"
+                    attrs="{'required': [('parent_field_id', '!=', False)]}"
+                />
+                <field
+                    name="parent_stage_field_id"
+                    attrs="{'required': [('parent_field_id', '!=', False)]}"
+                />
+                <field name="reply_stage_field_id" />
+                <field name="reply_stage" />
+                <field name="remain_stage" />
+            </tree>
+        </field>
+    </record>
+    <record id="action_mail_reply_config" model="ir.actions.act_window">
+        <field name="name">Mail Reply Configurations</field>
+        <field name="res_model">mail.reply.config</field>
+        <field name="view_mode">tree</field>
+        <field name="view_id" ref="view_mail_reply_config_tree" />
+    </record>
+    <menuitem
+        id="menu_mail_reply_config"
+        name="Mail Reply Configurations"
+        parent="base.menu_administration"
+        action="action_mail_reply_config"
+        sequence="10"
+    />
+</odoo>
diff --git a/setup/mail_reply_stage/odoo/addons/mail_reply_stage b/setup/mail_reply_stage/odoo/addons/mail_reply_stage
new file mode 120000
index 0000000000..dbc0c8b748
--- /dev/null
+++ b/setup/mail_reply_stage/odoo/addons/mail_reply_stage
@@ -0,0 +1 @@
+../../../../mail_reply_stage
\ No newline at end of file
diff --git a/setup/mail_reply_stage/setup.py b/setup/mail_reply_stage/setup.py
new file mode 100644
index 0000000000..28c57bb640
--- /dev/null
+++ b/setup/mail_reply_stage/setup.py
@@ -0,0 +1,6 @@
+import setuptools
+
+setuptools.setup(
+    setup_requires=['setuptools-odoo'],
+    odoo_addon=True,
+)