Closed Tikanya closed 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
Thats why I set the mimetype in the controller. The _compute_mimetype
should than take this value instead of trying to compute it.
I was finally able to reproduce the bug and will try to fix it asap.
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.
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"
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