1

I have a selection field and I want to inherit and update the selection field without overriding, here is what I am implementing.

Base field:

test_field = fields.Selection([ ('a', 'A'),('c', 'C'),],'Test Field')

The way I inherited

test_field = fields.Selection(selection_add=[('b', 'B')])

But this updates the field by updating the selection value in the end like this:

[('a', 'A'),('c', 'C'), ('b', 'B')]

however I want something like this:

[('a', 'A'),('b', 'B'), ('c', 'C')]

Just wondering if there is way to accomplish this without actually overriding the field. Any ideas or thoughts would be appreciated. Thanks.

Bishal Ghimire
  • 647
  • 7
  • 15

1 Answers1

2

From class odoo.fields.Selection documentation:

or singletons (value,), where singleton values must appear in the overridden selection. The new values are inserted in an order that is consistent with the overridden selection

You can add the ('b', 'B') pair before the singleton like following:

test_field = fields.Selection(selection_add=[('b', 'B'), ('c',)])
Kenly
  • 24,317
  • 7
  • 44
  • 60