跳至內容
選單
此問題已被標幟
3 回覆
8083 瀏覽次數

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
28286
1
2月 24
1881
3
6月 23
54846
0
7月 24
2865
0
7月 22
60