Community mailing list archives

community@mail.odoo.com

Custom Invoice Report Error

by
Ty Muscat
- 11/02/2015 17:52:52
Hello,

I am hoping that this is a easy one to resolve.  I am attempting to write my first custom invoice report in v9 and I get an error.


  File "", line 1, in <module>
QWebException: "'NoneType' object is not callable" while evaluating
"translate_doc(doc_id, doc_model, 'partner_id.lang', 'custom_invoice.report_custom_invoice_document')"


Module  - custom_invoice

__init__.py:

from . import report_print

__openerp__.py:

{
    'name': 'Custom Invoice Print',
    'author': 'Name',
    'website': 'http://www.companyname.com',
    'version': '1.0.1',
    'description': """
        Custom Invoice Print - Adds additional formating
    """,
    'depends' : ['account'],
    'application': True,
    'data': [
    'report.xml',
    'view/report_invoice.xml'
     ],
    'installable': True,
}

report_print.py:

from openerp.report import report_sxw
from openerp import api, models, _

class account_invoice(models.Model):
    _inherit = 'account.invoice'

    @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, 'custom_invoice.report_custom_invoice')   

report_invoice.xml:

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

    <template id="custom_invoice.report_custom_invoice_document">
        <t t-call="report.external_layout">
            <div class="page">
            <div class="row">
                <h3>Title</h3>
            </div>
        </div>
        </t>
    </template>

    <template id="report_custom_invoice">
        <t t-call="report.html_container">
            <t t-foreach="doc_ids" t-as="doc_id">
                <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'custom_invoice.report_custom_invoice_document')"/>
            </t>
        </t>
    </template>

</data>
</openerp>

report.xml:

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

        <report
            id="report_custom_invoice_print"
            model="account.invoice"
            string="Custom Invoice Print"
            report_type="qweb-pdf"
            name="custom_invoice.report_custom_invoice"
            file="custom_invoice.report_custom_invoice"
            attachment_use="True"
            attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
        />

    </data>
</openerp>


Any suggested changes for the above code?

Thanks in advance for the help.

Regards,

Ty Muscat