Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
16470 Lượt xem

Hello Folks


After uploading an image on ODOO site and display it on the webpage

We have an image location like this


https://www.domain_name/web/image/565


the only difference with another uploaded image is the ID number


Where does ODOO store that image ?


in the server  file system ? where ?

in the PostgreSQL database ?


I've used find to search elsewhere on the entire server whithout success

may be it's an hidden directory ?


the problem is thant when I restore my database from one server to another

The images of website are not available

I think I need to restore in the same way the  image folder, but from where ?


where am I wrong ?


thank you for your help

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello,

Template to attach image file in your website form should contain following code:

 <form action="/save/my/profile" method="post" enctype="multipart/form-data">

  <input class="form-control" id="profile_image" type="file" name="profile_image" accept=".jpeg,.jpg,.png,"/>
 </form>

 Python code to save submitted image to res.partner:

 @http.route('/save/my/profile', type='http', auth="public", website=True)

    def save_image(self, **kw):
     datas = kw.get('profile_image').stream.getvalue()
     # store image in base64 format to image field of partner
     partner.sudo().write({'image': base64.encodestring(datas)})

Note: binary field for image should be defined with attachment=True

This image file will be stored inside the ir.attachment model (ir_attachment table).This table contains following values to establish the link to the original record:

    name: name of the binary field, e.g. image

    res_field: name of the binary field, e.g. image

    res_model: model containing the field, e.g. res.partner

    res_id: ID of the record the binary field belongs to

    type: 'binary'

    datas: virtual field with the contents of the binary field, which is actually stored on disk

Hope this will help you!

Thanks,

Ảnh đại diện
Huỷ bỏ

This error message show:

AttributeError: 'SpooledTemporaryFile' object has no attribute 'getvalue'

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 6 25
1446
1
thg 2 23
4286
3
thg 11 22
3965
2
thg 6 25
5502
0
thg 10 24
1889