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

Hello all,

We are in the the class Overdue in the file odoo-8.0-20151003/openerp/addons/account/report/account_print_overdue.py

At this place, the line is written :

    self.localcontext.update({......})


How could we update update this localcontext variable if it is not defined there in the class?

Is it an inherited variable? Where is this variable localcontext defined?

Thanks

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

@Pascal

Because every class that inherit from rml_parse, it's inheriting the __init__ method too, and if that class does not override the __init__ method it will be called or also like the case of Overdue class it's calling the super

super(Overdue, self).__init__(cr, uid, name, context=context)

The __init__ method of the rml_parse creates the localecontext with this code:

self.localcontext = {

'user': user,

'setCompany': self.setCompany,

'repeatIn': self.repeatIn,

'setLang': self.setLang,

'setTag': self.setTag,

'removeParentNode': self.removeParentNode,

'format': self.format,

'formatLang': self.formatLang,

'lang' : user.company_id.partner_id.lang,

'translate' : self._translate,

'setHtmlImage' : self.set_html_image,

'strip_name' : self._strip_name,

'time' : time,

'display_address': self.display_address,

# more context members are setup in setCompany() below:

# - company_id

# - logo

}

So after the super call, self.localcontext exist. The rml_parse class it's defined in your /openerp/report/report_sxw.py file


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

That's great. Big thanks mister.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 5 24
6515
1
thg 1 20
6190
2
thg 7 17
7486
1
thg 1 16
3621
0
thg 9 15
4086