コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
4388 ビュー

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?

アバター
破棄
最善の回答

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

アバター
破棄
著作者

Thanks for your suggestion ! ;)

著作者 最善の回答
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!

アバター
破棄
関連投稿 返信 ビュー 活動
0
3月 15
4288
1
1月 25
1365
1
10月 22
28376
0
8月 16
2994
7
7月 16
6249