Odoo Help

Welcome!

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.

0

How to get different default value in different view

By
tomcio1205
on 2/12/16, 8:58 AM 454 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--
5941
| 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!

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)

Stats

Asked: 2/12/16, 8:58 AM
Seen: 454 times
Last updated: 2/13/16, 6:32 AM