Hi there.
I'm trying to make a custom model extending account.invoice, which will add a button on sales invoice form, to print my new custom report. So far, the button, does trigger my function in custom model (I've put there a warning to test), so now the only thing left seems to run my new custom report somehow. The content of imortant file is:
models.py:
# -*- coding: utf-8 -*-
from openerp import models, fields, api, _
from openerp.exceptions import Warning
class Inv(models.Model):
_inherit = 'account.invoice'
_name = 'account.invoice'
#_name = 'my.inv'
#_name = 'account.invoice'
name = fields.Char(string="Title", required=False)
description = fields.Text()
#comment = fields.Text()
@api.multi
def print_invoice_my(self):
#raise Warning( _("do something here") )
#assert len(self) == 1
#self.sent = True
#return self.env['report'].get_action(self, 'account.invoice.report_invoice_my')
return self.env['report'].get_action(self, 'my.report_invoice_my')
#report_obj = self.env['report']
#report = report_obj._get_report_from_name('my.report_invoice_my')
my.xml:
<openerp>
<data>
<record id="invoice_form_my" model="ir.ui.view">
<field name="name">account.invoice.form.my</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<button name="invoice_print" position="after">
<button type="object" name="print_invoice_my" string="my Invoice"/>
<!--<button name="%(report_invoice_my)d" string="my Invoice" type="action"/>-->
</button>
</field>
</record>
</data>
</openerp>
my_report.xml:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="id_report_invoice_my"
#model="account.invoice"
model="my"
string="my Invoice"
report_type="qweb-pdf"
name="my.report_invoice_my"
attachment_use="False"
file="my.report_invoice_my"
/>
</data>
</openerp>
report_invoice_my.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_invoice_my">
<t t-call="report.external_layout">
<div class="page">
<div class="row">
<h3>Title</h3>
</div>
</div>
</t>
</template>
</data>
</openerp>
I've tried to folow this tutorial
http://www.odoo.yenthevg.com/creating-custom-reports-odoo-8/
However, when trying to hit my button, I get error: "Bad Report Reference" This report is not loaded into the database: my.report_invoice_my.
Posts related to this one are:
https://www.odoo.com/forum/help-1/question/how-to-add-new-button-in-sales-invoice-form-95995
https://www.odoo.com/forum/help-1/question/how-to-connect-button-with-function-96285
https://www.odoo.com/forum/help-1/question/cant-inherit-account-invoice-96458
Can you please suggest how can I fix this, much thanks in advance, best regards.