diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-02-12 18:34:43 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-02-12 18:34:43 +0100 |
| commit | adeea2a88db4443b2b426877a28bb1471c2f5db1 (patch) | |
| tree | 2f43fecc9649947d3061e8c482219fa167b3385a /addons/web_editor/controllers/main.py | |
| parent | 317f5f11112266128ac2292ecfafcd92cda74fd0 (diff) | |
| parent | 0f02dcb63918228d48df50f2d5805b7fda25c14a (diff) | |
[MERGE] forward port branch saas-11.2 up to 0f02dcb6391
Diffstat (limited to 'addons/web_editor/controllers/main.py')
| -rw-r--r-- | addons/web_editor/controllers/main.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index f4500c7bcc6..b14c58ae938 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -146,6 +146,9 @@ class Web_Editor(http.Controller): # therefore we have to recover the files from the request object Attachments = request.env['ir.attachment'] # registry for the attachment table + res_model = kwargs.get('res_model', 'ir.ui.view') + res_id = res_model != 'ir.ui.view' and kwargs.get('res_id') or None + uploads = [] message = None if not upload: # no image provided, storing the link and the image name @@ -159,9 +162,11 @@ class Web_Editor(http.Controller): 'type': 'url', 'url': url, 'public': True, - 'res_model': 'ir.ui.view', + 'res_id': res_id, + 'res_model': res_model, }) - uploads += attachment.read(['name', 'mimetype', 'checksum', 'url']) + attachment.generate_access_token() + uploads += attachment.read(['name', 'mimetype', 'checksum', 'url', 'res_id', 'res_model', 'access_token']) else: # images provided try: attachments = request.env['ir.attachment'] @@ -188,10 +193,12 @@ class Web_Editor(http.Controller): 'datas': base64.b64encode(data), 'datas_fname': datas_fname, 'public': True, - 'res_model': 'ir.ui.view', + 'res_id': res_id, + 'res_model': res_model, }) + attachment.generate_access_token() attachments += attachment - uploads += attachments.read(['name', 'mimetype', 'checksum', 'url']) + uploads += attachments.read(['name', 'mimetype', 'checksum', 'url', 'res_id', 'res_model', 'access_token']) except Exception as e: logger.exception("Failed to upload image to attachment") message = pycompat.text_type(e) |
