Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
4251 Zobrazení

Hi guys,

My question is how to dynamically change 'type_ids' value:

 def _get_type_common(self, cr, uid, context):
     ids = self.pool.get('project.task.type').search(cr, uid, [('case_default','=',1)],
     context=context)
return id

_defaults = { 'type_ids': _get_type_common }

My model is inherited from another model but have different view. I want to change this default value of 'type_ids' in my new view but not changing it in original view. I want to add something like this:

     ids = self.pool.get('project.task.type').search(cr, uid, [('case_default','=',1),('task_type_is_project','=',False)], context=context)

It is possible?

Avatar
Zrušit
Nejlepší odpověď

You redefine method _get_type_common and select correct ids with "if" based on context value.

Avatar
Zrušit
Autor

Thanks for your suggestion ! ;)

Autor Nejlepší odpověď
def _get_type_common2(self, cr, uid, context):
 if (context['params']['action']==171):
 ids =self.pool.get('project.task.type').search(cr, uid, [('case_default','=',1),
('task_type_is_project','=',False)], context=context)
elif (context['params']['action']==142):
 ids = self.pool.get('project.task.type').search(cr, uid, [('case_default','=',1),
('task_type_is_project','=',True)], context=context)
 return ids

Thank you zbik! This code works perfect!

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
bře 15
4158
1
led 25
1174
1
říj 22
28206
0
srp 16
2897
7
čvc 16
6097