mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[14.0][IMP] add layout for clean template
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
"depends": ["web", "base"],
|
"depends": ["web", "base"],
|
||||||
"data": [
|
"data": [
|
||||||
"views/document_layout.xml",
|
"views/document_layout.xml",
|
||||||
|
"templates/assets.xml",
|
||||||
"templates/report_templates.xml",
|
"templates/report_templates.xml",
|
||||||
"data/report_layout.xml",
|
"data/report_layout.xml",
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,14 +1,27 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="external_layout_images" model="report.layout">
|
<record id="external_layout_images_standard" model="report.layout">
|
||||||
<field name="name">Layout images</field>
|
<field name="name">Layout images standard</field>
|
||||||
<field
|
<field
|
||||||
name="view_id"
|
name="view_id"
|
||||||
ref="report_layout_config.external_layout_images_template"
|
ref="report_layout_config.external_standard_layout_images_template"
|
||||||
/>
|
/>
|
||||||
<field
|
<field
|
||||||
name="image"
|
name="image"
|
||||||
>/report_layout_config/static/img/preview_standard.png</field>
|
>/report_layout_config/static/img/preview_standard.png</field>
|
||||||
<field name="pdf">/report_layout_config/static/pdf/preview_standard.pdf</field>
|
<field name="pdf">/report_layout_config/static/pdf/preview_standard.pdf</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="external_layout_images_clean" model="report.layout">
|
||||||
|
<field name="name">Layout images clean</field>
|
||||||
|
<field
|
||||||
|
name="view_id"
|
||||||
|
ref="report_layout_config.external_clean_layout_images_template"
|
||||||
|
/>
|
||||||
|
<field
|
||||||
|
name="image"
|
||||||
|
>/report_layout_config/static/img/preview_standard.png</field>
|
||||||
|
<field name="pdf">/report_layout_config/static/pdf/preview_standard.pdf</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
18
report_layout_config/migrations/14.0.1.0.0/pre-migrate.py
Normal file
18
report_layout_config/migrations/14.0.1.0.0/pre-migrate.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Copyright 2021 Camptocamp SA
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
|
||||||
|
from openupgradelib.openupgrade import rename_xmlids
|
||||||
|
|
||||||
|
|
||||||
|
def migrate(cr, version):
|
||||||
|
|
||||||
|
rename_xmlids(
|
||||||
|
cr,
|
||||||
|
[
|
||||||
|
(
|
||||||
|
"report_layout_config.external_layout_images",
|
||||||
|
"report_layout_config.external_standard_layout_images_template",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
@@ -8,22 +8,16 @@ class BaseDocumentLayout(models.TransientModel):
|
|||||||
_inherit = "base.document.layout"
|
_inherit = "base.document.layout"
|
||||||
|
|
||||||
full_header_img = fields.Binary(
|
full_header_img = fields.Binary(
|
||||||
related="company_id.full_header_img", readonly=False
|
related="company_id.full_header_img",
|
||||||
|
readonly=False,
|
||||||
|
help="Replaces whole header with image",
|
||||||
)
|
)
|
||||||
full_footer_img = fields.Binary(
|
full_footer_img = fields.Binary(
|
||||||
related="company_id.full_footer_img", readonly=False
|
related="company_id.full_footer_img",
|
||||||
|
readonly=False,
|
||||||
|
help="Replaces whole footer, disables footer logo",
|
||||||
)
|
)
|
||||||
|
|
||||||
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(
|
@api.depends(
|
||||||
"full_footer_img",
|
"full_footer_img",
|
||||||
"full_header_img",
|
"full_header_img",
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
* Thomas Nowicki <thomas.nowicki@camptocamp.com>
|
* Thomas Nowicki <thomas.nowicki@camptocamp.com>
|
||||||
|
* Iryna Vyshnevska <iryna.vyshnevska@camptocamp.com>
|
||||||
|
|||||||
11
report_layout_config/static/src/scss/style.scss
Normal file
11
report_layout_config/static/src/scss/style.scss
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
.footer-image {
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-image {
|
||||||
|
margin-top: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-full-image {
|
||||||
|
max-height: 60px;
|
||||||
|
}
|
||||||
14
report_layout_config/templates/assets.xml
Normal file
14
report_layout_config/templates/assets.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<template id="report_assets_common" inherit_id="web.report_assets_common">
|
||||||
|
<xpath expr="." position="inside">
|
||||||
|
<link
|
||||||
|
href="/report_layout_config/static/src/scss/style.scss"
|
||||||
|
rel="stylesheet"
|
||||||
|
type="text/scss"
|
||||||
|
/>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<template
|
<template
|
||||||
id="external_layout_images_template"
|
id="external_standard_layout_images_template"
|
||||||
primary="True"
|
primary="True"
|
||||||
inherit_id="web.external_layout_standard"
|
inherit_id="web.external_layout_standard"
|
||||||
>
|
>
|
||||||
@@ -12,13 +12,12 @@
|
|||||||
<img
|
<img
|
||||||
t-if="company.full_header_img"
|
t-if="company.full_header_img"
|
||||||
t-att-src="image_data_uri(company.full_header_img)"
|
t-att-src="image_data_uri(company.full_header_img)"
|
||||||
style="max-height: 60px;"
|
class="header-full-image"
|
||||||
alt="Logo"
|
alt="Logo"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="col-9 text-right"
|
class="col-9 text-right header-image"
|
||||||
style="margin-top:22px;"
|
|
||||||
t-field="company.report_header"
|
t-field="company.report_header"
|
||||||
name="report_header"
|
name="report_header"
|
||||||
/>
|
/>
|
||||||
@@ -31,7 +30,7 @@
|
|||||||
<img
|
<img
|
||||||
t-if="company.full_footer_img"
|
t-if="company.full_footer_img"
|
||||||
t-att-src="image_data_uri(company.full_footer_img)"
|
t-att-src="image_data_uri(company.full_footer_img)"
|
||||||
style="max-width:500px;"
|
class="footer-image"
|
||||||
alt="Footer logo"
|
alt="Footer logo"
|
||||||
/>
|
/>
|
||||||
<div t-if="report_type == 'pdf'" class="text-muted">
|
<div t-if="report_type == 'pdf'" class="text-muted">
|
||||||
@@ -41,10 +40,51 @@
|
|||||||
</div>
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template
|
||||||
|
id="external_clean_layout_images_template"
|
||||||
|
primary="True"
|
||||||
|
inherit_id="web.external_layout_clean"
|
||||||
|
>
|
||||||
|
<xpath expr="//div[contains(@t-attf-class, 'header')]" position="replace">
|
||||||
|
<div class="header">
|
||||||
|
<div class="row">
|
||||||
|
<img
|
||||||
|
t-if="company.full_header_img"
|
||||||
|
t-att-src="image_data_uri(company.full_header_img)"
|
||||||
|
class="header-full-image"
|
||||||
|
alt="Logo"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="col-9 text-right header-image"
|
||||||
|
t-field="company.report_header"
|
||||||
|
name="report_header"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//div[contains(@t-attf-class, 'footer')]" position="replace">
|
||||||
|
<div class="footer o_standard_footer">
|
||||||
|
<div class="text-center">
|
||||||
|
<img
|
||||||
|
t-if="company.full_footer_img"
|
||||||
|
t-att-src="image_data_uri(company.full_footer_img)"
|
||||||
|
class="footer-image"
|
||||||
|
alt="Footer logo"
|
||||||
|
/>
|
||||||
|
<div t-if="report_type == 'pdf'" class="text-muted">
|
||||||
|
Page: <span class="page" /> / <span class="topage" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template id="styles_company_report" inherit_id="web.styles_company_report">
|
<template id="styles_company_report" inherit_id="web.styles_company_report">
|
||||||
<xpath expr="//t[contains(@t-if, 'layout')]" position="after">
|
<xpath expr="//t[contains(@t-elif, 'layout')]" position="after">
|
||||||
|
<!-- next part is the same as in web/views/report_templates web.external_layout_standard -->
|
||||||
<t
|
<t
|
||||||
t-elif="layout == 'report_layout_config.external_layout_images_template'"
|
t-elif="layout == 'report_layout_config.external_standard_layout_images_template'"
|
||||||
>
|
>
|
||||||
&.o_report_layout_standard {
|
&.o_report_layout_standard {
|
||||||
h2 {
|
h2 {
|
||||||
@@ -63,27 +103,50 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</t>
|
</t>
|
||||||
|
<!-- next part is the same as in web/views/report_templates web.external_layout_clean -->
|
||||||
|
<t
|
||||||
|
t-elif="layout == 'report_layout_config.external_clean_layout_images_template'"
|
||||||
|
>
|
||||||
|
&.o_clean_footer {
|
||||||
|
border-top: 3px solid <t t-esc='secondary' />;
|
||||||
|
h4 {
|
||||||
|
color: <t t-esc='secondary' />;
|
||||||
|
}
|
||||||
|
.pagenumber {
|
||||||
|
border: 3px solid <t t-esc='primary' />;
|
||||||
|
background-color: <t t-esc='secondary' />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.o_report_layout_clean {
|
||||||
|
h1, h2, h3 {
|
||||||
|
color: <t t-esc='primary' />;
|
||||||
|
}
|
||||||
|
strong {
|
||||||
|
color: <t t-esc='secondary' />;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
thead {
|
||||||
|
color: <t t-esc='secondary' />;
|
||||||
|
tr th {
|
||||||
|
border-top: 3px solid <t
|
||||||
|
t-esc='secondary'
|
||||||
|
/> !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tbody {
|
||||||
|
tr:last-child td {
|
||||||
|
border-bottom: 3px solid <t t-esc='secondary' />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#total {
|
||||||
|
strong {
|
||||||
|
color: <t t-esc='secondary' />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</t>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
<template id="header_image">
|
|
||||||
<div>
|
|
||||||
<img
|
|
||||||
t-if="company and company.full_header_img"
|
|
||||||
t-att-src="image_data_uri(company.full_header_img)"
|
|
||||||
style="max-height: 60px;"
|
|
||||||
alt="Logo"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template id="footer_image">
|
|
||||||
<div>
|
|
||||||
<img
|
|
||||||
t-if="company and company.full_footer_img"
|
|
||||||
t-att-src="image_data_uri(company.full_footer_img)"
|
|
||||||
style="max-width:420px;"
|
|
||||||
alt="Footer logo"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -5,40 +5,9 @@
|
|||||||
<field name="model">base.document.layout</field>
|
<field name="model">base.document.layout</field>
|
||||||
<field name="inherit_id" ref="web.view_base_document_layout" />
|
<field name="inherit_id" ref="web.view_base_document_layout" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='logo']" position="attributes">
|
|
||||||
<attribute
|
|
||||||
name='attrs'
|
|
||||||
>{'invisible': [('need_images_layout', '=', True)]}</attribute>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//field[@name='report_footer']" position="attributes">
|
|
||||||
<attribute
|
|
||||||
name='attrs'
|
|
||||||
>{'invisible': [('need_images_layout', '=', True)]}</attribute>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//field[@name='report_header']" position="attributes">
|
|
||||||
<attribute
|
|
||||||
name='attrs'
|
|
||||||
>{'invisible': [('need_images_layout', '=', True)]}</attribute>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//field[@name='report_header']" position="attributes">
|
|
||||||
<attribute
|
|
||||||
name='attrs'
|
|
||||||
>{'invisible': [('need_images_layout', '=', True)]}</attribute>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//field[@name='logo']" position="after">
|
<xpath expr="//field[@name='logo']" position="after">
|
||||||
<field name="need_images_layout" invisible="True" />
|
<field name="full_header_img" widget="image" class="mb-4" />
|
||||||
<field
|
<field name="full_footer_img" widget="image" class="mb-4" />
|
||||||
name="full_header_img"
|
|
||||||
widget="image"
|
|
||||||
class="mb-4"
|
|
||||||
attrs="{'invisible': [('need_images_layout', '=', False)]}"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="full_footer_img"
|
|
||||||
widget="image"
|
|
||||||
class="mb-4"
|
|
||||||
attrs="{'invisible': [('need_images_layout', '=', False)]}"
|
|
||||||
/>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
<field name="preview" position="attributes">
|
<field name="preview" position="attributes">
|
||||||
<attribute name='style'>max-width: 450px;</attribute>
|
<attribute name='style'>max-width: 450px;</attribute>
|
||||||
|
|||||||
Reference in New Issue
Block a user