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

Hello friends,

I am working in V 7.0. I have to set a default values for many2many field name called "Expenses" (more than one values), when click on "Add an item".Please reply me for this situation .Thanks in Advance

アバター
破棄
著作者 最善の回答

Hi friends, This code worked for me.Make use of it

def _get_expense_id(self, cr, uid, context=None):

     result = []

     if context is None:

         context = {}

     name = ["Selling Expenses","Grading Expenses","Stock Maintenance Expenses", "Fumigation Charges"]

     expense_obj = self.pool.get('expense.deduct')

     res = expense_obj.search(cr, uid, [('name', '=', name )])

     for eachid in res:

        result.append(eachid)

     return result or result[0] or False

     _defaults = { 'expense_deduct_id': _get_expense_id, }

アバター
破棄
最善の回答

it does not work when you set the default value for that field in the related model?

アバター
破棄
関連投稿 返信 ビュー 活動
2
2月 24
28513
1
2月 24
2095
3
6月 23
55366
0
7月 24
3145
0
7月 22
60