[IMP] yaml_import: add openerp in the evaluation context.

bzr revid: vmt@openerp.com-20130325144833-aos5t6x5bc8vi0ss
This commit is contained in:
Vo Minh Thu 2013-03-25 15:48:33 +01:00
parent 63222e389e
commit 385491f46e
1 changed files with 9 additions and 1 deletions

View File

@ -540,10 +540,18 @@ class YamlInterpreter(object):
self.noupdate = node.noupdate
def process_python(self, node):
import openerp
python, statements = node.items()[0]
model = self.get_model(python.model)
statements = statements.replace("\r\n", "\n")
code_context = { 'model': model, 'cr': self.cr, 'uid': self.uid, 'log': self._log, 'context': self.context }
code_context = {
'model': model,
'cr': self.cr,
'uid': self.uid,
'log': self._log,
'context': self.context,
'openerp': openerp,
}
code_context.update({'self': model}) # remove me when no !python block test uses 'self' anymore
try:
code_obj = compile(statements, self.filename, 'exec')