browse() method in odoo 8

坚强是说给别人听的谎言 提交于 2019-12-24 16:46:29

问题


In OperERP 7,

There is a statement as

 context = dict(context or {})

 data = self.read(cr, uid, ids, [], context=context)[0]

In Odoo 8, I want to write this statement in new style. I tried the below, but it wont work.

 context = dict(self._context or {})

 data = self.browse([], context)[0]

Here how do I pass the context value ?


回答1:


you can use with_context to change current environment's context. i.e.

ctx = dict(self._context or {})
rec = self.with_context(ctx).browse()


来源:https://stackoverflow.com/questions/31602802/browse-method-in-odoo-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!