Skip to content

Commit

Permalink
[MIG] mail_layout_force: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioM-S73 committed Jan 28, 2025
1 parent 9dced53 commit 7333d77
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 141 deletions.
1 change: 0 additions & 1 deletion mail_layout_force/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import models
from . import wizards
2 changes: 1 addition & 1 deletion mail_layout_force/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Mail Layout Force",
"summary": "Force a mail layout on selected email templates",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["ivantodorovich"],
"website": "https://github.com/OCA/social",
Expand Down
1 change: 0 additions & 1 deletion mail_layout_force/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import mail_template
from . import mail_thread
34 changes: 8 additions & 26 deletions mail_layout_force/models/mail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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

Check warning on line 26 in mail_layout_force/models/mail_template.py

View check run for this annotation

Codecov / codecov/patch

mail_layout_force/models/mail_template.py#L26

Added line #L26 was not covered by tests
20 changes: 0 additions & 20 deletions mail_layout_force/models/mail_thread.py

This file was deleted.

1 change: 0 additions & 1 deletion mail_layout_force/tests/__init__.py

This file was deleted.

73 changes: 0 additions & 73 deletions mail_layout_force/tests/test_mail_layout_force.py

This file was deleted.

1 change: 0 additions & 1 deletion mail_layout_force/wizards/__init__.py

This file was deleted.

17 changes: 0 additions & 17 deletions mail_layout_force/wizards/mail_compose_message.py

This file was deleted.

0 comments on commit 7333d77

Please sign in to comment.