Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I have created a hello world module following this tutorial https://www.odoo.com/documentation/9.0/howtos/website.html and it's working fine.
Now I would like to implement a file upload on this hello world page.
My templates.xml file is like this (I just get the relavant part):
<form action="/upload" method="post" enctype="multipart/form-data">
Upload file: <input type="file" name="uploaded" /> <br />
<input type="submit" name="submit" value="Submit" />
My controllers.py is like this (I also just give the relevant part, my module name is "sunxia") :
# -*- coding: utf-8 -*-
from openerp import http
@http.route('/upload', type="http", auth="public", methods=['GET', 'POST'])
form_data = cgi.FieldStorage()
file_data = form_data['uploaded'].value
But after choosing a file and click the upload button, the /uploads page gave an error messange:
TypeError: upload_file() got an unexpected keyword argument 'uploaded'
It seems that it cannot get the uploaded file in my controller. Can anyone told my how may I change my controller to implement this simple upload?
Since I'm quite new to odoo and python... I would strongly appreciate if you could give me more detail about this.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 2/27/16, 9:14 AM|
|Seen: 1488 times|
|Last updated: 2/27/16, 11:44 AM|