Ir al contenido
Menú
Se marcó esta pregunta

Hello,

I'm having trouble with hiding the dropdown function from a many2one field. 

I want to make the field NOT show possible values to choose from the dropdown list. The dropdown list should not be shown at all, but the field has to be a many2one, since i want the field to be related to static values. 

Does anyone know how to do so?



Avatar
Descartar
Mejor respuesta

Hi  Simon ,

You can use related if the field provides the value of a sub-field on the current record

employee_id = fields.Many2one('hr.employee', string="Employee", default=lambda self: self.env.user.employee_id.id,help='Name of the employee for whom the request is creating')
department_id = fields.Many2one('hr.department', string="Department", related='employee_id.department_id',
help='Department of the employee')

or you can use 'default'

your_field_name = fields.Many2one(
comodel_name
='your.model', default=lambda self:
self.env['your.model'].search([], limit=1))

In XML 

<field name="your_field" force_save="1" readonly="1"/>


Hope it helps,
Kiran K


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
nov 19
60
1
ago 25
840
3
feb 23
3664
1
nov 22
3155
0
jul 20
3138