Hi dear ones,
To remove options from an odoo 15 selection field, proceed as follows:
Example:
Basic model
class SurveyQuestion(models.Model):
_name = 'survey.question'
question_type = fields.Selection([
('text_box', 'Multiple Lines Text Box'),
('char_box', 'Single Line Text Box'),
('numerical_box', 'Numerical Value'),
('date', 'Date'),
('datetime', 'Datetime'),
('simple_choice', 'Multiple choice: only one answer'),
('multiple_choice', 'Multiple choice: multiple answers allowed'),
('matrix', 'Matrix')], string='Question Type',
compute='_compute_question_type', readonly=False, store=True)
*****************************************************************************
Inheritance model
class SurveyQuestionInherited(models.Model):
_inherit = 'survey.question'
question_type = fields.Selection(selection='_get_new_question_type', string='Type de question', compute='_compute_question_type', readonly=False, store=True)
@api.model
def _get_new_question_type(self):
selection = [
('text_box', 'Zone de texte à plusieurs lignes'),
('char_box', 'Zone de texte sur une seule ligne'),
('numerical_box', 'Valeur numérique'),
('date', 'Date'),
('datetime', 'Date et heure'),
('simple_choice', 'Choix multiple : une seule réponse')
]
return selection
After several unsuccessful attempts, this method worked for me.
I really hope it helps !