[MIG] [13.0] Migrate base_comment_template from account_invoic_reporting.

This commit is contained in:
Mihai Fekete
2020-07-08 10:37:24 +03:00
committed by Víctor Martínez
parent fe1da090d5
commit 2c3e562dde
18 changed files with 607 additions and 150 deletions

View 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