mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[MIG] base_comment_template: Migration to 18.0
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
# Copyright 2020 NextERP Romania SRL
|
||||
# Copyright 2021-2022 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from odoo import _, api, fields, models
|
||||
from odoo import Command, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ class BaseCommentTemplate(models.Model):
|
||||
column1="base_comment_template_id",
|
||||
column2="res_partner_id",
|
||||
string="Partner",
|
||||
readonly=True,
|
||||
help="If set, the comment template will be available only for the selected "
|
||||
"partner.",
|
||||
)
|
||||
@@ -104,7 +103,7 @@ class BaseCommentTemplate(models.Model):
|
||||
models = im_model.browse()
|
||||
if item.models:
|
||||
models = self._get_ir_model_items(item.models.split(","))
|
||||
item.model_ids = [(6, 0, models.ids)]
|
||||
item.model_ids = [Command.set(models.ids)]
|
||||
|
||||
@api.constrains("models")
|
||||
def check_models(self):
|
||||
@@ -113,7 +112,9 @@ class BaseCommentTemplate(models.Model):
|
||||
models = item.models.split(",")
|
||||
res = self._get_ir_model_items(item.models.split(","))
|
||||
if not res or len(res) != len(models):
|
||||
raise ValidationError(_("Some model (%s) not found") % item.models)
|
||||
raise ValidationError(
|
||||
self.env._(f"Some model ({item.models}) not found")
|
||||
)
|
||||
|
||||
@api.depends("position", "model_ids")
|
||||
def _compute_display_name(self):
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
import markupsafe
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import Command, api, fields, models
|
||||
from odoo.osv import expression
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
|
||||
@@ -49,7 +49,7 @@ class CommentTemplate(models.AbstractModel):
|
||||
for template in templates:
|
||||
domain = safe_eval(template.domain)
|
||||
if not domain or record.filtered_domain(domain):
|
||||
record.comment_template_ids = [(4, template.id)]
|
||||
record.comment_template_ids = [Command.link(template.id)]
|
||||
|
||||
def render_comment(self, comment, engine=False, add_context=None, options=None):
|
||||
self.ensure_one()
|
||||
|
||||
Reference in New Issue
Block a user