Search code examples
python-2.7odooodoo-8

Method read declaration in odoo 8


In openerp ,

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

What is the equivalent statement of above in odoo 8. I am getting wrong result when I used the below statement.

data = self.with_context(context).browse(self.ids)[0]

I am new to odoo 8, Please help me on this...


Solution

  • Quite often I am lazy and just use the V7 api. It still works fine.

    @api.v8
    def function_i_want_to_edit_that_uses_v8_api(self):
        # omg where are my cr and uid objects
        # oh... i can just smuggle :-P
        data = self.browse(self._cr, self._uid, self._ids, context=self._context)
    

    But this should also work:

    @api.v8
    def function_i_want_to_edit_that_uses_v8_api(self):
        data = self.browse(self._ids)
    

    Maybe the only problem is the missing _? Also make sure that any functions in which you use this are v8-enabled, eg. decorated with @api.v8 or similar.