Odoo Help


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


How to use a variable in a function field?

on 4/9/15, 3:43 AM 354 views

I want to pass a variable to calculate a function field.

However, in the following code values stays empty (None) in def _get_mainproject.

How to solve this?

class xx_project_task(osv.osv):
     _inherit = "project.task"
     def _get_mainproject(self, cr, uid, ids, name, values, context):
         [some code here to get the main project, differs depending on the value of 'trigger']

     _columns = { 'xx_mainproject': fields.function(_get_mainproject, type="char", string='Main project',size=250,
                 'account.analytic.account': (lambda self, cr, uid, ids, name, values={'trigger':'account'}
                     , c={}: self.search(cr,uid,[(1,'=',1)]),['parent_id'], 10),
                 'project.task': (lambda self, cr, uid, ids, name, values={'trigger':'task'}
                     , c={}: ids,['project_id'], 20)

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 4/9/15, 3:43 AM
Seen: 354 times
Last updated: 4/9/15, 3:44 AM