mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[ADD][13.0] new module report_layout_config
This commit is contained in:
committed by
Iryna Vyshnevska
parent
93a005f241
commit
661f59ba23
46
report_layout_config/models/base_document_layout.py
Normal file
46
report_layout_config/models/base_document_layout.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# Copyright 2020 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class BaseDocumentLayout(models.TransientModel):
|
||||
_inherit = "base.document.layout"
|
||||
|
||||
full_header_img = fields.Binary(
|
||||
related="company_id.full_header_img", readonly=False
|
||||
)
|
||||
full_footer_img = fields.Binary(
|
||||
related="company_id.full_footer_img", readonly=False
|
||||
)
|
||||
|
||||
need_images_layout = fields.Boolean(
|
||||
compute="_compute_need_images_layout", readonly=True
|
||||
)
|
||||
|
||||
@api.depends("report_layout_id")
|
||||
def _compute_need_images_layout(self):
|
||||
self.ensure_one()
|
||||
img_lay = self.env.ref("report_layout_config.external_layout_images").view_id
|
||||
self.need_images_layout = self.external_report_layout_id == img_lay
|
||||
|
||||
@api.depends(
|
||||
"report_layout_id",
|
||||
"logo",
|
||||
"font",
|
||||
"primary_color",
|
||||
"secondary_color",
|
||||
"full_footer_img",
|
||||
"full_header_img",
|
||||
)
|
||||
def _compute_preview(self):
|
||||
self.ensure_one()
|
||||
if not self.need_images_layout or not self.report_layout_id:
|
||||
super()._compute_preview()
|
||||
else:
|
||||
ir_qweb = self.env["ir.qweb"]
|
||||
qweb_ctx = self.env["ir.ui.view"]._prepare_qcontext()
|
||||
qweb_ctx.update({"company": self})
|
||||
self.preview = ir_qweb.render(
|
||||
"report_layout_config.layout_preview", qweb_ctx
|
||||
)
|
||||
Reference in New Issue
Block a user