Support is limited and more of a hindrance than a help, as some
clients' suppliers create PDFs with broken scripting which trigger the
autoprinting any time they're loaded and can have other odd
misbehaviors, which is a hassle.
OPW-3208409
OPW-3222228
closesodoo/odoo#115659
X-original-commit: a7331d9709c8e097356f89bf144986f441c8f2cc
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Reimplementation of 74fa91e0b3 on top of
new version of pdfjs. See previous commit for explanation.
Ideally we would set that behaviour from the outside using
e.g. `PDFViewerApplicationOptions.set` but there are multiple
locations from which we embed the viewer, which makes that a difficult
proposition. There should probably be a clean component which handles
loading the library, configuring it to our specifications (possibly on
a per-embed basis), and exposing both manipulations methods and events
which pdfjs triggers on its eventBus.
Part-of: odoo/odoo#100067
Our current version is getting rather outdated. Replace by
the *legacy* bundle: pdfjs now provides a non-polyfilled version of
the library, which is probably faster though it doesn't save overly
much (for the entire bundle anyway). Use polyfilled version for
safety, though it's unclear whether non-chromium Edge is still
supported by Odoo. If not, we could just use the non-polyfilled
version.
The difference is quite large for pdf.js (+32.5%), however it is much
less consequential for the sandbox (+1%) or for the much larger
worker (+5.6%). The biggest difference is likely performances
but... who knows?
Notes:
- The main reason for this change is that automated vulnerability
scanner have apparently started scanning for `postMessage(..., '*')`
and the previous bundles includes a version of corejs polyfills
without zloirock/core-js#542), therefore triggering those scans. As
the PR notes this is almost certainly not a concern because of the
innocuous payload, but there is no reason to waste time on those
reports if we don't *have* to.
- The bundle now includes "standard fonts", those were removed as
they're heavy and may not be necessary for our usage (?).
- All the bitmap images were dropped and replaced by svgs, which is
nice.
- The local changes since the previous update were *not* impacted in
this, the entire thing was just reset to upstream. This means
changes which were backported (922c7c72, 6943714f) are superseded
but more odoo-specific changes will have to be reapplied in further
commits.
Part-of: odoo/odoo#100067
Currently when we click on external links from a PDF opened in our
PDF viewer, you are redirected to the link, means you are leaving
the record which is not ideal.
With this commit, external links in PDF document will be opened in
new tab so that the opened record is not lost. For that we need to
change the default option of the pdfjs lib, because we cannot pass
this parameter in iframe (link of the documentation is available in
task pad). For that, we changed the value of 'externalLinkTarget'
from 0 (which sets target to NONE) to 2 (which sets target to BLANK)
in 'getDefaultPreferences' function.
taskID-2752002
closesodoo/odoo#84594
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
In new version of chrome (92) or firefox when some fonts (eg. courier)
were used:
- either the page would never finish loading (odoo 13 and below)
- or the text would in this font would not be shown (odoo 14 and over)
This was solved in pdf.js whith this commit:
https://github.com/mozilla/pdf.js/commit/8805614a03
And this PR is backporting that commit in 12.0 version up to master.
opw-2621405 opw-2613412 opw-2620186 opw-2618225 opw-2616690 opw-2615502
opw-2616249 opw-2615144 opw-2613969 opw-2613793 opw-2618129 opw-2617736
opw-2622506 opw-2614508 opw-2620883 opw-2622105 opw-2620863 opw-2615326
opw-2622842 opw-2620220 opw-2622842 opw-2620220 opw-2615346 opw-2615026
opw-2618389 opw-2619382 opw-2613286 opw-2621730 opw-2613412 opw-2622029
opw-2620625 opw-2622311
closes#75020closesodoo/odoo#75057
X-original-commit: d3feb26c8923cfde60894058f06dc2c2a8be05f5
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Some features of the PDF.js library doesn't work in the
webview of the mobile apps.
Initially 'window.print' is defined as an empty function in
webviews unlike browsers where it is already ready.
After that, PDF.js needs to monkey patch 'window.print' and
saves a reference to the original definition, which is not
yet fulfilled in by the mobile app (Java part).
So the print of PDF.js doesn't work in webviews and end
users will need to download the file before printing it.
Regarding the Download button, the 'download' attribute is
not supported by the webview as you can see in:
https://bugs.chromium.org/p/chromium/issues/detail?id=432414
As there's many ways to download a file in Odoo it's not
a big deal to simply hide it in PDF.js.
Because it's quite complicated to fix this, we decided
to hide the features that don't work (Download / Print)
or don't make sense (Open file).
Note that a refactoring is already in progress in order to
avoid to patch this library in master.
closesodoo/odoo#70110
Task-id: 2200168
X-original-commit: 39225827035efe11cdc90b2a7f1ae1f24a54b136
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
Signed-off-by: rfr-odoo <rfr-odoo@users.noreply.github.com>
Show digital signatures items in PDF.JS preview even if the signature
verification is not implemented.
From discussion in mozilla/pdf.js this is like this because they don't
want to give the user a false sense of "the digital signature has been
verified" when it has not, but for a preview of the PDF this seems
misleading, in any case the user can have a full fledged PDF reader and
know if the document is well signed then.
https://github.com/mozilla/pdf.js/ issues/4743
opw-2287840
closes#54922closesodoo/odoo#54988
X-original-commit: 820128385c523f562b9ee82698c81daa63149bb7
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Before this commit, when PDF viewer opens, it opens the sidebar forcefully.
Now with this commit, we have restricted to open the sidebar on initial load
by passing the false value to the forceOpen flag, we did this changes directly
in the library file itself as the file loads in iframe so we can not change the
file from outside by overriding the existing function or parameter.
task-2209742
closesodoo/odoo#47458
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
In the module account_invoice_extract, the the code need to react to the 'pagerendered' event triggered by pdf.js. However in recent version of pdf.js, event are not visible outside of the library, except if the 'eventBusDispatchToDOM' has been set to true.
We tried to set this option from outside of the library but without success, as our pdf viewer is in an iframe.
There is no state of the iframe in which we can add an event listener to set the option.
pdf.js has an event used to signal when we can set settings, called 'webviewerloaded'.
This event is triggered in an EventListener attached to the 'DOMContentLoaded' event.
So, to list options we had, we could:
a) add an eventListener to the iframe document or window to react to 'webviewerloaded'. This doesn't work as document and windows are not the definitive ones and won't catche the event later.
b) add an eventListener to the iframe to react to 'DOMContentLoaded', which doens't work too as our listener will be called after the pdf.js one.
Finally the option was choosed to modify the default value of this option directly in pdf.js as no hook worked in the
'account_invoice_extract' module.
closesodoo/odoo#47024
X-original-commit: 42e6f56c887c3175c76f0f84b8581e288ebc7daf
Related: odoo/enterprise#9044
Signed-off-by: Florian Daloze (fda) <fda@odoo.com>
after this commit:
Worker disable is no longer supported by pdfjs since version 2.0, so
remove disabling worker code.
Used pre-built version of pdfjs as source version dependency with other
lib like SystemJS and we can not add dependency of these libs, so used
pre-built version which don't require any other dependent lib.
pdf.worker.js is always loaded and as we are using pre-built version we
don't need odoo's loader, previously we need it because worker loader of
pdfjs was loading files separately so to avoid it as we were loading
files in asset bundle we had odoo's loader file but we don't need it
anymore.
task-2124443
Today, Odoo is really tricky to use without seeing the screen, it must be improved to be usable.
This PR forbid to use labels without a "for" attribute, add some title, rule and aria attributes in HTML. With that, Odoo will be fully usable with a screen reader.
* [IMP] Labels must have a for attribute. Improve accessibility.
* [IMP] Better error message when trying to read a missing cached value
* [FIX] Add some aria-label and title attributes for screen readers.
* [FIX] Template name is not included in the error message in case of SyntaxError in QWeb
* [FIX] Improve the Tour failed at step error message to be more explicit.
* [IMP] Add aria-labels
* [FIX] Add missing aria-label on failing test
* [IMP] aria-hidden means hidden. Fix all bad aria-hidden and hide aria-hidden for all.
* [IMP] Color names on kanban views and many2many tags
* [IMP] Add some checks on views for accessibility.
* [IMP] Add `alt` attribute on `img` tags.
* [IMP] Add aria-label and title on non-described icons
* [IMP] Add button role to widgets with btn class
* [IMP] Translate aria and formatted attributes.
* [IMP] Remove wrong aria-labelledby
* [IMP] Add menu role on dropdowns
* [IMP] Buttons must be focusable
* [IMP] Add aria attributes on progress bars
* [IMP] Improve accessibility of basic widgets
* [IMP] Change main layout to more semantic tags
* [IMP] Add menuitem role when missing
* [IMP] Remove wrong role='presentation'
* [IMP] Improve accessibility of tab panels
* [IMP] Add aria-invalid on invalid fields
* [IMP] Add aria-sort on ordered columns
* [IMP] Add role on alerts
* [IMP] Use dialog role, header, main and footer tags for modals
* [IMP] Add labels on o_status
* [IMP] Improve accessibility of kanban view with feeds and articles
* [IMP] Add alerts in case of new messages
* [IMP] Add widget, navigation or img role to aria-labelled items