单击“打印调查”按钮(“人力资源”-“审批”-“面试请求”)时,标准输出为HTML (action_print_survey方法)。我想要将输出更改为PDF。我在Odoo上找不到Qweb报告的标准结构,也找不到他们作为标准支架的方式(模板是,菜单是,python包装器是)。我试着纠正一个包装器,但它不工作。有什么想法吗?预先感谢Gustavo
发布于 2015-12-21 20:35:12
报告
每个报告都必须由报告操作声明。
为了简单起见,可以使用快捷的<report>元素来定义报告,而不必手动设置操作及其周围环境。该<report>可以采用以下属性:
id:
生成的记录的外部id
名称(必需)
在某种类型的列表中查找时,仅用作报告的助记/描述
型号(必需)
您的报告将涉及的模型
report_type (必需):
PDF报告的
的qweb-html
report_name:
报告的名称(这将是PDF输出的名称)
组
允许查看/使用当前报告的组的Many2many字段
attachment_use
如果设置为True,则使用由附件表达式生成的名称将报告存储为记录的附件;如果只需要生成一次报告(例如,出于法律原因),则可以使用此选项
附件
定义报表名称的python表达式;记录可作为变量对象访问
示例:
<report
id="account_invoices"
model="account.invoice"
string="Invoices"
report_type="qweb-pdf"
name="account.report_invoice"
file="account.report_invoice"
attachment_use="True"
attachment="(object.state in ('open','paid')) and
('INV'+(object.number or '').replace('/','')+'.pdf')"
/>参考链接:https://www.odoo.com/documentation/8.0/reference/reports.html
发布于 2016-01-21 14:36:41
@Gustavo不是html报告,它是一个呈现的模板,用于响应使用该按钮操作打印调查的请求。这就是为什么您找不到报告的任何声明,但是您可以很容易地通过更改模型survey.survey的方法定义来实现,如下所示:
def action_print_survey(self, cr, uid, ids, context=None):
context = dict(context or {}, active_ids=ids, active_model=self._name)
return {
'type': 'ir.actions.report.xml',
'report_name': 'module.survey_print',
'context': context,
}此外,您还需要定义报告module.survey_print以使用原始模板。为此,您可以在https://www.odoo.com/fr_FR/forum/help-1/question/how-to-define-a-custom-methods-functions-to-be-used-in-a-qweb-report-how-to-define-and-use-a-report-parser-92244上查看如何执行此操作:
https://stackoverflow.com/questions/34358436
复制相似问题