按下代码中的“打印”按钮时如何打印自定义费用报表

时间:2018-08-15 16:38:45

标签: python-2.7 odoo-9

我使用odoo 9,并且想要自定义费用报告。我使用“ bi_professional_reports_templates”模块来了解如何修改模板,因此在“ res_company.xml”中添加了“ expense_template”字段,然后创建了费用报告。然后,当我单击“打印”时,我尝试调用我的报告。问题是默认报告始终显示,而不是我的新报告。有什么想法可以帮忙吗?

res_company.xml

        <openerp>
     <data>

    <record id="res_company_custom_inherit_form_view" model="ir.ui.view">
        <field name="name">res_company_inherit.inherit_form_view</field>
        <field name="model">res.company</field>
        <field name="inherit_id" ref="base.view_company_form"/>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <field name="parent_id" position="after">
                <group colspan="2" col="2">
                    <field name="sale_template"/>
                    <field name="purchase_template"/>
                    <field name="account_template"/>
                    <field name="stock_template"/>
                    <field name="expense_template"/>
                </group>
            </field>
        </field>
    </record>
 </data>
</openerp>

res_company.py

 from openerp import models, fields, api, _

class res_company(models.Model):
_inherit = "res.company"
 sale_template = fields.Selection([
        ('fency', 'Fency'),
        ('classic', 'Classic'),
        ('modern', 'Modern'),
        ('odoo_standard', 'Odoo Standard'),
    ], 'Sale')
purchase_template = fields.Selection([
        ('fency', 'Fency'),
        ('classic', 'Classic'),
        ('modern', 'Modern'),
        ('odoo_standard', 'Odoo Standard'),
    ], 'Purchase')
stock_template = fields.Selection([
        ('fency', 'Fency'),
        ('classic', 'Classic'),
        ('modern', 'Modern'),
        ('odoo_standard', 'Odoo Standard'),
    ], 'Stock')
account_template = fields.Selection([
        ('fency', 'Fency'),
        ('classic', 'Classic'),
        ('modern', 'Modern'),
        ('odoo_standard', 'Odoo Standard'),
    ], 'Account')
expense_template = fields.Selection([
    ('odoo_standard', 'Odoo Standard'),
], 'Expense')


 ghclass account_invoice(models.Model):
_inherit = "account.invoice"

paypal_chk = fields.Boolean("Paypal")
paypal_id = fields.Char("Paypal Id")

@api.multi
def invoice_print(self):
    """ Print the invoice and mark it as sent, so that we can see more
        easily the next step of the workflow
    """
    self.ensure_one()
    self.sent = True
    return self.env['report'].get_action(self, 'bi_professional_reports_templates.report_invoice')


   class res_company(models.Model):
_inherit = "res.company"

bank_account_id = fields.Many2one('res.partner.bank', 'Bank Account')

class sale_order(models.Model):
_inherit = 'sale.order'

@api.multi
def print_quotation(self):
    self.filtered(lambda s: s.state == 'draft').write({'state': 'sent'})
    if self.company_id.sale_template:
        return self.env['report'].get_action(self, 'bi_professional_reports_templates.report_saleorder')
    else:
    return self.env['report'].get_action(self, 'sale.report_saleorder')

class PurchaseOrder(models.Model):
_inherit = "purchase.order"

@api.multi
def print_quotation(self):
    self.write({'state': "sent"})
    if self.company_id.purchase_template:
        return self.env['report'].get_action(self, 'bi_professional_reports_templates.report_purchasequotation')
    else:
        return self.env['report'].get_action(self, 'purchase.report_purchasequotation')

class HrExpense(models.Model):
_inherit = "hr.expense"
@api.multi
def print_quotation(self):

    self.write({'state': "draft"})
    if self.company_id.expense_template:
        return self.env['report'].get_action(self, 'bi_professional_reports_templates.report_expense')
    else:
        return self.env['report'].get_action(self, 'hr_expense.report_expense')

0 个答案:

没有答案