-
-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] mail_layout_force: Migration to 17.0
- Loading branch information
1 parent
9dced53
commit 5d48701
Showing
7 changed files
with
11 additions
and
124 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
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
from . import mail_template | ||
from . import mail_thread |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# @author Iván Todorovich <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
from odoo import fields, models | ||
|
||
|
||
class MailTemplate(models.Model): | ||
|
@@ -16,29 +16,11 @@ class MailTemplate(models.Model): | |
help="Force a mail layout for this template.", | ||
) | ||
|
||
def _ensure_force_email_layout_xml_id(self): | ||
missing = self.force_email_layout_id.filtered(lambda rec: not rec.xml_id) | ||
if missing: | ||
vals = [ | ||
{ | ||
"module": "__export__", | ||
"name": "force_email_layout_%s" % rec.id, | ||
"model": rec._name, | ||
"res_id": rec.id, | ||
} | ||
for rec in missing | ||
] | ||
self.env["ir.model.data"].sudo().create(vals) | ||
self.force_email_layout_id.invalidate_recordset(["xml_id"]) | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
records = super().create(vals_list) | ||
records._ensure_force_email_layout_xml_id() | ||
return records | ||
email_layout_xmlid = fields.Char( | ||
compute="_compute_email_layout_id", store=True, readonly=False | ||
) | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
if "force_email_layout_id" in vals: | ||
self._ensure_force_email_layout_xml_id() | ||
return res | ||
def _compute_email_layout_id(self): | ||
for template in self: | ||
if template.force_email_layout_id: | ||
template.email_layout_xmlid = template.force_email_layout_id.xml_id | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Copyright 2022 Camptocamp SA (https://www.camptocamp.com). | ||
# @author Iván Todorovich <[email protected]> | ||
# Copyright 2023 Abraham Anes <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import models | ||
|
||
|
@@ -14,4 +14,4 @@ def _action_send_mail(self, auto_commit=False): | |
for rec in self: | ||
if rec.template_id.force_email_layout_id: | ||
rec.email_layout_xmlid = rec.template_id.force_email_layout_id.xml_id | ||
return super(MailComposer, self)._action_send_mail(auto_commit=auto_commit) | ||
return super()._action_send_mail(auto_commit=auto_commit) |