Search code examples
pythonodooodoo-12

Selection field options in odoo


I have to create a new field in one of my forms which is a selection field. How do i make the options in the selection field, entries from another model( like selecting a place from list of places). Do i have to create a new module for such a field? I am using odoo 12.

NB: odoo newbie!


Solution

  • Instead of Selection field you have to create a Many2one field.You can define a Many2one field like ,

    from odoo import fields
    
       field_name = fields.Many2one('your.model', string="Field  Name")
    

    In your case, consider you have the places in the model place.place, then you can create the Many2one field in your form like ,

       place_id = fields.Many2one('place.place', string="Place")