mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[MIG] base_comment_template: Migration to 15.0
TT35696
This commit is contained in:
committed by
Jesús Alan Ramos Rodríguez
parent
61973247ec
commit
1a9d3178f1
@@ -1,6 +1,8 @@
|
||||
from odoo import api, fields, models
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
|
||||
from odoo.addons.base.models.res_partner import _lang_get
|
||||
|
||||
|
||||
class BaseCommentTemplatePreview(models.TransientModel):
|
||||
_name = "base.comment.template.preview"
|
||||
@@ -11,13 +13,9 @@ class BaseCommentTemplatePreview(models.TransientModel):
|
||||
models = self.env["ir.model"].search([("is_comment_template", "=", True)])
|
||||
return [(model.model, model.name) for model in models]
|
||||
|
||||
@api.model
|
||||
def _selection_languages(self):
|
||||
return self.env["res.lang"].get_installed()
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
result = super(BaseCommentTemplatePreview, self).default_get(fields)
|
||||
result = super().default_get(fields)
|
||||
base_comment_template_id = self.env.context.get(
|
||||
"default_base_comment_template_id"
|
||||
)
|
||||
@@ -41,21 +39,25 @@ class BaseCommentTemplatePreview(models.TransientModel):
|
||||
base_comment_template_id = fields.Many2one(
|
||||
"base.comment.template", required=True, ondelete="cascade"
|
||||
)
|
||||
lang = fields.Selection(_selection_languages, string="Template Preview Language")
|
||||
lang = fields.Selection(_lang_get, string="Template Preview Language")
|
||||
engine = fields.Selection(
|
||||
[("jinja", "Jinja"), ("qweb", "QWeb")],
|
||||
[
|
||||
("inline_template", "Inline template"),
|
||||
("qweb", "QWeb"),
|
||||
("qweb_view", "QWeb view"),
|
||||
],
|
||||
string="Template Preview Engine",
|
||||
default="jinja",
|
||||
default="inline_template",
|
||||
)
|
||||
model_ids = fields.Many2many(
|
||||
"ir.model", related="base_comment_template_id.model_ids"
|
||||
)
|
||||
model_id = fields.Many2one("ir.model")
|
||||
body = fields.Char("Body", compute="_compute_base_comment_template_fields")
|
||||
body = fields.Char(compute="_compute_base_comment_template_fields")
|
||||
resource_ref = fields.Reference(
|
||||
string="Record reference", selection="_selection_target_model"
|
||||
)
|
||||
no_record = fields.Boolean("No Record", compute="_compute_no_record")
|
||||
no_record = fields.Boolean(compute="_compute_no_record")
|
||||
|
||||
@api.depends("model_id")
|
||||
def _compute_no_record(self):
|
||||
|
||||
@@ -1,80 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- SMS Template Preview -->
|
||||
<record model="ir.ui.view" id="base_comment_template_preview_form">
|
||||
<field name="name">base.comment.template.preview.form</field>
|
||||
<field name="model">base.comment.template.preview</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Base Comment Preview">
|
||||
<h3>Preview of
|
||||
<field
|
||||
name="base_comment_template_id"
|
||||
readonly="1"
|
||||
nolabel="1"
|
||||
class="oe_inline"
|
||||
/>
|
||||
</h3>
|
||||
<field name="no_record" invisible="1" />
|
||||
<field name="model_ids" />
|
||||
<div class="o_row">
|
||||
<span>Choose an example
|
||||
<field
|
||||
name="model_id"
|
||||
domain="[('id', 'in', model_ids or False)]"
|
||||
/>
|
||||
record:
|
||||
</span>
|
||||
<div>
|
||||
<field
|
||||
name="resource_ref"
|
||||
class="oe_inline"
|
||||
options="{'hide_model': True, 'no_create': True, 'no_edit': True, 'no_open': True}"
|
||||
attrs="{'invisible': [('no_record', '=', True)]}"
|
||||
/>
|
||||
<span
|
||||
class="text-warning"
|
||||
attrs="{'invisible': [('no_record', '=', False)]}"
|
||||
>No records
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p>Choose a language:
|
||||
<field name="lang" class="oe_inline ml8" />
|
||||
</p>
|
||||
<p>Choose an engine:
|
||||
<field name="engine" class="oe_inline ml8" />
|
||||
</p>
|
||||
<label for="body" string="Base Comment content" />
|
||||
<hr />
|
||||
<record model="ir.ui.view" id="base_comment_template_preview_form">
|
||||
<field name="name">base.comment.template.preview.form</field>
|
||||
<field name="model">base.comment.template.preview</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Base Comment Preview">
|
||||
<h3>Preview of
|
||||
<field
|
||||
name="body"
|
||||
name="base_comment_template_id"
|
||||
readonly="1"
|
||||
nolabel="1"
|
||||
options='{"safe": True}'
|
||||
class="oe_inline"
|
||||
/>
|
||||
<hr />
|
||||
<footer>
|
||||
<button
|
||||
string="Discard"
|
||||
class="btn-secondary"
|
||||
special="cancel"
|
||||
</h3>
|
||||
<field name="no_record" invisible="1" />
|
||||
<field name="model_ids" />
|
||||
<div class="o_row">
|
||||
<span>Choose an example
|
||||
<field
|
||||
name="model_id"
|
||||
domain="[('id', 'in', model_ids or False)]"
|
||||
/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
record:
|
||||
</span>
|
||||
<div>
|
||||
<field
|
||||
name="resource_ref"
|
||||
class="oe_inline"
|
||||
options="{'hide_model': True, 'no_create': True, 'no_edit': True, 'no_open': True}"
|
||||
attrs="{'invisible': [('no_record', '=', True)]}"
|
||||
/>
|
||||
<span
|
||||
class="text-warning"
|
||||
attrs="{'invisible': [('no_record', '=', False)]}"
|
||||
>No records
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p>Choose a language:
|
||||
<field name="lang" class="oe_inline ml8" />
|
||||
</p>
|
||||
<p>Choose an engine:
|
||||
<field name="engine" class="oe_inline ml8" />
|
||||
</p>
|
||||
<label for="body" string="Base Comment content" />
|
||||
<hr />
|
||||
<field name="body" readonly="1" nolabel="1" options='{"safe": True}' />
|
||||
<hr />
|
||||
<footer>
|
||||
<button string="Discard" class="btn-secondary" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="base_comment_template_preview_action" model="ir.actions.act_window">
|
||||
<field name="name">Template Preview</field>
|
||||
<field name="res_model">base.comment.template.preview</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="base_comment_template_preview_form" />
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'default_base_comment_template_id':active_id}</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
<record id="base_comment_template_preview_action" model="ir.actions.act_window">
|
||||
<field name="name">Template Preview</field>
|
||||
<field name="res_model">base.comment.template.preview</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="base_comment_template_preview_form" />
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'default_base_comment_template_id':active_id}</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user