Help

0

use "domain" in a field

Avatar
rifqui

i wanna have control on a field which i have only the values already selected in another field 

1 Comment
Avatar
Discard
Avatar
Christoph Ronken
-

Please provide some example or preferrably actual code. It is not that clear what you mean

2 Answers
0
Avatar
Odoo Mates
Best Answer

Hi,

You can use web_domain_field module from OCA, which allows you to set the the dynamic domain.

See: https://www.youtube.com/watch?v=dq5Vtj_pwuI

Problem with returning domain is not a stable solution and it is deprecated in odoo 14.

Thanks

Avatar
Discard
0
Best Answer

Hi,

In this way You can give the domain for a field based on another fields. Here i used two fields and state for passing domain to room id.

return {'domain': {'room_id': [('room_state', '=', 'available'),
('bed_type', '=', self.bed_type), ('facilities_ids', '=', facilities)]}}

Or you can also try the following method

default_id = fields.Many2one('product.attribute.value',
domain="[('id', 'in', value_ids)]",
string="Default Value")

Here 'default_id' is the field we want to control and 'value_ids' in the domain is the another field and their values are already selected.So under 'default_id' field you can see only the values selected in 'value_ids' field.

Regards

Avatar
Discard