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

I'm trying to use report parser, but it always pop an error

ValueError  The _name attribute report.test_module.report_test_doc is not valid

I searched that your report name is use for the parser _template and _name in order to be used by Odoo. It doesn't show the error if I remove the test_module in 'report.report_test_doc', but when I execute it, another error appears -  'Nonetype' object is not callable' hello()


report.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <report 
            id="eport_monthly_pdc"
            string="Monthly report of PDC"
            model="account.voucher"
            report_type="qweb-pdf"
            name="test_module.report_test_doc" 
            file="test_module.report_test_doc" 
        />
    </data>
</openerp>

report_parser.py

from openerp import api, models
from openerp.report import report_sxw
import time
class report_parser(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(report_parser, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({     
            'time': time,            
            'hello_world': self._hello,
        })
    def _hello(self):
        return "Hello World!"

class report_parser_test(models.AbstractModel):
    _name = 'report.test_module.report_test_doc'
    _inherit = 'report.abstract_report'
    _template = 'test_module.report_test_doc'
    _wrapped_report_class = report_parser


report_test_doc.xml


<openerp>
<data> 
<template id="report_test_doc">
    <t t-call="report.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="test_module.report_test_layout">
                <div class="page">
                    <div class="text-center">
                        <span t-esc="hello_world()"/>
                    </div>
                </div>
            </t>
        </t>
    </t>
</template>
</data>
</openerp>

What am I missing?

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

I have used the same code, but i didn't get any error as like as you mentioned. I had the error in "report_test_doc.xml" file. So i replaced the 6th line as below:

<t t-call="report.external_layout">

then is working fine for me. 

Ảnh đại diện
Huỷ bỏ
Tác giả

That was my custom layout. Anyway, it was already solved, the name of the module is the problems. Hehe Thanks anyway :)

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 1 25
44371
0
thg 10 24
1384
0
thg 10 24
5
1
thg 5 23
2916
5
thg 5 21
11434