I have a Many2one field that has a domain filter with 2 conditions that it needs to meet. There should only be one value to select in that Many2one field that meets those 2 conditions. Since there is only one value to select from, I would like that Many2one field to automatically select that specific value or default to that value. Is there a way to do this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Akuntansi
- Inventaris
- PoS
- Project
- MRP
Pertanyaan ini telah diberikan tanda
Hi,
Either you can set the value from an onchange function or from the default get function or by making a computed field.
I think here it is better to set the value using the default get method.
Reference: https://www.youtube.com/watch?v=OBw0PFhOAnM
Thanks
@api.model
def default_get(self, fields):
res = super(ClassName, self).default_get(fields)
#if conditions are met
res['field_name'] = id_of_many2one_field
return res
@api.model
def default_get(self, default_fields):
res = super(Classname, self).default_get(default_fields)
res['m2o_field'] = (4, ID) # (4, ID of m2o field)
return res
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
DaftarPost Terkait | Replies | Tampilan | Aktivitas | |
---|---|---|---|---|
|
1
Des 21
|
2258 | ||
get the value of a field of other model
Diselesaikan
|
|
3
Mar 24
|
7239 | |
|
3
Agu 25
|
2027 | ||
|
2
Feb 24
|
2449 | ||
Odoo 13 many2one filter base of the current user
Diselesaikan
|
|
2
Nov 22
|
4925 |