Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
8200 Vizualizări

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

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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, }

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
feb. 24
28498
1
feb. 24
2070
3
iun. 23
55341
0
iul. 24
3132
0
iul. 22
60