0
votes

I created a selection field in odoo :

commercial_group = 

  fields.Selection([('1GB_dynPool_Plus_LTE','1GB_dynPool_Plus_LTE'),

 ('1GB_EU_dynPool_Plus_LTE', '1GB_EU_dynPool_Plus_LTE'), 

 ('3GB_dynPool_Plus_LTE', '3GB_dynPool_Plus_LTE'),

 ('5GB_dynPool_Plus_LTE', '5GB_dynPool_Plus_LTE')], string='Commercial Group')

And I would like to populate this field with the value which i am getting from api like this :

         record.sudo().create({"id" : count,

         "commercial_group": commercial_group.text, // **Here commercial_group.text=5GB_dynPool_Plus_LTE**

     })

But i get an error. What is the right way to populate a selection field Dynamically??

1
I suggest use many2one field instead selection field and give it selection widget or no_create and no_edit option as True - khelili miliana
didnt work!!!!!! - Anudocs

1 Answers

0
votes

@khelili-miliana is rigth you should define a Many2one field instead of a Selection field using the record model of the incomplete create code. Incomplete because if you are asking for help you should be providing all the needed info to understand your situation and provide you with a proper answer. Also you are setting the id of the record and you should avoid that since Odoo is capable of generate the id. Try this field with the proper "record model"

commercial_group = fields.Many2one("record model")

and set this on the view

<field name="commercial_group" widget="selection"/>