コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
5023 ビュー

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

関連投稿 返信 ビュー 活動
3
1月 24
1514
0
5月 23
1455
1
9月 22
3037
1
12月 21
5238
0
5月 15
6315