Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
5022 Vistas

I have Many2one field linked to 'res.partner' 

I also have related field to this many2one field and catch the image from this customer record to display it on  the form 

at first it appear but when I click save or reopen this record image don't appear and this message don't display
any help

name_id = fields.Many2one('res.partner', required=True, string='Customer Name', ondelete='restrict',store=True)
image_id = fields.Image(related='name_id.image_1920')


Avatar
Descartar
Mejor respuesta

Add attachment =True , it should work

Avatar
Descartar
Mejor respuesta

Hi,

In default odoo you can not define many2one field with field name "name" with image field in a same form view because it generate error in addons to avoid this situation follow odoo name field rules.

Regards

Avatar
Descartar

Hi, is there a workaround for this situation?

Mejor respuesta

As I can see in your code your related field is point to name and it should be related to name_id

image_id = fields.Image(related='name_id.image_1920')


I have tested it in sale order and its working. I have added the below field in sale order:

image_1920 = fields.Image(related='partner_id.image_1920')

In Sale order form view before the title I have added it:

<xpath expr="//div[hasclass('oe_title')]"  position="before">
<field name="image_1920" widget="image" class="oe_avatar" options="{&quot;zoom&quot;: true}"/>
</xpath>


If its not work, to add compute_sudo= True to the field.


Avatar
Descartar
Autor

I edit it
but it still not appear after save the record

Try to add compute_sudo=True as in my updated answer, If still not working add readonly= False

Autor

I try both of your attribute but it is still not appear

It's working with me in Odoo 15. You need to update your Odoo to the latest.

Autor

I have odoo 15 and it's not work
I don't dare you but it still doesn't work on my App

Publicaciones relacionadas Respuestas Vistas Actividad
3
ene 24
1513
0
may 23
1454
1
sept 22
3037
1
dic 21
5237
0
may 15
6314