报告不从向导打印 - Odoo v8

时间:2018-04-19 22:53:07

标签: python odoo

我有这段代码:

class mrp_worksheet_contract(models.Model):
    _inherit = 'mrp.worksheet.contract'
    _name = 'mrp.worksheet.contract'

    start_date = fields.Date('From')
    end_date = fields.Date('To')

    @api.multi
    def generate_report(self):
        data = {'start_date': self.start_date, 'date_stop': self.end_date,}
        report_name = 'bsi.report_contract_worksheet'
        return self.env['report'].get_pdf(self, report_name, data=data)

我的模块名为bsireport_contract_worksheet就是这个:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<template id="report_contract_worksheet">
<t t-call="report.html_container">
    <t t-set="data_report_margin_top" t-value="12"/>
    <t t-set="data_report_header_spacing" t-value="9"/>
    <t t-set="data_report_dpi" t-value="110"/>

    <t t-foreach="docs" t-as="o">
        <t t-call="report.internal_layout">
            <div class="page">
                <h2><span t-esc="res_company.name"/>: COntract Worksheet</h2>

                <div class="row mt32">
                    <div class="col-xs-3">
                        <strong>Order No.:</strong>
                        <field name="name"/>
                    </div>
                    <div class="col-xs-3">
                        <strong>Date:</strong>
                        <field name="date"/>
                    </div>
                    <div class="col-xs-3">
                        <strong>Language:</strong>
                          <field name="book_block"/>
                    </div>
                    <div class="col-xs-3">
                        <strong>Title/Description:</strong>
                          <field name="isbns"/>
                    </div>
                    <div class="col-xs-3">
                        <strong>I.S.B.N.:</strong>
                          <field name="isbns"/>
                    </div>
                    <div class="col-xs-3">
                        <strong>Specification/Description:</strong>
                        <p>
                        </p>
                    </div>
                </div>
            </div>
        </t>
    </t>
</t>
</template>
</data>
</openerp>

在我看来,我这样调用generate_report函数:

   <record id="report_contract_worksheet_view" model="ir.ui.view">
        <field name="name">Contract Worksheet Report</field>
        <field name="model">mrp.worksheet.contract</field>

        <field name="arch" type="xml">
            <form string="Report Options">
                <separator string="Contract Worksheet "/>
                <label string="Lorem Ipsum "/>
                <group col="4">
                    <field name="name"/>
                    <newline/>
                    <field name="start_date"/>
                    <field name="end_date"/>
                </group>
                <footer>
                    <button name="generate_report" string="Print" type="object" default_focus="1" class="oe_highlight"/>
                    or
                    <button string="Cancel" class="oe_link" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>

     <record id="action_report_contract_worksheet_view" model="ir.actions.act_window">
         <field name="name">Contract Worksheet Report</field>
         <field name="res_model">mrp.worksheet.contract</field>
         <field name="type">ir.actions.act_window</field>
         <field name="view_type">form</field>
         <field name="view_mode">tree,form</field>
         <field name="view_id" ref="report_contract_worksheet_view"/>
         <field name="context">{}</field>
         <field name="target">new</field>
   </record>

    <menuitem icon="STOCK_PRINT"
        name="Contract Worksheet"
        action="action_report_contract_worksheet_view"
        id="menu_general_prod_child_1" 
        parent="menu_general_prod_1"
        />

它不会打印任何内容,而且每次点击mrp.contract.worksheet按钮时都会创建一个新的generate_report

有什么想法吗?

0 个答案:

没有答案