Odoo Help


How to set a default value on many2many tags.

Nissan Pagotaisidro
on 11/10/15, 12:30 AM 4,594 views

Hello! How to set a custom or default values on a m2m tag widget?

for example:

In a tax types field, there are 3 types, "income", "value" and "excise"

i want that 3 to be the default value and there is no edit or create.

please help thanks! 

Hello! thank you for fast reply. Sorry noob here but I don't understand what does def get_taxes do. Can you explain it to me please? and i want my field to like a combo box but in a m2m tag form/widget

Nissan Pagotaisidro
on 11/10/15, 5:17 AM

get_taxes method will be called when you are creating a record. This method will return the IDs of those taxes which are of given type.

Serpent Consulting Services Pvt. Ltd.
on 11/10/15, 5:21 AM

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 11/10/15, 1:24 AM

Hello Nissan,

You can call a method in default and can set the taxes by searching the records.


def get_taxes(self):
return self.env['my.tax.tax'].search([('type', 'in', ['income', 'value', 'excise'])]).ids

my_taxes = fields.Many2many(default=get_taxes, ...)

Hope this help you.

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.


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)


Asked: 11/10/15, 12:30 AM
Seen: 4594 times
Last updated: 10/10/17, 9:22 AM