- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从 Odoo Qweb 报告开始。我按照本教程创建了我的第一个自定义报告 http://blog.emiprotechnologies.com/create-qweb-report-odoo/
解析器类
import time
from openerp.osv import osv
from openerp.report import report_sxw
class sale_quotation_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(sale_quotation_report, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'get_total': self.get_total,
})
def get_total(self, lines, field):
total = 0.0
for line in lines:
total += line.product_uom_qty or 0.0
return total
class report_saleorderqweb(osv.AbstractModel):
_name = 'sale_report.sale_custom_report_qweb'
_inherit = 'report.abstract_report'
_template = 'sale_report.sale_custom_report_qweb'
_wrapped_report_class = sale_quotation_report
报 TableView
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="sale_custom_report_qweb">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="page">
<div class="oe_structure"/>
<div class="row">
<table style="font-name: 'Helvetica';width:100%;">
<tr colspan="4" style="font-size: 24px;font-weight: bold;">
<td align="center">
<strong> <p t-field="o.partner_id.name"/> </strong>
</td>
</tr>
<tr colspan="4" style="font-size: 12px;">
<td align="center">
QUOTE NO :
<strong>
<span t-field="o.name"/>
</strong>
QUOTE DATE :
<strong>
<span t-field="o.date_order"/>
</strong>
SALES PERSON :
<span t-field="o.user_id.partner_id.name"/>
</td>
</tr>
</table>
</div>
<br/>
<table class="table-condensed" style="font-size: 12px;">
<thead>
<tr style="border-bottom: 1px solid black;">
<th>
<strong>Name</strong>
</th>
<th>
<strong>Qty</strong>
</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.order_line" t-as="line" style="border-bottom: 1px solid black;">
<td>
<span t-field="line.product_id.name"/>
</td>
<td>
<span t-field="line.product_uom_qty"/>
</td>
</tr>
<tr>
<td/>
<td>
<!-- Print total of product uom qty -->
<strong>
<span t-esc="get_total(o.order_line)"/>
</strong>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</template>
</data>
</openerp>
当我打印报告时,它抛出这个错误:
File "/home/user/workspace/lcdv/trunk/server/openerp/tools/safe_eval.py", line 313, in safe_eval
return eval(c, globals_dict, locals_dict)
File "", line 1, in <module>
QWebException: "'NoneType' object is not callable" while evaluating
'get_total(o.order_line)'
最佳答案
我认为您必须将“get_total”方法放入“report_saleorderqweb”类而不是“sale_quotation_report”。
关于python - 无法访问 Odoo 8 Qweb 报告模板中的自定义方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28048817/
我想要输出 20 td 的 css 样式取决于 qweb var。是否有任何替代方法可以像这样复制整个代码: ... ... ... ... ... ... ... 因为此
我想在 qweb 模板中访问两个值 start_date 和 end_date。我如何才能在 qweb. 中使用这些值? 我正在生成然后将其发送到电子邮件。这是我创建报告的方式。 job_id = s
t字段选项不起作用。 我试过了 最佳答案 而不是使用 用 希望能有所帮助! 关于qweb - 如何在Odoo 10 QWeb报表中设置日期格式?,我们在Stack Overflow上找到一个类似
我想在 qweb 报告中添加分隔符“,”,以获得以下结果:session1,session2,session3 而不是:session1session2session3 这是我的代码:
我正在 Odoo 中开发一个模块。我需要更改发票报告以添加一些详细信息。 我使用带有位置属性的 xpath 并检查是否链接了事务以隐藏默认表。 hidden 这
我在 Qweb 报告中显示了一个浮点变量: 我想用产品价格 的小数精度对其进行舍入。我将它四舍五入到 4 位数字,因为我知道Product Price 的小数精度为 4 位数字,但正确的方法是从
我正在 Odoo 中开发一个模块。我需要更改发票报告以添加一些详细信息。 我使用带有位置属性的 xpath 并检查是否链接了事务以隐藏默认表。 hidden 这
我是报告 qweb 的新手,我想练习它,然后我尝试为我的模块 gestion_des_etudiants 创建报告,我知道我的代码中缺少一些东西,我需要你的帮助: report_etudiant.xm
我的问题是关于在 Odoo v8 中自定义 Qweb 报告,如果您检查图像 (Report Description),您会看到我有动态表,所以我的主要问题是如何通过调整主容器的大小来填充可用空间?有什
如何根据源文档字段名更改打印的qweb文件名?我在模型 stock.picking 中 因此,当我单击打印 -> 交货单时,将打印 qweb,但文件名将取决于源文档字段。在这里,我展示了解释我的意思的
我创建了一个向导,在其中放置了来自另一个启用了报告打印的模型的多对一字段[名称]。这里发生的情况是,当我选择一条记录并单击打印按钮时,它仅打印空报告。因此是否可以将数据提取到此处的报告中。 def
我想将“account.invoice”模型中的源文档“来源”字段添加到 qweb 报告中,但我不知道语法我只需要语法来添加这个字段我写的所有其他代码提前致谢。 class make_fields (
如何在 Odoo Qweb 报告中设置字体?目前,当我在 ubuntu 12.04 中开发报告时,报告的 PDF 副本看起来不错。但是,如果我在 ubuntu 14.04 中尝试同样的事情,字体看起来
如何减少qweb中的字符串长度? 示例: 返回stackoverflow我想删除最后8个字符并获取stack 最佳答案 关于odoo - 减少 qweb odoo 中的字符串长度,我们在Stack
我试图实现在字符串结果中有一个新行(回车),但到目前为止,我没有得到这个工作。 这个例子只是忽略了'\n'。 最佳答案 \n 正在工作 将 CSS "white-space: pre-wrap"添加
我想使用 Odoo 10 在报告的标题中插入 Logo 。 我测试过 和 它在 Odoo 8 中没有任何问题,但在 Odoo 10 中却没有。为什么会这样,我该如何解决? 最佳答案 如果你想使用公
我正在 account.invoice 模型中创建一个报告(qweb View ),并希望对每个发票行的一些字段进行求和,如下图所示: 问题是没有按照我想要的方式对字段求和。我该怎么办? cantid
有没有办法在循环 Qweb 中打印 python 字典中的键和值?例如,如果我有一个返回字典的函数: def get_informations(self): mydico={'myfirstk
我想做一个循环来打印元素精确的次数。像这样: ... 其中 o.label_qty 是一个整数。 但我只能在 qweb 中使用 t-foreach 循环: ... 有办法吗? 如果不是,我认为
Odoo v8 使用 Qweb,我们需要在发票的最后一页打印销售条款和条件。 据我所知,我们需要测试它是报告的最后一页,并在此页上打印一些静态 HTML。 有谁知道如何测试最后一页并从中删除页眉和页脚
我是一名优秀的程序员,十分优秀!