-
-
Notifications
You must be signed in to change notification settings - Fork 379
[16.0][MIG] attachment_preview: Migration to 16.0 #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7f77b67 to
38faa14
Compare
|
Hi this PR is ready, please review @vancouver29 @HolgerNahrstaedt @holgern I am tagging you as you worked on #363 (15.0 mig) @hbrunn I am tagging you as you bootstrapped this module, in case you're still around |
|
Thank you for migrating this! Despite having no browser or server error, the preview doesn't seem to work in either FF or Chrome for anything but pdf files. |
Hi @len-foss did you test on runboat? My screenshots in this issue are from runboat; the file with "character formatting" / "paragraph formatting" is an ODT file. I'm using Chromium mainly, but I just tried with Firefox in an incognito window; no problem either. At the moment, the only supported file extensions are those in In this PR I did not update the viewerjs lib; we could update it in a separate PR and add new supported filetypes in there. |
|
@houzefa-abba I tried in combination with |
|
@houzefa-abba oh thanks, indeed it works fine with odt files, runboat or local. I agree doing the update in a separate PR is the proper way to do it, let's just hope it gets through quickly for once. I confirm the behavior reported by @astirpe, although I wouldn't call it a glitch. It seems you could trivially fix it by setting the z-index of |
838485f to
0a4b343
Compare
Good catch! Fixed with z-index change suggested by @len-foss. I also used some |
0a4b343 to
f55a434
Compare
|
I added widget clean-up in my last change, otherwise I was getting multiple widgets in the DOM tree when navigating in and out of form views |
|
/ocabot migration attachment_preview |
|
|
||
| setup() { | ||
| var res = this._super(...arguments); | ||
| this.attachmentPreviewWidget = new AttachmentPreviewWidget(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment we have two different functionalities for the PDF preview on forms:
- standard Odoo PDF preview
- this module (
attachment_preview)
Would be nice to have an option to disable this attachment preview on forms for this module (attachment_preview). This is a requirement for one of our customers. So the idea is that the admin could decide to configure the option (enable/disable). This way, when the option is disabled, the standard Odoo preview will be work in place of this module (attachment_preview).
Disabling this option can be easily achieved by returning res just after the _super(..).
var res = this._super(...arguments);
if (is_attachment_preview_disabled) return res;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea makes perfect sense. To take it even further, I did ponder whether this module could entirely re-use components added by Odoo to implement their preview feature...
I won't be able to get to this until at least next week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@houzefa-abba did you get time to get to this or you plan to do it in the near future ? thanks for this PR anyway !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi this is still in my TODO but it has moved further back 😅
Very unlikely I could get back to this PR until end of May
This per-form setting hinges between fix (imposed by odoo16 adding its own preview system) and evolution; perhaps we could add it as a separate evolution PR so this initial PR can get moving as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi I got back onto this topic for a bit
I just rebased on top of latest 16.0 and added a commit to disable Odoo's default attachment sidebar can show up in views with <div class="o_attachment_preview" />
However I kept pondering @astirpe's idea above but I can't see a way it fully makes sense:
- Global setting: would be useful to disable our viewer in forms in favor of odoo's own viewer when one still wants to use our viewer somewhere else, but it doesn't make much sense to me: such an odoo app would use 2 different viewers based on view type, potentially displaying the same documents in different ways depending on view type.
- Per-form setting (on the
<form>tag): again, I can't see a use case, especially when we assume our viewer is similar (and in parts more powerful) than odoo's base one.
Could we think about it some more before confirming we need such a setting? In a separate PR possibly?
Thanks
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
In order to get visibility on https://www.odoo.com/apps the OCA board has decided to add the OCA as author of all the addons maintained as part of the association.
[FIX] Lint [FIX] lint and flake [ADD] tests [ADD] tests [ADD] tests [ADD] Tests [ADD] Package python-magic [ADD] Tests [FIX] Lint
[REM] Old files [ADD] Magic to travis file [FIX] Nagivation refresh widget
Currently translated at 100.0% (2 of 2 strings) Translation: knowledge-12.0/knowledge-12.0-attachment_preview Translate-URL: https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-attachment_preview/sl/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: knowledge-12.0/knowledge-12.0-attachment_preview Translate-URL: https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-attachment_preview/
…_attachment_preview
Currently translated at 100.0% (4 of 4 strings) Translation: knowledge-15.0/knowledge-15.0-attachment_preview Translate-URL: https://translation.odoo-community.org/projects/knowledge-15-0/knowledge-15-0-attachment_preview/es/
Currently translated at 100.0% (4 of 4 strings) Translation: knowledge-15.0/knowledge-15.0-attachment_preview Translate-URL: https://translation.odoo-community.org/projects/knowledge-15-0/knowledge-15-0-attachment_preview/it/
Overall implementation remains the same as in previous versions: * patch into attachment list to prepare prev/next buttons in the viewer * patch into attachment cards to observe clicks on new buttons this module adds * fetch attachment extensions * add an iframe into the DOM tree next to the main form one, display viewer inside it * add preview button within binary fields Main changes in this migration: * update imports/exports to proper JS modules - in particular, this fixes "service already defined" console messages we also get in 15.0 * rework FormRenderer injector, previous (legacy) one was no longer used * patch attachment list / cards with new methods in the mail module * fix preview button inclusion within binary fields * fix previous/next viewer buttons
Odoo's default attachment sidebar can show up in views with `<div class="o_attachment_preview" />`. Our attachment sidebar would show up on top of it, making the base Odoo sidebar obsolete. ➔ We disable it.
f55a434 to
8e6a26c
Compare


I squashed a few commits according to https://github.com/OCA/maintainer-tools/wiki/Merge-commits-in-pull-requests
This PR has 2 commits: 1 with the actual migration; 1 where I move code around without changing anything. I can squash them if you feel it's better
I made sure this plays well with
web_responsive& especiallyweb_chatter_positionwith its 3 chatter settings (responsive / bottom / sided)I added a ROADMAP file with possible future improvements
Overall implementation remains the same as in previous versions:
module adds
viewer inside it
Main changes in this migration:
fixes "service already defined" console messages we also get in 15.0
Screenshots from runboat
2 buttons in attachment cards to preview inline & open in new tab:

Inline preview of a PDF:

Inline preview of an ODT (which I navigated to using left arrow at the top of the viewer):

Binary field with button to open in new tab:
