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

How to modify a simple report?

By
Juan Formoso
on 1/27/15, 9:57 AM 708 views

I've modified a RML report (account_print_invoice.rml) and it's working great. However, I can print it from the interface because I overwrote the old RML file with my new one.

I'd like to do it rightly, and create a module which includes the new report. I've called the module customized_reports_01. Here is its content:

i18n
report
|__ __init__.py
|__ account_print_invoice.py
|__ account_print_invoice.rml
__init__.py
__openerp__.py
account_report.xml

I've copied the files account_print_invoice.py and and account_report.xml from the original (then in my account_report.xml I've removed all the report records different from the target report), and I've only modified the bold lines:

account_report.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <report
            auto="False"
            id="account_invoices"
            model="account.invoice"
            name="account.invoice"
            rml="customized_reports_01/report/account_print_invoice.rml"
            string="Invoices"
            attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
            attachment_use="True"
            usage="default"
            />
    </data>
</openerp>

account_print_invoice.py

import time
from openerp.report import report_sxw

class account_invoice(report_sxw.rml_parse):

    def __init__(self, cr, uid, name, context):
        super(account_invoice, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
        })

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

But when I install my module, I get the next error:

AssertionError: The report "report.account.invoice" already exists!

I've changed the name and tried other ways but I cannot achieve to print my report. I' like to know which is the right way to manage this.

Can anyone help me, please?

0
Juan Formoso
On 1/29/15, 5:01 AM

Finally, I was given the solution: I must change the name of the report in both files (it must be different from the original) and in the ID, before the dot, I must specify the module where the original report is!!

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

2 follower(s)

Stats

Asked: 1/27/15, 9:57 AM
Seen: 708 times
Last updated: 3/16/15, 8:10 AM