Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Replace invoice template with my own rml file [Closed]

By
Aitzol
on 4/19/13, 8:33 AM 8,421 views

The Question has been closed

by
Sudhir Arya (SA)
on 04/22/2013 06:09:52

Hi,

I have to add new fields in the invoice "account_print_invoice.rml" template.

I guess the easiest way to do it would be to replace "account_report.xml" in "account" module, modifying the invoice report entry:

Original account/account_report.xml:

<report
            auto="False"
            id="account_invoices"
            model="account.invoice"
            name="account.invoice"
            rml="account/report/account_print_invoice.rml"
            string="Invoices"
            attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
            usage="default"
            multi="True"/>

Modified account/account_report.xml (Note RML path has been changed to a location in my module):

<report
            auto="False"
            id="account_invoices"
            model="account.invoice"
            name="account.invoice"
            rml="mymodule/report/account_print_invoice.rml"
            string="Invoices"
            attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
            usage="default"
            multi="True"/>

However I'd prefer not to change any of the files in the account module, keeping account_report.xml unmodified. Is there any way of modifying the "acount.invoice" report configuration by creating a new <report> entry in my module which replaces the rml loaded when generating a new invoice pdf?

Proposed new report entry in my own module: mymodule/account_report.xml

<report
                auto="False"
                id="account_invoices"
                model="account.invoice"
                name="account.invoice"
                rml="mymodule/report/account_print_invoice.rml"
                string="Invoices"
                attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
                usage="default"
                multi="True"/>

Is this approach possible?

Thanks,

7

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 4/21/13, 10:56 AM

First you need to overwrite the report ID in your xml like this: id="account.account_invoices" and then change name.

<report
    auto="False"
    id="account.account_invoices"
    model="account.invoice"
    name="new.account.invoice"
    rml="mymodule/report/account_print_invoice.rml"
    string="Invoices"
    attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
    usage="default"
    multi="True"/>

Now copy & paste account_print_invoice.py from account/report to your_module and then modify it as follow:

report_sxw.report_sxw(
    'report.new.account.invoice',
    'account.invoice',
    'addons/mymodule/report/account_print_invoice.rml',
    parser=account_invoice
)

Import this file in __init__.py and then restart your server and update your module.

2
Andrea Cometa
On 4/19/13, 9:13 AM

yes your approach is possible.

create your own addon and override the rml bye

1

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 4/19/13, 9:04 AM

If you go to Settings -> Actions -> Reports, you can search for the report you want to replace.

Click on the line of the order

Click on the button 'Edit'

Now you can change the path to the .RML file. It is behind the text 'Report File'

This one is for temporary. What if I update the modules? Edited path will be replaced if I update the modules.

Sasuke
on 4/21/13, 10:47 AM
0
Aitzol
On 4/22/13, 6:02 AM

Thank you all for your help. The post by Sudhir Arya was exactly the answner to what I was looking for.

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/19/13, 8:33 AM
Seen: 8421 times
Last updated: 3/16/15, 8:10 AM