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

Hi everyone,

I created a custom form and I able to save fields like email, name, etc. Now I want to attach image to the form. These are my files

Model:

from odoo import models, fields, api, _
from odoo.modules.module import get_module_resource
import base64

class Registro(models.Model):
    _name = 'feria.registro'
    _description = 'Recopilacion de datos en Feria'
    name = fields.Char(string='Name', required=True, tracking=True)
    attachment = fields.Image('Image', attachment=True)......


Controller:

class Feria(http.Controller):
    @http.route('/feria/formulario', type="http", auth='public', website=True)
    def feria_form(self, **kw):
    contact_list = request.env['res.partner'].sudo().search([])
    values = {
        'attachment': attachment_id
    }
    return http.request.render('feria.custom_form', value)


View:


With this, I´m getting the error:

TypeError: 'FileStorage' object is not subscriptable


Please help me, I´m learning Odoo :)


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

Hi,

You can refer to the Blog: https://www.cybrosys.com/blog/how-to-upload-files-from-web-form-in-the-odoo-15

Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 2 24
5226
1
thg 9 22
2611
2
thg 5 22
15068
2
thg 7 24
4166
2
thg 5 25
9747