Odoo Help

Welcome!

This community 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.

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,540 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--
2896
| 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?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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