Skip to Content
Menu
This question has been flagged

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
0
Nov 19
60
3
Feb 23
2176
1
Nov 22
1561
0
Jul 20
2124
2
Apr 19
6784