Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Why can I update localcontext in a report parser if it is not even define?

By
Pascal Tremblay
on 2/16/16, 10:58 AM 397 views

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

1

Axel Mendoza

--Axel Mendoza--
10298
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 2/16/16, 11:36 AM

@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


That's great. Big thanks mister.

Pascal Tremblay
on 2/16/16, 2:26 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 2/16/16, 10:58 AM
Seen: 397 times
Last updated: 2/16/16, 2:26 PM