Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

[12.0][muk_web_preview_msoffice] docx, xlsx, pptx url missing fot non-admin user #85

Closed
Tikanya opened this issue May 7, 2019 · 6 comments
Assignees
Labels

Comments

@Tikanya
Copy link

Tikanya commented May 7, 2019

Ms Office doc-file is previewed correct, but for .docx odoo creates temporary attachment with wrong mime type (text/plain) in case user access is not "Administration/Settings". Thus non-admin user can't preview docx, pptx and xlsx

@keshrath keshrath added the 12.0 label May 7, 2019
@keshrath keshrath self-assigned this May 7, 2019
@keshrath
Copy link
Member

6ab318c

@Tikanya
Copy link
Author

Tikanya commented May 11, 2019

The error comes from here: /odoo/addons/base/models/ir_attachment.py

def _check_contents(self, values):
mimetype = values['mimetype'] = self._compute_mimetype(values)
xml_like = 'ht' in mimetype or 'xml' in mimetype # hta, html, xhtml, etc.
user = self.env.context.get('binary_field_real_user', self.env.user)
force_text = (xml_like and (not user._is_system() or
self.env.context.get('attachments_mime_plainxml')))
if force_text:
values['mimetype'] = 'text/plain'
return values

@keshrath
Copy link
Member

Thats why I set the mimetype in the controller. The _compute_mimetype should than take this value instead of trying to compute it.

@keshrath
Copy link
Member

I was finally able to reproduce the bug and will try to fix it asap.

@keshrath
Copy link
Member

58f7801

Please try again now. This seems to be a rather strange behaviour of Odoo. I already opened a ticket in Odoo.

@Tikanya
Copy link
Author

Tikanya commented May 22, 2019

Sorry, muk_web_utils (12.0.2.9.6) does not solve the problem for me, even more, now the admin together with a non-admin user cannot preview *.docx. Although I understand that this is against the rules - but only this change solved my problem: edit odoo / odoo-server / odoo / addons / base / models / ir_attachment.py remove the condition "not user._is_system () or"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants