mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[MIG] [13.0] Migrate base_comment_template from account_invoic_reporting.
This commit is contained in:
committed by
Víctor Martínez
parent
fe1da090d5
commit
2c3e562dde
33
base_comment_template/models/ir_model.py
Normal file
33
base_comment_template/models/ir_model.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# Copyright 2020 NextERP Romania SRL
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class IrModel(models.Model):
|
||||
_inherit = "ir.model"
|
||||
|
||||
is_comment_template = fields.Boolean(
|
||||
string="Comment Template",
|
||||
default=False,
|
||||
help="Whether this model supports in reports to add " "comment templates.",
|
||||
)
|
||||
|
||||
def _reflect_model_params(self, model):
|
||||
vals = super(IrModel, self)._reflect_model_params(model)
|
||||
vals["is_comment_template"] = issubclass(
|
||||
type(model), self.pool["comment.template"]
|
||||
)
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
def _instanciate(self, model_data):
|
||||
model_class = super(IrModel, self)._instanciate(model_data)
|
||||
if (
|
||||
model_data.get("is_comment_template")
|
||||
and model_class._name != "comment.template"
|
||||
):
|
||||
parents = model_class._inherit or []
|
||||
parents = [parents] if isinstance(parents, str) else parents
|
||||
model_class._inherit = parents + ["comment.template"]
|
||||
return model_class
|
||||
Reference in New Issue
Block a user