我正在尝试基于向导打印Odoo自定义报告。
它从向导视图获取输入。该向导使用户可以选择带有start_date和end_date的项目。然后点击打印按钮。因此,与向导表单字段过滤器匹配的活动列表应打印在PDF
中。但是我得到了一个PDF
的{{1}}文件,当我尝试打开时,我得到了0 KB
并且控制台中没有错误
这是一些关键文件
报告/ __ init __。py
Format error: Not a PDF or corrupted.
报告/print_work_plan_template.xml
# -*- coding: utf-8 -*-
from odoo import models, api
class ReportWorkPlan(models.AbstractModel):
_name = 'ewonga_pta.report_model_work_plan'
@api.model
def render_html(self, docids, data=None):
docs = self.env['ew.pta.line'].browse(docids)
docargs = {
"doc_ids": docs.ids,
"doc_model": "ew.pta.line",
"docs": docs,
}
return docargs
reports / work_plan_report.xml
<?xml version="1.0" ?>
<odoo>
<template id="report_work_plan_template">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="web.external_layout">
<div class="page">
<h2>Report title</h2>
</div>
</t>
</t>
</t>
</template>
</odoo>
向导/workplan.py
<?xml version="1.0" ?>
<odoo>
<report
id="action_work_plan_print_report"
string="Print Report"
model="ewonga_pta.report_model_work_plan"
report_type="qweb-pdf"
name="ewonga_pta.report_work_plan_template"
file="print_work_plan_template"
/>
</odoo>
向导/wizard_work_plan.xml
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class WorkPlanWizard(models.TransientModel):
_name = "ewonga_pta.work_plan_wizard"
# attendee_ids = fields.Many2many('res.partner', string="Attendees")
project_id = fields.Many2one("account.analytic.account", domain=[("type_interne", "=", "projet" )])
start_date = fields.Date("Date de début")
end_date = fields.Date("Date de fin")
@api.multi
def check_report(self):
data = {}
data["form"] = self.read(
[
"project_id",
"start_date",
"end_date"
]
)[0]
return self.env.ref("ewonga_pta.action_work_plan_print_report").report_action(self, data=data)
os:Window 10 x64
python:版本3.6.5
wkhtmltopdf:版本0.12.3.2(带有修补的qt)
请帮助我解决此问题。谢谢
答案 0 :(得分:0)
尝试通过“ report_action”调用删除“数据”参数。自我已包含数据。
谢谢