Skip to Content
Menu
This question has been flagged

in v8 which is the best way to reference to another model from within a parser?

Eg. I need to reference ir.config_parameter, but using self.env['ir.config_parameter'] I get error from Aeroo "env is not defined"

Avatar
Discard
Best Answer

In your case you can still use self.pool.get

Avatar
Discard
Author

To access self.pool.get I need to import pooler, and in the log it is reported as deprecated.

no need to import pooler, you just import pooler when you have no other way to access to your db models pool and you need to do it manually. This is not the case

I write a more extensive explanation of report parsers at: https://www.odoo.com/es_ES/forum/help-1/question/how-to-define-a-custom-methods-functions-to-be-used-in-a-qweb-report-how-to-define-and-use-a-report-parser-92244

Best Answer

Hi Raffaele,

You can only use self.env inside the class if your class inherits models.model not osv.Model or other objects.

for eg:

from openerp import models 
class class_name(models.Model):
#inside this class self.env can be use.

Updated (5,sept):

rml_parse is class which is defined inside /odoo/openerp/report/report_sxw.py file which is not inherits models.Model it simply inherits Object. So you cannot use self.env inside the parser class.

Hope this will help.

Rgds,

Anil.

Avatar
Discard
Author

Aeroo parser inherits report_sxw.rml_parse. https://github.com/gisce/aeroo/blob/master/report_aeroo_sample/report/parser.py

rml_parse is class which is defined inside /odoo/openerp/report/report_sxw.py file which is not inherits models.Model it simply inherits Object. So you cannot use self.env inside the parser class.

Author

not enough karma to convert this as an answer.

Is that your ans? so i will update the in my same ans.

Related Posts Replies Views Activity
0
Jul 22
673
2
Oct 19
6598
1
Dec 15
2592
0
May 15
2855
1
Mar 15
3536