Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
9636 Näkymät

how to set default value for many2one field

Avatar
Hylkää
Paras vastaus

find the id of that default value and give it to the many2one field using _defaults = ...

Avatar
Hylkää
Tekijä

I have to write a function for default

Suppose I have a many2many relationship from a module "x" with partners. then, the relationship of this many2many fields, becomes a many2one (between the items selected for partners and invoice). I have limited the domain for this relationship in the invoice using domain="[('partner_ids', '=', partner_id)] in the view. It works but now I want to get the first of these items (in the invoice) as the default one. So, actually I don't know the id of the item because it varies for each partner. I just want selected as default the first one in the list. How could I do this?

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
3
lokak. 18
40896
0
syysk. 22
60
2
elok. 22
3371
0
jouluk. 21
2816
1
tammik. 17
6639