muk-it / muk_web

MuK Odoo Web Modules
GNU Lesser General Public License v3.0
109 stars 232 forks source link

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

Closed Tikanya closed 5 years ago

Tikanya commented 5 years ago

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 commented 5 years ago

https://github.com/muk-it/muk_web/commit/6ab318c0d216f37bd6579e2ca0657c3edac9a48e

Tikanya commented 5 years ago

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 commented 5 years ago

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

keshrath commented 5 years ago

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

keshrath commented 5 years ago

https://github.com/muk-it/muk_web/commit/58f7801b8aaed8e1312aba97827dfb45f4319ad3

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

Tikanya commented 5 years ago

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"