Sheenergizer
Sheenergizer

Reputation: 85

What are the steps I need to do to change a field from Selection to Many2one

This is related to my previous question, see here. The package_type field has 2 values that can be selected, but I need to dynamically change it based on the other fields.

package_type = fields.Selection([('item', 'Loose Cargo'), 
   ('container', 'Containerized')], string="Package Type", default='item')

Based on some forums, it is not possible to change those values. Instead make them Many2one

package_type = fields.Many2one('package.type', string="Package Type")

As far as I know, I need to create a model for that and fill the database with its data. How can I do that? I just need to put those 2 values again. Overall, the main issue I have is that I need to have a dynamic choice/domain for the package_type based on the values of the other fields and I cannot do that if it is fields.Selection. What are the steps I need to do, if I need a migration script, how and when should I execute it, since it should only be executed once.

I tried using CoPilot but its answers changes every time so I do not know what is the correct one. I cannot just apply every answer and revert back since the database schema is involved

Upvotes: 0

Views: 16

Answers (0)

Related Questions