【发布时间】:2019-07-04 08:08:37
【问题描述】:
我想将自定义 css 文件添加到 qweb 报告模板。我尝试添加如下内容,但没有成功:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<report id="my_module.report_id" model="my_module.report_model" string="Some Model Report" report_type="qweb-pdf" name="my_module.report_name" file="my_module.report_name_file" menu="False"/>
<template id="my_module_inherit_id" inherit_id="report.minimal_layout">
<xpath expr="." position="inside">
<link rel='stylesheet' href="/my_module/static/src/css/report_style.css"/>
</xpath>
</template>
<template id="my_module.report_name">
<t t-call="report.html_container">
<t t-call="report.internal_layout">
<div class="page">
<style>
.test_class{color:blue;}
</style>
<!-- <div class="header">
</div> -->
<div class="body">
<h1 class="test_class" t-esc="test_variable['subVariable']"/>
<h1 class="test_class2" t-esc="test_variable['subVariable']"/>
</div>
</div>
</t>
</t>
</template>
</data>
</odoo>
页面分类 div 中定义的样式运行良好。但我也想添加css文件。我也在下面尝试了继承 ID,但它们都不起作用:
report.minimal_layout
report.internal_layout
report.assets_common
web.assets_backend
report.style
report.external_layout
css 文件:
.test_class2{
color: red;
}
css文件路径:
/my_module/static/src/css/report_style.css
【问题讨论】:
-
<h1 style="color: red;" t-esc="test_variable['subVariable']"/>怎么样。它在ir.ui.view中用于表单视图 -
是的,在 qweb 中使用样式是可行的,但我的 css 文件只是一个示例,我想在 qweb 报告中添加 css 文件。
-
您在
__manifest__.py中添加了'css': ['static/src/css/report_style.css',],吗? -
是的,我添加它并再次尝试但仍然相同(我在清单文件中定义 report_template.xml 之前定义了 css 行)