Skip to Content
Menú
This question has been flagged
2 Respostes
7905 Vistes

Hello All,

I have a selection field and another many2one field in odoo10. And i want that when i select only "service" from selection type field then another many2one field visible on the form view. Here i attach my python and xml code.


Python code:-

service_types = fields.Selection([('product', ('Product')),
('service', ('Service'))], string='Services', required=True)
name_rental = fields.Many2one('rental.pet', string="Rental Management")

Xml code:-

<field name="service_types"/>
<field name="name_rental" attrs="{'invisible': [('service_types', '!=', 'service')]}"/>
Avatar
Descartar

What is the prob? are you telling the above code is not working ?

Seems error is in your field defination. please correct the tuples of both field.

service_types = fields.Selection([('product', 'Product'),

('service', 'Service')], string='Services', required=True)

please field this field first and check.

Best Answer

Hello! 
please find the below code with changes

Python code:-

service_types = fields.Selection([('product', 'Product'),
('service', 'Service')], string='Services', required=True)
name_rental = fields.Many2one('rental.pet', string="Rental Management")

Xml code:-

<field name="service_types"/>
<field name="name_rental" attrs="{'invisible': [('service_types', 'not in', 'service')]}"/>

Avatar
Descartar
Related Posts Respostes Vistes Activitat
0
de set. 17
3326
2
de nov. 18
5541
0
de febr. 25
959
2
de des. 24
1287
0
de jul. 24
1079