t字段选项不起作用。
我试过了
<span t-field="o.date_invoice" t-field-options='{"format": "MM/dd/yyyy"}'/>
Run Code Online (Sandbox Code Playgroud) 有没有办法在循环Qweb中打印python字典中的键和值?例如,如果我有一个返回字典的函数:
def get_informations(self):
mydico={'myfirstkey':1,'mysecondkey':2}
return mydico
Run Code Online (Sandbox Code Playgroud)
然后,在Qweb报告中:
<t t-foreach="doc.get_informations()" t-as="l">
<tr>
<td class="text-right">
<t t-esc="l"/>
</td>
<td class="text-right">
<span t-esc="l_value"/>
</td>
</tr>
</t>
Run Code Online (Sandbox Code Playgroud)
我怎么能打印钥匙和价值?
谢谢
2015年12月12日更新:
谢谢你的回归.确切地说,当我放
<t t-foreach="{'my': 'first', 'my2': 'second' }" t-as="v">
Run Code Online (Sandbox Code Playgroud)
它有效,我有类似的东西:
my first
my2 second
Run Code Online (Sandbox Code Playgroud)
但是当我在foreach中使用一个函数时,输出完全相同,qweb无法将它分开,我有:
{'my': 'first', 'my2': 'second' }
{'my': 'first', 'my2': 'second' }
Run Code Online (Sandbox Code Playgroud)
所以我决定采取另一种方式:
在我的继承报告中:
<t t-foreach="doc.tabTaxes" t-as="v">
<tr>
<td>
<span t-esc="v.name"/>
</td>
<td>
<span t-esc="doc.get_amount(v.name)[0]"/>
</td>
</tr>
</t>
Run Code Online (Sandbox Code Playgroud)
在sale.order模型继承:
@api.one …
Run Code Online (Sandbox Code Playgroud) 我正在定义我自己的report.paperformat
。我正在尝试不同的网络配置margin_top
,但header_space
我无法理解每个参数的作用。
margin_top
当和中使用给定值时header_space
, 所使用的单位是什么wlkhtmltopdf
?15
in的值和in 中使用margin_top
的值是什么意思?5
header_line
我正在尝试创建一个QWeb报告.我有一个产品清单,我想在同一页上打印每个礼仪.这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Déclaration des rapports -->
<report
id="etiquette_produit"
model="product.template"
string="Etiquette Produit"
report_type="qweb-pdf"
file="Product_Etiquette_QWeb.produit_etiquette"
name="Product_Etiquette_QWeb.produit_etiquette"
/>
<template id="produit_etiquette">
<t t-call="report.external_layout">
<t t-foreach="docs" t-as="o">
<div class="page">
<table class="table table-striped">
<tr>
<td class="col-xs-1"><span t-field="o.default_code"/></td>
<td class="col-xs-5 text-center"><span t-field="o.name"/></td>
<td class="col-xs-1"><span t-field="o.default_code"/></td>
<td class="col-xs-5 text-center"><span t-field="o.name"/></td>
</tr>
<tr>
<td colspan="2" class="text-center">* M E 2 1 5 9 *</td>
<td colspan="2" class="text-center">* M E 2 0 1 7 *</td>
</tr>
</table>
</div>
</t>
</t>
</template>
</data>
</openerp>
Run Code Online (Sandbox Code Playgroud)
问题:当我选择要打印的所有产品时,我有一个错误(见下文).但是,当我只选择一种产品时,我可以打印报告.
Odoo Server …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在销售订单模块的树视图中添加一个按钮,旁边是创建和导入按钮。该按钮将执行一个 python 方法。
我已经创建了我的自定义模块,扩展了销售订单模块,然后,我遵循了以下步骤:
第 1 步:在 my_module/static/src/xml/qweb.xml 中创建按钮:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery="button.o_list_button_add" t-operation="after">
<t t-if="widget.model=='sale.order'">
<button class="btn btn-sm btn-primary update_sales_button" type="button">Run my stuff</button>
</t>
</t>
</t>
</templates>
Run Code Online (Sandbox Code Playgroud)
第 2 步:将文件添加到我模块的 __openerp.py__ 中的 qweb 部分:
'depends': ['sale'],
'data': [],
'qweb': ['static/src/xml/qweb.xml'],
Run Code Online (Sandbox Code Playgroud)
现在,按钮出现。
第 3 步:创建 python 方法来为 my_module/my_python_file.py 中的按钮提供功能:
from openerp import api, fields, models, _
class SaleOrderExtended(models.Model):
_inherit = ['sale.order']
@api.multi
def update_sales_button(self):
... …
Run Code Online (Sandbox Code Playgroud) 我是odoo的新手我想向我的模型报告pdf,我已经尝试了所有tuto我在net youtube中找到,google但没有人为我工作请给我一个建议.有我的模特:
# modelx.py file
from openerp import models, fields, api
class omega(models.Model):
_name = 'omega.model'
_description = 'No Description for now !!'
@api.model
def render_html(self, docids, data=None):
report_obj = self.env['report']
report = report_obj._get_report_from_name('report.external_layout')
docargs = {
'doc_ids': docids,
'doc_model': report.model,
'docs': self,
}
return report_obj.render('report.external_layout', docargs)
state = fields.Selection([
('Nouveau', 'Nouveau'),
('valid', 'Validation Responsable'),
('Termine', 'Termine'),
],default='Nouveau')
@api.one
def confirmer(self):
self.write({
'state': 'valid',
})
employe = fields.Many2one(comodel_name="res.users", string="Employe", required=True, delegate=True)
date = fields.Datetime(string="Date", required=True)
date2 = fields.Date(string="Date2", required=True)
day_number …
Run Code Online (Sandbox Code Playgroud) 我想在我的自定义Qweb报告中显示用户上传的图像.
哪种方法最好?
我正在 Odoo 中开发一个模块。我需要更改发票报告以添加一些详细信息。
我使用带有位置属性的 xpath 并检查是否链接了一个事件来隐藏默认表。
<template id="my_invoice" inherit_id="account.report_invoice_document">
<xpath expr="//div[@class='page']/table[@class='table table-condensed']" position="attributes">
<attribute t-if="o.affair_id" name="class">hidden</attribute>
</xpath>
</template>
Run Code Online (Sandbox Code Playgroud)
这是行不通的。即使发票未链接到事务,默认表也隐藏在每个发票中。
我不明白,因为条件适用于我的第二个模板。
<template id="my_invoice2" inherit_id="account.report_invoice_document">
<xpath expr="//div[@class='page']/div[@class='row mt32 mb32']" position="after">
<t t-if="o.affair_id">
<!-- table with my additional detail -->
</t>
</xpath>
</template>
Run Code Online (Sandbox Code Playgroud)
对不起我的英语不好。我正在学习它。
如何减少qweb中的字符串长度?
例:
<p t-field="doc.name" />
Run Code Online (Sandbox Code Playgroud)
return stackoverflow我想要remowe最后8个字符并获得堆栈
我有一个选择字段,例如
field = fields.Selection([('a', 'A'), ('b', 'B')],string='Test')
Run Code Online (Sandbox Code Playgroud)
当我尝试在选择字段中获取所选元素时,键“a”被打印到pdf中,我需要打印“A”
<t t-esc="med['field']"/>
#med 是连接模型 A 和 B 的 one2many 线,我正在尝试从模型 B(笔记本)获取数据,