diff options
| author | Nasreddin (bon) <bon@odoo.com> | 2020-08-12 13:34:55 +0000 |
|---|---|---|
| committer | Nasreddin (bon) <bon@odoo.com> | 2020-08-13 16:22:18 +0000 |
| commit | a137f22363ff538ab86f50d15851730af1b8ed76 (patch) | |
| tree | 1aad324f4b4d95238d24b9ea9cbc41f830186b18 /addons/web_editor/controllers | |
| parent | c5fee9d009329691db58a16c1f90eac734749f4d (diff) | |
[FIX] web_editor: Multi-company error when adding image to task description
Issue
- Select "My Company (Chicago)" as current company
- Open "Projects" module
- Create a new Task
- Edit description, upload a new Image and add it to description.
Multi-company error "Write" on project.task .
In frontend, can optimize uploaded picture.
Causes
Wrong "allowed_company_ids" value in context.
Solution
Remove allowed companies from context to avoid allowed_company_ids
which may erroneously restrict based on website.
opw-2304511
closes odoo/odoo#55897
X-original-commit: 8f6506a57853040d065569fdd60f9d94be8e26e1
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
Diffstat (limited to 'addons/web_editor/controllers')
| -rw-r--r-- | addons/web_editor/controllers/main.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index 2b2a5a7d650..5285af88c2c 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -162,11 +162,13 @@ class Web_Editor(http.Controller): data = tools.image_process(data, size=(width, height), quality=quality, verify_resolution=True) except UserError: pass # not an image + self._clean_context() attachment = self._attachment_create(name=name, data=data, res_id=res_id, res_model=res_model) return attachment._get_media_info() @http.route('/web_editor/attachment/add_url', type='json', auth='user', methods=['POST'], website=True) def add_url(self, url, res_id=False, res_model='ir.ui.view', **kwargs): + self._clean_context() attachment = self._attachment_create(url=url, res_id=res_id, res_model=res_model) return attachment._get_media_info() @@ -177,6 +179,7 @@ class Web_Editor(http.Controller): Returns a dict mapping attachments which would not be removed (if any) mapped to the views preventing their removal """ + self._clean_context() Attachment = attachments_to_remove = request.env['ir.attachment'] Views = request.env['ir.ui.view'] @@ -259,6 +262,12 @@ class Web_Editor(http.Controller): attachment = request.env['ir.attachment'].create(attachment_data) return attachment + def _clean_context(self): + # avoid allowed_company_ids which may erroneously restrict based on website + context = dict(request.context) + context.pop('allowed_company_ids', None) + request.context = context + @http.route("/web_editor/get_assets_editor_resources", type="json", auth="user", website=True) def get_assets_editor_resources(self, key, get_views=True, get_scss=True, get_js=True, bundles=False, bundles_restriction=[], only_user_custom_files=True): """ |
