diff --git a/base_substate/models/__init__.py b/base_substate/models/__init__.py index da826df400..6ac2cf86a3 100644 --- a/base_substate/models/__init__.py +++ b/base_substate/models/__init__.py @@ -1,3 +1,2 @@ from . import base_substate from . import base_substate_mixin -from . import mail_thread diff --git a/base_substate/models/base_substate_mixin.py b/base_substate/models/base_substate_mixin.py index 6b5f34d9a3..c8e6152de5 100644 --- a/base_substate/models/base_substate_mixin.py +++ b/base_substate/models/base_substate_mixin.py @@ -7,6 +7,7 @@ class BaseSubstateMixin(models.AbstractModel): _name = "base.substate.mixin" + _inherit = "mail.thread" _description = "BaseSubstate Mixin" _state_field = "state" @@ -28,6 +29,23 @@ def check_substate_id_value(self): } ) + def _track_template(self, changes): + res = super()._track_template(changes) + first_rec = self[0] + if "substate_id" in changes and first_rec.substate_id.mail_template_id: + res["substate_id"] = ( + first_rec.substate_id.mail_template_id, + { + "composition_mode": "comment", + "auto_delete_message": True, + "subtype_id": self.env["ir.model.data"]._xmlid_to_res_id( + "mail.mt_note" + ), + "email_layout_xmlid": "mail.mail_notification_light", + }, + ) + return res + def _get_default_substate_id(self, state_val=False): """Gives default substate_id""" search_domain = self._get_default_substate_domain(state_val) diff --git a/base_substate/models/mail_thread.py b/base_substate/models/mail_thread.py deleted file mode 100644 index 017a9bb4cc..0000000000 --- a/base_substate/models/mail_thread.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models - - -class MailThread(models.AbstractModel): - _inherit = "mail.thread" - - def _track_template(self, changes): - res = super()._track_template(changes) - first_rec = self[0] - if "substate_id" in changes and first_rec.substate_id.mail_template_id: - res["substate_id"] = ( - first_rec.substate_id.mail_template_id, - { - "composition_mode": "comment", - "auto_delete_message": True, - "subtype_id": self.env["ir.model.data"]._xmlid_to_res_id( - "mail.mt_note" - ), - "email_layout_xmlid": "mail.mail_notification_light", - }, - ) - return res diff --git a/base_substate/tests/sale_test.py b/base_substate/tests/sale_test.py index 85f05829ad..4f21c0498f 100644 --- a/base_substate/tests/sale_test.py +++ b/base_substate/tests/sale_test.py @@ -7,7 +7,7 @@ class SaleTest(models.Model, TestMixin): _name = "base.substate.test.sale" - _inherit = ["mail.thread", "base.substate.mixin"] + _inherit = ["base.substate.mixin"] _description = "Base substate Test Model" name = fields.Char(required=True)