Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4885 Vizualizări

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?

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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!!

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
sept. 15
3264
4
aug. 15
3578
0
aug. 15
2752
3
iul. 24
8298
0
apr. 18
2696