Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
5024 Переглядів

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')


Аватар
Відмінити
Найкраща відповідь

Add attachment =True , it should work

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити

Hi, is there a workaround for this situation?

Найкраща відповідь

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.


Аватар
Відмінити
Автор

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

Автор

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.

Автор

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

Related Posts Відповіді Переглядів Дія
3
січ. 24
1514
0
трав. 23
1455
1
вер. 22
3037
1
груд. 21
5238
0
трав. 15
6315