To upload files through web page you have to create a template and odoo controller.
upload_file_attachment_in_odoo_website.xml
upload_file_attachment_in_odoo_website.py
Code Description:
Read More: Inherit web login controller in Odoo
In above code snippet we have created an odoo template, and in that template we have created a HTML form tag, and set the action of that form as our odoo controller route. We have also take three input type fields and a submit button. When user clicks on submit button the form action goes to our odoo controller and save the attachment file in "attachment" model.
9 Comments
great sharing
ReplyDeleteHello, can you share with us github link for code?
ReplyDeleteThank you
how to display this field in website
ReplyDeletein your code error: .py code: row:15 'res_model':'model.model', - you missed " ' "
ReplyDeleteYup got it, thanks
DeleteHi I Tried this code but "file = post.get('attachment')" is returning a string object.
ReplyDeletewhen i try attachment = file.read() its says str object has no attribute read()
can you please share your attachment field
DeleteHi file = post.get('attachment') is giving me string object and when i try attachment = file.read() it says
ReplyDeletestr object has no attribute read()
i am only able to attach only 1 file not multiple any specific reason?
ReplyDelete