我一直在争论一段时间......请帮助我。以下是问题:
我在表单的标题上创建了一个按钮,此按钮的概念是在单击时显示图像文件的报告。但是无论何时我点击这个按钮,都没有任何反应。当我从开发人员模式编辑表单视图时,我意识到按钮正在选择一个不同的名称。即
<header>
<button name="reports/bh_customcustom.report_formdownload_view" type="report" string="Form Download" class="oe_highlight"/>
</header>
而不是代码中的这个:
<header>
<button name="action_formdownloader" type="object"
string="Form Downloader" class="oe_highlight"/>
</header>
以下是我的代码段:
表单视图:
<record model="ir.ui.view" id="form_download_form_view">
<field name="name">form_download.form</field>
<field name="model">formdownload</field>
<field name="arch" type="xml">
<form string="Form Download Form">
<header>
<button name="action_formdownloader" type="object"
string="Form Downloader" class="oe_highlight"/>
</header>
<sheet>
<group string="Company Name">
<!--<field name="company_name_id"/>-->
<field name="name"/>
<!--<field name="form_serial_no" />-->
</group>
</sheet>
</form>
</field>
</record>
模特:
class FormDownload(models.Model):
_name = 'formdownload'
_rec_name = 'form_serial_no'
# @api.multi
def action_formdownloader(self):
return self.env['report'].get('bh_customcustom.report_formdownload_view')
name = fields.Many2one('companyname', string="Company Name", ondelete='cascade',
required=True)
form_serial_no = fields.Char(string="Form Serial No", readonly=True)
status = fields.Boolean(string="Status", default=False)
与相关的 openerp .py文件的一部分
'depends': ['base', 'construction_plot_4devnet', 'bh_custom', 'report'],
# always loaded
'data': [
# 'security/ir.model.access.csv',
'views/bh_customcustom.xml',
'sequences.xml',
'report/form_download_report.xml',
'security/security_groups.xml',
'templates.xml',
],
'images': [
'img/firstpage.png',
],
报告文件:
<openerp>
<data>
<report
id="report_form_download"
model="formdownload"
string="Form Download Report"
name="bh_customcustom.report_formdownload_view"
file="bh_customcustom.report_formdownload_view"
report_type="qweb-pdf"/>
<record id="paperformat_formdownloadcheck" model="report.paperformat">
<field name="name">Form Download Check</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">80</field>
<field name="page_width">175</field>
<field name="orientation">Portrait</field>
<field name="margin_top">3</field>
<field name="margin_bottom">3</field>
<field name="margin_left">3</field>
<field name="margin_right">3</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">3</field>
<field name="dpi">80</field>
</record>
<template id="report_formdownload_view">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="report.external_layout">
<div class="page">
<!--<img class="img img-responsive" src="/bh_customcustom/static/src/img/firstpage.png"-->
<!--style="max-height: 45px"/>-->
<img src="/static/src/img/firstpage.png"
style="max-height: 45px"/>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>
答案 0 :(得分:0)
问题来自我在视图xml文件上的路径我现在编辑了表单视图,并且它选择了它在我查看路径后选择的确切方法。另外,提取报告的方法应该是这样的:
@api.multi
def action_formdownloader(self):
return self.env['report'].get_action(self, 'bh_customcustom.report_formdownload_view')