Reputation: 13
can someone help me with this, How to add an image in many2one field in odoo 13
I want to add an image in the many2one field means when my dropdown list appears it include the name and the image with it
Upvotes: 1
Views: 706
Reputation: 793
You can’t add an image directly to a fields.Many2one
field. Because an image is also a field (fields.Binary
).
You can create a relational model and next extend your model. For example, this code enables you to add many photos to your obiect.
In your model add:
your_images_ids = fields.One2many(“your.image.model”, “product_id”)
in your.image.model (new one) model:
… other fields..
yourmodel_id = fields.Many2one(“your.model”)
image = fields.Binary()
Then you can extend your view also and try to put photo next to your obiect.
Upvotes: 1