Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
5030 Tampilan

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
Buang
Jawaban Terbai

Add attachment =True , it should work

Avatar
Buang
Jawaban Terbai

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
Buang

Hi, is there a workaround for this situation?

Jawaban Terbai

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
Buang
Penulis

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

Penulis

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.

Penulis

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

Post Terkait Replies Tampilan Aktivitas
3
Jan 24
1521
0
Mei 23
1458
1
Sep 22
3039
1
Des 21
5241
0
Mei 15
6319