Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4905 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 15
3279
4
thg 8 15
3583
0
thg 8 15
2759
3
thg 7 24
8332
0
thg 4 18
2710