qweb的格式化options - xiaohao0576/odoo-doc GitHub Wiki
保留两位小数
<span t-out="doc.amount_total" t-options="{'widget': 'float', 'precision': 2}"/>
<t t-out="doc.date_order" t-options='{"widget": "date", "format": "YYYY-MM-dd"}'/>
<span>
<t t-set="now" t-value="datetime.datetime.now()"/>
<t t-esc="context_timestamp(now).strftime('%Y-%m-%d %H:%M:%S')"/>
</span>
# 使用生成器表达式将每个整数转换为字符串,然后用逗号连接
ids = ",".join(map(str, records.ids))
# 定义 URL
url = 'https://your-domain.odoo.com/report/html/report.name/' + ids
# 创建 URL 动作
action = {
'type': 'ir.actions.act_url',
'url': url,
'target': 'new' # 在新的标签页中打开
}
<table>
<t t-set="index" t-value="0"/>
<t t-foreach="doc.order_line" t-as="line">
<t t-set="index" t-value="index + 1"/>
<tr>
<td style="width: 32px; color:white;">
<span style="white-space: pre;"> <t t-out="index"/></span>
</td>
<td style="width: 310px;">
<span style="white-space: pre-line;"> <t t-out="line.name"/></span>
</td>
<td style="width: 56px;">
<span style="white-space: pre;"> <t t-out="line.product_uom_qty" t-options="{'widget': 'float', 'precision': 2}"/></span>
</td>
<td style="width: 65px;">
<span style="white-space: pre;"> <t t-out="line.product_uom.name"/></span>
</td>
<td style="width: 80px;">
<span style="white-space: pre;"> <t t-out="line.price_unit" t-options="{'widget': 'float', 'precision': 2}"/></span>
</td>
<td style="width: auto;">
<span style="white-space: pre;"> <t t-out="line.price_subtotal" t-options="{'widget': 'float', 'precision': 2}"/></span>
</td>
</tr>
</t>
</table>