Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
8217 มุมมอง

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?

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.พ. 24
28532
1
ก.พ. 24
2122
Security (6,0) and (4) in openerp แก้ไขแล้ว
3
มิ.ย. 23
55392
0
ก.ค. 24
3160
0
ก.ค. 22
60