Skip to Content
Menu
This question has been flagged
4 Replies
1845 Views

Hello,


I just need to take out the other from the gender selection.


Can anyone assist?

Avatar
Discard
Best Answer

You just overwrite that fields like 

gender = fields.Selection([
('male', 'Male'),
('female', 'Female'),
])

please follow https://www.odoo.com/documentation/12.0/developer/reference/orm.html#odoo.fields.Text

Avatar
Discard
Author

Thanks Farid, but the issue is where to do this overriding

Best Answer

Hi,

You need to modify the field definition in the relevant model.

1: Identify the model and field that need to be modified. Example There is a
selection field inside ‘hr.employee’ ‘gender’ inside ‘hr.employee’.

2: Edit the selection parameter by Inheriting ‘hr.employee’. Here’s an example

from odoo import fields,models
classEmployeeSelectionInherit(model.Model):
​_inherit=’hr.employee’

​gender =fields.Selection([ ('male', 'Male'), ('female', 'Female'), ],string='Gender')

In this Custom Module We removed the “other” option from ‘gender’ field
inside ‘hr.employee’.

3: Update the Module and Apply Changes.

After this ‘other’ should be not seen in hr.employee.

Regards

Avatar
Discard

Please, how can i do that using Odoo studio ?
you can explan to me with pictures
Thanks a lot !

Best Answer
gender = fields.Selection(selection='get_gender',string="Gender")

@api.model
def get_gender(self):
return [
('male', 'Male'),
('female', 'Female')
]


Avatar
Discard
Best Answer

In an app, you need a python file, e.g. employee.py:

from odoo import models, fields

class Employee(models.Model):

​_inherit = 'hr.employee'

​gender = fields.Selection(selection=[('male', 'Male'), ('female', 'Female')])

This code will override the gender selection of 'hr.employee' model.

Avatar
Discard