Odoo Help

0

How to get different default value in different view

By
tomcio1205
on 2/12/16, 8:58 AM 662 views

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?

1

Zbik

--Zbik--
6293
| 6 4 7
Lodz, Poland
--Zbik--


Zbik
On 2/12/16, 9:32 AM

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

Thanks for your suggestion ! ;)

tomcio1205
on 2/13/16, 6:34 AM
0
tomcio1205
On 2/13/16, 6:32 AM
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!

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: 2/12/16, 8:58 AM
Seen: 662 times
Last updated: 2/13/16, 6:32 AM