Odoo Help

0

How to set default values on form loading for many2many field in account_invoice_line ?

By
vadivel
on 4/8/15, 3:24 AM 1,749 views

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

0
vadivel
On 4/8/15, 6:14 AM

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

0

Temur

--Temur--
2912
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 4/8/15, 4:26 AM

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

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 4/8/15, 3:24 AM
Seen: 1749 times
Last updated: 4/8/15, 6:17 AM