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

Hello everybody,

I want to inherit from the class rml_parse for adding some keys on localcontext :

I tyed this :

class rml_parse(rml_parse):
    def setCompany(self, company_id):
        super(rml_parse,self).setCompany(company_id)
        self.localcontext['mykey'] = 'vim6574'

The syntax is good, i have imported all class needed, the problem is when I print a report, this classs is not called, is there a way to define a global context within localcontext, because I need this value on all report

Thank you so much.

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

Try this

class rml_parse(rml_parse):
    def setCompany(self, company_id):
        super(rml_parse,self).setCompany(company_id)

    def __init__(self, cr, uid, name, context):
        super(rml_parse, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({'mykey': 'vim6574',
                                  'setCompany': self.setCompany,})
Ảnh đại diện
Huỷ bỏ
Tác giả

Doesn't work, the same problem, I tried this way, the class rml_parse is defined out of addons, and when I inherit in my module and when I print, the function above is not called, this is the problem, Thank you

Did you import it correctly in your report parser? can you show your full code?

Tác giả

from openerp.report.report_sxw import rml_parse This class is called just one time when restaring OpenERp, but when I print It doesn't invoked

you should import your rml_parse class not openerp.report.report_sxw import rml_parse

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 19
6830
1
thg 5 16
3017
2
thg 8 19
3129
0
thg 9 17
3272
2
thg 3 25
4768