The pages here do not include pages that are returned using JINJA2 rendering.
Using jinja2 rendered pages, you can pass parameters to the page directly when you call Template.render (), and the page gets through the El expression.
and corresponding to the General page, the mobile sent over the request, we can only return the data in the case, what should be done?
One: Return text data
If it is a text message, we use JSON as the transmission medium.
In Odoo's controller, store the data in an array, dictionary, object, and then use it to convert to JSON data:
import json// importing JSON module //= Json.dumps (datas)//return Jsonstr.decode ( ' Unicode_escape ') Return to the person making the request
Report:
How to extract data on the requesting side: To receive a JSON array as an example:
for (Let i = 0; i < json.length; i++) {// traversal returned to JSON array var value = Json[i].key// extract content by key }
Second: Back to Multimedia
For the transmission of multimedia content such as video, audio, picture, etc., we use IO stream form.
from Import Stringio Import = request.env[' model name '].sudo (). Search ([(search condition)])return Http.send_file (Stringio (Base64.standard_b64decode (record. Multimedia field)), Filename="The file name can be set by itself, note that the suffix must have, Otherwise the IO stream sent back cannot be parsed correctly ", As_attachment=true)
Where: Multimedia fields can be pgadmin to view the corresponding model database tables, storage content is binary data is the field of the preservation of multimedia content, with the field name to extract binary content.
Since Odoo is using Base64 format to store data by default, we need to decode the extracted binary data with Base64, decode the resulting data string as parameters, pass it to Stringio, generate the data stream, and send it back.
How Odoo returns data to Web pages, mobile, as a backend