Odoo Help

0

How to override method of function field?

By
Rakesh Yadav
on 6/28/17, 2:26 AM 589 views

I was getting traceback error while filling timesheet. After R&D I came to know that it was the issue of Odoo’s code it self. I compared code with the latest one and found the issue.

The Problem:

The method is called from function field. I have overridden it successfully but the problem is, after overriding it, it is calling first the original method of Odoo and after that, it is calling my overridden method. That’s why I am facing the same traceback error.

Here is default code:

def _get_task(self, cr, uid, id, context=None):

  res = []

  for line in self.pool.get('account.analytic.line').search_read(cr,uid,[('task_id', '!=', False),('id','in',id)], context=context):

      res.append(line['task_id'][0])

  return res


Here is my overridden code after bug fixed by Odoo:

def _get_task(self, cr, uid, id, context=None):

  res = []

     for line in self.pool.get('account.analytic.line').search_read(cr, uid,[('task_id', '!=', False), ('id', 'in', id)], ['task_id'], context=context):

      res.append(line['task_id'][0])

  return res

The only difference between these two is the [‘task_id’] which is added in the search_read method. Can anybody help me out regarding it?

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 6/28/17, 2:26 AM
Seen: 589 times
Last updated: 6/28/17, 2:35 AM