콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
13501 화면

Here's my model.py:

def ExampleForm(models.Model):
    _name = 'example.form'
    
    name = fields.Char('Name')
    picture = fields.Binary('Picture', attachment=True)

And here's my data.xml

<record model="example.form" id="example_form">
  <field name="name">Hello World</field>
  <field name="picture">
    <!-- Assume that my image is located in /example/data/helloworld.png -->
  </field>
</record>

What options do I use for the picture/binary field?

아바타
취소

I figured it out, it was "my_module/static/img/my_logo.png"

베스트 답변

Hi Mc,

You can simply set the type to base64, the Odoo framework will handle it as base64 then. This means the image is stored as a base64 in the database and shown as an image in the Odoo frontend:

<field name="image" type="base64" file="/example/data/helloworld.png"/>

Regards,
Yenthe

아바타
취소

How would it work if I wanted to provide a relative path inside my module? I tried "./static/img/my_logo.png" but it wasn't found

베스트 답변

You can simply set the type to base64, the Odoo framework will handle it as base64 then. This means the image is stored as a base64 in the database and shown as an image in the Odoo frontend:

아바타
취소
관련 게시물 답글 화면 활동
2
9월 19
5119
2
2월 24
3273
1
8월 23
4872
6
4월 23
17112
2
12월 22
6314