Commit Graph
15142 Commits
Author SHA1 Message Date
Pierre Paridans 08030d3409 [FIX] web: allow this test to pass on both newer & older Chrome
This commit should be reverted once Chrome has been upgraded to v97+ on
Runbot.

closes odoo/odoo#92921

X-original-commit: abac4e9eb4be8e31f776d745ad1fd19a310c608f
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2022-06-03 21:33:00 +02:00
Bruno Boi 15d642ef73 [FIX] web: failing parseDateTime test in Chrome97+
Since Chrome 97+ some assertions in a parseDateTime test was failing.

This commit adapts these assertions as the behavior in this browser
version is more sensible.

X-original-commit: 866133f5b292ae17b68e1e593cf4c9a29f7e8839
Part-of: odoo/odoo#92921
2022-06-03 21:32:59 +02:00
Julien Castiaux fc115ebdf7 [FIX] web: invalid image placeholder resizing
Access `/web/image/82303?height=16`, traceback because the placeholder
image cannot be resized to `"16"`.

closes odoo/odoo#92891

Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-06-03 18:34:49 +02:00
Ivan Yelizariev ffa26fbee9 [FIX] web: fix typo in menu "My Odoo.com account"
It was introduced on js refactoring in v15

closes odoo/odoo#92825

X-original-commit: 4dd941150aba0a11f1fb9c604ce11a149018f97a
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
2022-06-03 16:41:06 +02:00
Gorash 0452d0701f [IMP] website: remove cache from website.page
The cache placed on the pages is no longer useful thanks to the use of
the new directive t-cache.

closes odoo/odoo#88276

Related: odoo/enterprise#27582
Related: odoo/documentation#2056
Related: odoo/upgrade#3451
Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
2022-06-03 16:40:40 +02:00
Gorash b0a2a41d78 [IMP] all/website: using lazy values and t-cache in templates
Using lazy values allows you to not do query when the content is not
displayed or if it is already cached. Adding `t-cache` only reduces
render time, but combining it with lazy values saves browses, computes
and query.
Thus for the `/shop` page the page is displayed in 60ms (before: 250ms).

Part-of: odoo/odoo#88276
2022-06-03 16:40:40 +02:00
Leonardo Pavan Rocha 2ac2d5ef1f [IMP] sign: makes automatic signature default
In order to make the process of signing faster, automatic mode should be the
default one. This commit implements this behavior and adds tests for it.

task-2862209

Part-of: odoo/odoo#92340
2022-06-03 12:02:17 +02:00
Sébastien Theys 44c4e5b3d0 [IMP] mail: properly destroy bus and messaging service in tests
This will reduce memory leaks in tests.
Indeed `destroy` is not a standard service method, it must be called manually.

And references to messaging service were unnecessarily kept in env.

Note: ideally everything should be cleaned this way, not just messaging code.
In other words, env itself should have no retainers at the end of each test, but
completely removing all of them is a much bigger work that is outside of the
scope of this PR.

Part of task-2850875

Part-of: odoo/odoo#90934
2022-06-02 18:58:27 +02:00
Lucas Perais (lpe) b7ce395a47 [IMP] web: qunit: debug doesn't completely finishes the test
Added debugTestId url searchParam that executes that test in debug mode.

While in debug mode, one can fully interact with it, and the console logs
the test's internal state.

closes odoo/odoo#92770

Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-06-02 16:54:30 +02:00
Hubert Van de Walle (huvw) a499263dd3 [FIX] web: mail.MessagingMenu isn't always added in the systray
Steps to follow

  - Use chrome
  - Connect to a runbot with the demo account
  - After a couple refreshes, the mail.MessagingMenu isn't displayed

Cause of the issue

  The navbar should be updated when there is a new item added to the systray registry.
  For that, the navbar listen to the update event with the `useBus` function.
  `useBus` itself uses `useEffect` which only starts listening after a component has been mounted/patched.
  -> The update callback is never called in this case because new items are added before the callback is registered.

opw-2801467

closes odoo/odoo#92768

X-original-commit: c2fd26881ceae95417e2a0afc71fdf8567e3b8c0
Signed-off-by: Samuel Degueldre <sad@odoo.com>
Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
2022-06-02 16:54:25 +02:00
Géry Debongnie 362f6b6d5b [IMP] web: update owl from 2.0.0-beta-7 to 2.0.0-beta-8
Release notes:
https://github.com/odoo/owl/releases/tag/v2.0.0-beta-8

Fixes
-----

- portal: allow use of expression to describe portal target
- compiler: fix issue with identifiers with same name
- reactivity: fix memory leak
- app: validate props for root component in dev mode

Improvements
------------

- component: display nice error for wrong child component
- props_validation: have clearer error messages
- component: only useState on props that are already reactive
- compiler: add better support for "in" and "new" operators in templates
- misc: export the validate function
- app: add setting to warn if no static props object
- add static App.registerTemplate and update Portal to use it
- add basic infrastructure to buid owl-runtime without compiler

closes odoo/odoo#92599

X-original-commit: 7fc0cc7c3f1c770dd80e8c3f3316c249d0708fe4
Related: odoo/enterprise#27916
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-06-01 11:02:40 +02:00
Aaron Bohy 4f884b1c37 [REF] web: merge mock server tests into one file
Also lint the mock_server file.

closes odoo/odoo#92539

Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-06-01 08:51:50 +02:00
Julien Castiaux da8def8e41 [IMP] core, web: Delegate delivery of static files
Rationnals
----------

Web servers can serve some resources (e.g. static files) right away
without any interaction with the web application. The network model of
most web servers makes them capable of handling thousands of
simultaneous requests when it comes to intensive IO operations such as
streaming data from a file. The network model of Odoo is different: it
is capable of a lot of processing power but can only serve a handful of
requests at a time, i.e. Odoo (with some help from postgres) is
optimized for CPU operations, not IO.

Some users don't configure their web server, they use a basic
configuration that relay all requests to Odoo. The result is that many
Odoo HTTP Workers can be busy streaming static files instead of
processing other requests. This can lead to a worker starvation, i.e.
all workers are busy streaming files and cannot process new requests.

X-Sendfile
----------

In this work, we add the support for the [X-Sendfile] header family,
they are multiples http headers that can be used by the web application
to communicate with the web server in order to delegate the delivery of
files stored on the file system. Odoo still receives the request but it
does no more stream the file content from within its HTTP worker,
instead it skips the response body altogether and sets the `X-Sendfile`
special header with the path of the file on the filesystem. The web
server intercepts that special header, open the file and stream it.

Using those headers, we can use the best of both the web application and
the web server. The web application is still responsible to locate the
resource and verify the access rights, the web server is still
responsible of streaming the content.

Using X-Sendfile is opt-in via the `--x-sendfile` CLI flag. We set both
`X-Sendfile` (apache) and `X-Accel-Redirect` (nginx). If you are using
apache, make sure `mod_xsendfile` is enabled. If you are using NGINX
you have to add the following location block:

    location /web/filestore {  # custom path, hardcoded within Odoo
        # Prevent access from the outside world, i.e. makes this
        # route only accessible via X-Accel. MANDATORY!!!
        internal;

        # Give access to the filestore using this server's
        # permissions. Odoo is in charge of verifying the access
        # rights.
        alias /path/to/odoo/data-dir/filestore;
    }

The Odoo [deployment documentation] has been updated accordingly.

[X-Sendfile]: https://www.nginx.com/resources/wiki/start/topics/examples/xsendfile/
[deployment documentation]: https://www.odoo.com/documentation/master/administration/install/deploy.html#serving-static-files-and-attachments

Changes to the API
------------------

To benefit most from X-Sendfile, all APIs related to streaming content
over HTTP has to be adapted. They are: (1) `request._serve_static`,
(2) `ir.http._serve_fallback`, (3) `/web/content` and (4) `/web/image`.

Each used it own way to deliver content: (1) `_serve_static` was using
`send_file` (flask's send_file that as been vendored with odoo 10
years ago and not maintenained since then), (2) _serve_fallback was
handcrafting a `werkzeug.wrappers.Response`, (3) /web/content-image were
using the "binary server" `ir.http.binary_content` API.

I has been decided to remove all 3 APIs and to merge the code inside of
the new `http.Stream` object and the `ir.binary` helper model.

A Stream wraps what is going to be sent to the browser, it can be a path
to a file on the locale filesystem, a blob of raw data or an URL to an
external resource. The Stream also holds various metadata that are
mainly used for caching. The preferred way to create a Stream is via one
of its three factories so that all the metadata are set. The factories
are: `from_path`, `from_attachment` and `from_binary_field`. A stream
instance exposes a single method `get_response()` used to create the
corresponding HTTP response object out of the stream.

Inside of `ir.http` were a few methods that were not related to the http
routing and formed what was called the "binary server". All those
methods have been removed and the feature have been refactored inside of
the new `ir.binary` model. The removed methods are:

- `_xmlid_to_obj`
- `_get_record_and_check`
- `_binary_ir_attachment_redirect_content`
- `_binary_record_content`
- `_binary_set_headers`
- `binary_content`
- `_response_by_status`
- `_get_content_common`
- `_content_image`
- `_content_image_get_response`
- `_placeholder_image_get_response`

The new `ir.binary` abstract model exposes the following utilities:

**`_find_record`**

Find an attachment or a record with a binary-field out of an xmlid or
out of a pair record-model/record-id. Check the access rights and the
access token.

**`_get_stream_from`**

Create a Stream from an attachment or a record with a binary-field.

**`_get_image_stream_from`**

Same as `_get_stream_from` but adapted for images. It sets a sensible
ETag on the stream and has image resizing support.

**`_placeholder`**

Get the image placeholder blob.

Testing
-------

It is possible to test the web server configuration using the
`test_http` module. Install the module then run the unittest using the
`webserver` test-tag. By default it attempts to connect to a web-server
running on `http://localhost:80`, you can change this URL by setting the
`WEB_SERVER_URL` environment variable.

    odoo-bin -i test_http --stop-after-init
    WEB_SERVER_URL='http://localhost:80' odoo-bin --test-tags webserver --stop-after-init

closes odoo/odoo#88134

Task: 2801675
Related: odoo/documentation#2083
Related: odoo/enterprise#26191
Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-06-01 02:53:59 +02:00
Benoit Socias 76eb6e6c74 [IMP] web, web_editor: exclude assets from documents
Currently only the `*.assets_*` CSS and JS files are considered as
assets. Because of this some assets from `web_studio`, `pos` and
`document_spreadsheet` become available for selection as documents.

This commit replaces the existing blacklist by a check on whether the
URL matches `/web/assets/*`.

Steps to reproduce:
- Install website, web_studio and pos.
- Drop a Text - Image block in the home page.
- Replace the Image.
- Go to the Documents tab.
=> Some JS/CSS/map assets were available for selection.

task-2799866

closes odoo/odoo#89151

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-05-31 19:16:59 +02:00
Rémi RahirandLucas Lefèvre d090d449d5 [FIX] web: mocked name_get should return "" instead of "False"
Since 43474916 and ff37a2fe, the function `name_get` now returns an
empty string for missing records. This change was not reflected in
mockServer.

This commit also copies the tests of `name_get` on  the legacy mockServer
to the "new" one. They were missing.

closes odoo/odoo#92473

X-original-commit: 638fab65cdf7a615138dee1395f54224b3ea1e77
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Co-authored-by: Lucas Lefèvre <lul@odoo.com>
2022-05-31 10:04:17 +02:00
tsm-odoo 3573a7fef4 [IMP] mail, *: use wowlEnv instead of the legacy one
*: bus, calendar, hr, hr_holidays, im_livechat, mail, mail_bot, note, project,
sms, snailmail, test_mail, web, website_livechat, website_slides.

task-2582313

closes odoo/odoo#83774

Related: odoo/enterprise#26493
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-05-30 19:40:53 +02:00
Paul Morelle f7494a914d [IMP] web: add stacklevel to DeprecationWarning
bcf665a291 introduced this deprecation warning without a stacklevel
argument. Adding it makes the error highlighted precisely where the
deprecated import occurred.

closes odoo/odoo#92420

X-original-commit: 9c01ab0deec4b82c60d8f942c39f2ca33aa42afd
Signed-off-by: Julien Castiaux <juc@odoo.com>
Signed-off-by: Paul Morelle <pmo@odoo.com>
2022-05-30 13:24:23 +02:00
xlu-odoo bf57a5ae35 [REF] web: ExportDialog revamp
This commit simplifies the SCSS of the export dialog.

task-2816763

closes odoo/odoo#88008

Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2022-05-30 10:34:45 +02:00
Denis Ledoux 2c7b10ed56 [FIX] ir.ui.view: do not inline automatically form views
odoo/odoo#87522 introduced the concept to automatically
inline tree, kanban and form views under one2many/many2many fields
within form views.
The goal being for the web client to make less `get_views` calls.

However, currently, automatically inlined form views
under one2many/many2many fields leads
to more triggered onchanges than before,
triggering more field computations than before,
potentially leading to performance issues
as more fields are computed than before.
Besides,  they are not visible in the tree/kanban view
and their computation can therefore be considered useless.

At worst, it can even causes bugs, by triggering computation
in places they were not used / do not handle correctly,
as explained in
https://github.com/odoo/odoo/pull/87522#issuecomment-1132554918
odoo/odoo#91878

This revision reverts the behavior to automatically inline
form views, while keeping the inlining of kanban/tree views.

However, by reverting this, we re-introduce a limitation
of the web client behavior regarding onchanges,
explained in odoo/odoo#91935.

This is therefore not perfect,
but at least the previous behavior is back.

In the future, work will be done to re-introduce the automatically
inlined form view, while solving both issues:
 - Do not trigger more onchanges than necessary,
 - Solve the limitation of the web client shown in odoo/odoo#91935

closes odoo/odoo#91968

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-05-27 11:45:47 +02:00
Géry Debongnie 2507e8d5d3 [IMP] web: add a way for kanban view to declare action
It is very common when using kanban view to need a way to declare what
action is executed when clicking on a record.  The default action
(switching to form view) is sometimes not what we would like. For
example, clicking on a project kanban record should open the
corresponding tasks, instead of the project form view.

Until this commit, it was not possible to do this simply for a whole
kanban record, however it was possible to add a button with a name and
type attribute to specify the resulting action.  This commit introduces
the same idea, but on the complete kanban record, instead of just a sub
element.

To specify the action that should be executed when clicking on a record,
one can now use the 2 attributes 'action' and 'type' (which corresponds
to the 'name' and 'type' attribute for the kanban record. 'name' was
also considered, but it was too weird). For example:

<kanban default_order="name" action="action_brand_model" type="object">
   ...
</kanban>

Part-of: odoo/odoo#92071
2022-05-25 20:31:41 +02:00
Brieuc-brd eaefb789e0 [IMP] web: bs5 utility-classes, add font-size
Define "Bootstrap v5 ready" utility-classes to handle font-size.
These classes definitions can be safely removed after migrating to v5.

task-2838625

Part-of: odoo/odoo#90476
2022-05-25 18:00:57 +02:00
xlu-odoo 9b98352f5f [IMP] web: bs5 utility-classes, add border-width
Define "Bootstrap v5 ready" utility-classes to handle border-width.
These classes definitions can be safely removed after migrating to v5.

task-2842691

Part-of: odoo/odoo#91298
2022-05-25 14:37:49 +02:00
Pierre Paridans f7f07ef6e5 [FIX] web: test breaking in newer Chrome due to rounding issue
Since (at least) Chrome 94+, some element's sizing computation returns a
slightly different value (in the order of a fraction of a pixel). Sadly,
due to rounding, this difference has an impact on exact sizing assertion
(specifically in the list view column sizing tests).

As the difference is *really* small, introducing a margin of error (i.e.
<= 1px) looks reasonnable ; as implemented in this commit.

closes odoo/odoo#92203

Forward-port-of: odoo/odoo#92066
X-original-commit: 5f0353814fc314b75a34a38e700bd7f0797dd18d
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2022-05-24 18:10:31 +02:00
FrancoisGe 321d687a2f [FIX] web: tests: patchDate use the offset fixed in luxon
Before this commit, patchDate used the machine offset and not the offset
fixed in luxon.

For example:
    Date to Patch = 01-01-2000 10:30:00
    Machine offset = -120 (UTC-2)
    Luxon offset = 360 (UTC+6)

Before:
    Patched Date = 01-01-2000 10:30:00 UTC-2

After:
    Patched Date = 01-01-2000 02:30:00 UTC-2

closes odoo/odoo#91591

Signed-off-by: Bruno Boi <boi@odoo.com>
2022-05-24 17:08:53 +02:00
FrancoisGe 646371b705 [IMP] web: tests: add patchTimeZone in test utils
This commit adds a testing utility function that applies a fixed time
zone to luxon based on an offset to the UTC time zone.

Part-of: odoo/odoo#91591
2022-05-24 17:08:53 +02:00
Jeremy Kersten 87fd20c9b4 [FIX] web: show datetime localized in Metadata view from debug menu
Before this commit, the dialog 'View Metadata' open the date in utc since the
refactoring of Owl. It is not coherent with all others dates shown in form.

Now we show the date in the timezone of the current user.

Part-of: odoo/odoo#92108
2022-05-24 12:48:01 +02:00
Jeremy Kersten df4782164f [IMP] web: allow to create ExternalId from the debug manager
Now, if you don't have ExternalID for the current record when you open the
'View Metadata' submenu from the debug menu, we add a button to create one.

Part-of: odoo/odoo#92108
2022-05-24 12:48:00 +02:00
Achraf (abz) daec4e6694 [IMP] web: Update Luxon to 2.4.0 version
closes odoo/odoo#92036

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-05-24 09:41:31 +02:00
Achraf (abz) eb9b28b2f8 [FIX] web: Allow user to display demo data in Vietnamese
Install the CRM app and the Vietnamese locale
Go to the CRM App > Reporting > Activities
Switch to Vietnamese (User icon > Preferences > Language)
The following error will appear :

```
UncaughtPromiseError > TypeError
Uncaught Promise > Cannot read properties of undefined (reading 'length')
TypeError: Cannot read properties of undefined (reading 'length')
    at parseDigits (http://localhost:8069/web/assets/debug/web.assets_backend.js:32038:31) (/web/static/lib/luxon/luxon.js:5117)
    at Object.deser (http://localhost:8069/web/assets/debug/web.assets_backend.js:32084:21) (/web/static/lib/luxon/luxon.js:5163)
    at match (http://localhost:8069/web/assets/debug/web.assets_backend.js:32423:37) (/web/static/lib/luxon/luxon.js:5502)
    at explainFromTokens (http://localhost:8069/web/assets/debug/web.assets_backend.js:32591:20) (/web/static/lib/luxon/luxon.js:5670)
    at parseFromTokens (http://localhost:8069/web/assets/debug/web.assets_backend.js:32614:30) (/web/static/lib/luxon/luxon.js:5693)
    at Function.fromFormat (http://localhost:8069/web/assets/debug/web.assets_backend.js:33592:30) (/web/static/lib/luxon/luxon.js:6671)
    at parseDateTime (http://localhost:8069/web/assets/debug/web.assets_backend.js:5814:32) (/web/static/src/core/l10n/dates.js:282)
    at parseDate (http://localhost:8069/web/assets/debug/web.assets_backend.js:5743:12) (/web/static/src/core/l10n/dates.js:211)
    at http://localhost:8069/web/assets/debug/web.assets_backend.js:20162:28 (/web/static/src/views/helpers/sample_server.js:460)
    at http://localhost:8069/web/assets/debug/web.assets_backend.js:10968:19 (/web/static/src/core/utils/arrays.js:96)
```

This is a issue with luxon
Issue: https://github.com/moment/luxon/issues/1169
Luxon update (2.4.0): https://github.com/moment/luxon/releases/tag/2.4.0
Fix: https://github.com/moment/luxon/pull/1194

PR to update luxon to 2.4.0 in master: https://github.com/odoo/odoo/pull/92036

closes odoo/odoo#92109

X-original-commit: 354433e7ba5b5f81f83368e497a8bed5059c91d5
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Achraf <abz@odoo.com>
2022-05-23 22:25:53 +02:00
Abdelouahab (abla) 37255ab4b9 [FIX] web : set color to match background
To reproduce
============

- choose boxed layout as document layout in settings
- enable packages in inventory
- set Incoming Shipments of warehouse on 3 steps
- enable detailed operations of *PACK* operation
- create a pack transfer
- in detailed operations tab, set destination pack
- validate the transfer and print the delivery slip

on PDF the line of destination pack is white text on clear gray (unreadable)

Purpose
=======

on that line two style classes are applied and both of them are changing the background color,

`.o_line_section` :
https://github.com/odoo/odoo/blob/9ce6136be700ae426b8910efd2357d16e2f49d7d/addons/web/static/src/scss/layout_boxed.scss#L61-L64
`.page > table:not(.o_main_table) tr td:last-child` :
https://github.com/odoo/odoo/blob/9ce6136be700ae426b8910efd2357d16e2f49d7d/addons/web/static/src/scss/layout_boxed.scss#L73-L75

We are taking the background color from one and the text color from the other one that don't match.

Specification
=============

to solve the issue we set the text color on `.page > table:not(.o_main_table) tr td:last-child` so that when this style class is
applied it has it's own text color, that matches the background, and doesn't take it from an other class.

opw-2841460

closes odoo/odoo#92096

X-original-commit: 4ee580d32f88fa9a13775355c75503678369c421
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
Signed-off-by: abla001 <abla@odoo.com>
2022-05-23 18:36:03 +02:00
FrancoisGe ac66c26097 [IMP] web: CP add custom placeholder by namespace
This commit adds the possibility to have a custom placeholder in the
command palette depending on the namespace.

closes odoo/odoo#91947

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-05-23 08:30:04 +02:00
Mathieu Duckerts-Antoine 01d7f98e24 [IMP] web: search: domain evaluation uses action context
It is now possible to get access to the action context keys when the
search filters are evaluated. This means that a search arch filter like

    <filter name="my_filter" domain="[('my_field', '=', context.get("my_value))]"/>

can be safely evaluated if "my_value" is in the action context (or in
the user context or is builtin as before).

closes odoo/odoo#91959

Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-05-20 21:09:00 +02:00
Simon Genin (ges) 8c3307a6b5 [FIX] web: fix field view get debug menu item
closes odoo/odoo#91943

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-05-20 16:46:09 +02:00
Pierre Paridans 90e65f9762 [FIX] web: <details> visiblity check regression in Chromium 97+
Since Chromium 97, folded `<details>` content has non-zero computed
width and height which returns false-positive QUnit
`assert.isNotVisible()` calls.

In a nutshell, this was introduced in https://bugs.chromium.org/p/chromium/issues/detail?id=1185950
when Chromium implemented the ability for "Find in page" to search in folded
`<details>`. To do so, the `content-visibility` rule was used instead of
`display: none` which, even if functionally similar, has an impact on the
values returned by `getBoundingClientRect()` (i.e. used in
`assert.isNotVisible()`.

A regression report was filled in https://bugs.chromium.org/p/chromium/issues/detail?id=1276028
to highlight this change of behavior. What emerged from this report's
discussion is that Chromium has no intent to revert this change and
instead put the emphasis on avoiding to use `getBoundingClientRect()`
and similar methods for visibility check (even pushing a proposal for a
`Element.isVisible()` API; cf. https://github.com/w3c/csswg-drafts/issues/6850).

This commit works around this issue by forcing the content to `display:
none`, like in the previous Chromium versions.

closes odoo/odoo#91833

X-original-commit: b718e7eb5ceb827f59ac395577408b7bc54aa3f9
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2022-05-19 19:04:59 +02:00
tsm-odoo 3c10fcadee [IMP] mail, web: allow ui size patching during tests
Until now, when we add to patch the ui size, we would have patched one of the following:
	- config.device.{isMobile,size_class}
	- (wowl) env.isSmall / env.services.ui.{isSmall/size}
	- (legacy) env.device.isMobile
	- (legacy/wowl) browser.innerWidth

The issue is that patching one does not affect the others resulting in an incoherent state.
In order to ease ui size patching, the `patchUiSize` method has been introduced. This method
take either a size or a width as parameter (eg. SIZES.SM, 1920) and affect all the properties above.

task-2582313

closes odoo/odoo#91540

Related: odoo/enterprise#27428
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-05-19 16:40:12 +02:00
Yolann Sabaux dc8cf87fc8 [FIX] web: fetch right company_id
Steps to reproduce:
- Have two companies set up
- In settings, check for company 2 the Files Centralization
- For a Product, upload a document

Issue:
The document will not appear in Documents.
It will only appear if the option is checked for company 1

Cause:
The company_id is not fetched correctly throughout the process.
There is a similar solution for the specific `documents` upload route:
https://github.com/odoo/enterprise/blob/bdf712d66c3e5cee70a6b424b69a618fe655a39f/documents/controllers/main.py#L147-L149

Solution:
Get the id directly from the cookies

opw-2774365

closes odoo/odoo#91751

X-original-commit: 46db92d5211c215d07448676e619154390b7147f
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: yosa-odoo <yosa@odoo.com>
2022-05-19 13:45:05 +02:00
momegahed 85ab969f6a [FIX] web: url to ping the server is incorrect
If applied, this commit will fix the following bug by fixing
the url used to ping the server

Steps to reproduce:

1- open apps with debug mode
2- click on updates
3- the server is read as if it is offline

Bug:

in ecfe85db84 all links are changed
static/src/(img|fonts) => static/(img|fonts) however in this specific
 case the server is remote
(https://apps.odoo.com) and it still needs /src/

Fix:
add /src to the url

OPW-2791531

closes odoo/odoo#91112

X-original-commit: bf629cf3063119a5c819f74329a51a0e1a7c172f
Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-05-19 12:28:12 +02:00
Hubert Van de Walle (huvw) a478a9e906 [FIX] web: boolean_toggle widget ignores readonly attribute
The boolean_toggle should only be disabled when there is a readonly
modifier, not when the view is in readonly mode.

Cause of the issue

  The input was disabled but the `_onClick` was registered on the
  widget root node.

Solution

  - Listen for clicks on the input element
  - Override the render method to set the disabled prop according to the
    readonly modifier.

opw-2739468

closes odoo/odoo#91601

X-original-commit: 29a2402153dc95414dad8c833487e7dd18c8a222
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
2022-05-19 11:13:51 +02:00
Leonardo Pavan Rocha 3bec61a95b [IMP] calendar: improve day/year/month/year view selection
Instead of having 4 buttons to select a view in calendar, we start using a
dropdown button with the framework data-hotkey approach.

task-2704432

closes odoo/odoo#81705

Related: odoo/enterprise#23131
Signed-off-by: Arnaud Joset <arj@odoo.com>
2022-05-18 19:31:20 +02:00
tsm-odoo 52d6089e1a [IMP] mail: replace env.browser by wowl browser
This PR prepares the ground for the one introducing the new environment in the discuss app.
Indeed, switching from `env.browser` to the wowl `browser` makes a lot of noise in the main
PR. In order to reduce this noise, this change is done now.

task-2582313

closes odoo/odoo#91622

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-05-18 13:08:22 +02:00
Camille Spiritus e8776485b4 [IMP] account: align delivery and recipient adresses on invoices
Since 15.2, when creating an invoice containing both a recipient address and an invoice address, the addresses would both appear on the left, one after the other.

This made reading difficult and the invoice unclear.

Furthermore, the company address wasn't present by default on the invoice : it was only there if a layout had previously been selected.

This PR:
- reverts the behaviour of the company address, i.e. it appears even if no layout is (yet) selected ;
- aligns the delivery and the recipient address on each side of the page when necessary, while not changing the outcome if a single address is given.

Also displays a "title" above the addresses when necessary to make things clearer.

task-2809240

related : https://github.com/odoo/enterprise/pull/27240

closes odoo/odoo#91487

X-original-commit: 1e745256fabbec4d6979180d8f792c99be463509
Related: odoo/enterprise#27383
Signed-off-by: Florian Gilbert <flg@odoo.com>
2022-05-17 16:03:16 +02:00
dht-odoo 3b3423d638 [IMP] web,crm: show sum of MRR on leads' kanban progress bar
This commit shows the sum of field 'recurring_revenue_monthly' on
leads' kanban progressbar next to the sum of 'expected_revenue',
if the recurring revenu is enabled for logged in user.

taskID-2414576

closes odoo/odoo#66237

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-05-17 16:03:03 +02:00
stefanorigano (SRI) 782047917f [FIX] web: cp's search menu-items, highlight design
As result of [1], control panel's search menu-items were highlighted
correctly on ':hover', but not using a keyboard.

This commit assigns the default <Dropdown> 'focus' class on both
circumstances.

[1] https://github.com/odoo/odoo/pull/87448

task#2852217

closes odoo/odoo#91206

Related: odoo/enterprise#27355
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2022-05-16 17:32:56 +02:00
Pierre Paridans 8ed9d667fe [FIX] web: Dialog footer buttons' spacing
Before this commit, some dialog's footer buttons were glued to each
other which impacted their readability and usability.

This commit fixes it by properly applying the existing `gap` CSS rule
which defined the spacing between the buttons, and this independently of
the structure of the footer.

Indeed, due to historical reasons, the `.modal-footer` may contain
drastically different structures depending of the kind of modal.

A non-exhaustive list of encountered structures:
- `.modal-footer > button`
- `.modal-footer > div > footer > button`
- `.modal-footer > div > button`

Note: some existing rules already illustrate that in `modal.scss`.

task-2792884

closes odoo/odoo#91371

X-original-commit: d15bfc785d392a7dffadf9489d1d21f449d42ca4
Related: odoo/enterprise#27337
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2022-05-16 10:09:42 +02:00
Laurent Stukkens (LTU) 1a8389858a [FIX] web: prevent access error in calendar
Prior to this commit:

- If the color attribute is set on a field on which the user might
  not have access to the model / record, a traceback is returned. However,
  in the case of a M2O, the name_get would be returned, so its is
  a pity that the color raise an access error.

After this commit:

- A search_read is made instead of a read, which returns nothing if
  the user does not have access to the model / record and does not raise
  a traceback.

closes odoo/odoo#91147

X-original-commit: 3e8744418d629a62e9eacd16dfa4721921e02453
Related: odoo/enterprise#27318
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-05-16 10:09:28 +02:00
Hardik Prajapati c0662dc68b [IMP] base{_geolocalize},project,web: usability improvements
purpose of the task is to improve the usability of the base,
base_geolocalize, project and web

task-2764760

closes odoo/odoo#85295

Related: odoo/enterprise#24706
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-05-15 15:29:55 +02:00
tsm-odoo c23f85903a [IMP] mail, *: use pyEnv in the mockServer
Now that pyEnv is available, using it in the mock_server lighten the syntax.

task-2582313

closes odoo/odoo#90783

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-05-13 11:59:58 +02:00
3cd87ca0dc [IMP] knowledge: add the template and file commands
This commit adds some commands that can be used in the html editor.

Editor Commands
---------------

Some new editor commands have been added:

- */article:*
This command is available on every html field using the Odoo Editor.
This command allows to add a direct link to the selected knowledge article.

- */file:*
This command is only available in the Knowledge App.
This command allows to add a file (or an image) download button inside the
body. The user can choose a file to add from its own file directory or an
existing attachment already present in the database.

- */template:*
This command is only available in the Knowledge App.
This command allows the user to create a block where them can write and lay out
content destined to be reused by the readers of the article. The lasts will be
able to copy and paste it to send it as message or use it as a description on
other records.
No /command can be added inside a template.

Technical notes:
/file and /template commands can be activated in other modules by adding
knowledge_commands = True on the html field in the view where they should
be activated.

Task-2674460

Part-of: odoo/odoo#82315
Co-authored-by: Damien Abeloos <abd@odoo.com>
Co-authored-by: Julien Banken <jbn@odoo.com>
Co-authored-by: David Beguin <dbe@odoo.com>
Co-authored-by: Fabio Barbero <faba@odoo.com>
Co-authored-by: Thibault Delavallee <tde@odoo.com>
Co-authored-by: Aurelien Warnong <awa@odoo.com>
2022-05-13 02:58:51 +02:00
661f98be3c [ADD] knowledge: manage knowledge
Purpose
=======

Allow companies to centralize all their knowledge in a specific place they own.
Create wiki-like pages to structure the information and make it easily
available. Leverage those later on while working in the back-end.

Specifications
==============

An article is mainly composed of a title and a body. The later is an html field
that can contain text, images, link to other articles or records from other
models, templates, etc..

Articles will be classified in 4 categories:

- *Workspace:*
The articles are available for each internal users in read or write access.
Only internal users can create, read, modify and delete knowledge articles.

- *Private:*
The articles are only available for the owner. Only internal users
can set an article as private. A private article can be shared to external users
in read access only. If the article is shared with internal users, see Shared
section.

- *Shared:*
The articles are not available for any user except the ones that have been
added as members on it. For the current user, this section contains all the
private article the user shared with someone and all the other's private
articles shared with me.

- *Favorite:* (Additional category for UX)
Articles can be set as favorite and are user specific. Any identified user can
set an article in favorite, as long as the user has access to it. Public users
cannot add articles to favorites. Favorites can be reordered and this ordering
is user specific.

An article can have a parent and multiple children. Each parent and each
children is also an article. Root articles are the highest parent in the
hierarchy and are considered as the *Subject* (aka Topic) of their whole
hierarchy. There is no limit on how many levels there are in the hierarchy.

In the 3 first categories, the articles are listed starting for the root
article. The child articles are listed below their parents only if the user has
access to them. It can be that a user has access to an article that is not
listed in knowledge main view because that user has no access to the parent
article. More information about access below.

Categories are based on the root article. If a children is private, because only
accessible by 1 user, and its parent is accessible by everyone, the children
will be listed in Workspace section.

Technical notes

The following domains apply to assign root articles in the different categories:
- Private: permission 'none', only member = uid
- Shared: permission 'none', more than one member with read/write access
- Workspace: other
In addition, the UX category
- Favorite: is_user_favorite = True (can contain articles from any category)

Home View (backend)
===================

The main knowledge view is a tweaked form view that displays all the accessible
root articles and their accessible children in a side panel hierarchic tree.
This side panel allow quick access to each articles without having to navigate
back to a list or kanban view. This form view mainly displays the title and the
body but also integrate custom buttons to manage and search the articles.
All those buttons + the side panel are detailed below.

This "Home" view is loading displaying the first favorite article of the
user. If the user has no favorite, it falls back to the first root article of
Workspace section.

The default view mode depends on the user access:
- If user can read: readonly mode
- If user can write: edit mode

Search View
-----------

The standard list view will be used as an advanced search to find an article
that cannot be found easily via the command palette (ctrl+K). All the searching
options remains standard (search / filter / group by). Selecting an article in
that view will redirect to the home view (displaying the selected article).

Side Panel
----------

- *Reorder and hierarchy:*
From the side panel, drag and dropping an article can resequence the articles
between them and/or change the parent of the moved article.

Note on reordering:
Each parent have its own sequence for its children. So the sequence is not
common for each articles in the database, but specific for the children of a
same parent. The resequencing is done among the children of the same parent.
If some articles has no parent, there are considered as the root articles and
all root articles have their own sequence too.

- *Create:*
From the hierarchy tree, the user can directly create an article using the '+'
signs:
    - as root of Workspace or Private section
    - as a child of a target article.

- *Fold/Unfold:*
To speed up Home page loading: only first level is loaded + the articles that
user already unfolded in the past. The app keeps track of unfolded articles per
user (using Local Storage).

- *Icon:*
Each article has an icon associated with it. The user can click on the icon to
change it.

- *Search an article:*
This button opens the command palette to perform a search on articles.
More detail on this in the Advanced Feature section (below).

Article header and Button Menu
------------------------------

- *Breadcrumb:*
Located on the top left of the main view, the breadcrumb can be used to edit the
article title.

- *Favorite:*
Next to the title, a star button can be used to add/remove the article to/from
the favorite.

- *Create:*
Creates a new private root article.

- *Share:*
Opens the permission panel. This is where the user can configure the access on
the article or, if user has no write access, see what are the access rules on the
article. More detail on this panel in the Access Rules section (below).

- *Chatter:*
Toggle the chatter On/Off at the right of the article view.
There users can:
    - Send messages and log notes
    - Schedule activities
    - Follow an article

The following buttons can found in the kebab menu, in which we can also find
who created or edited the article last and when.

- *Move To:*
Opens a modal to select the parent under which the current article should be
moved. The article will be placed as the last children of the selected parent.

- *Lock:*
When activated, prevents all edition of the article content (body and title)
until it is unlocked. (Purpose: avoid accidental edits)

- *Duplicate:*
Creates a copy of the current article, under the same parent, but does not copy
the children articles. The new created article will have the same access rules
as the original article.

- *Archive:*
Will archive the current article and all its children. Archived articles can be
retrieved using the Advanced Search (see below for detail) with "Archived"
filter.

- *Full Width:*
By default, the article is centered in the view, to make it easier to read.
If needed, the can activate the full width. This will make the article body take
full width available on the article view. This option impacts the rendering of
article, also in the frontend view. More detail on the Frontend View below.

Body
----

The body is composed of an html field that can be edited using the Odoo Editor
and all its capabilities. Some new commands have been added to enrich the
editor: /template - /file - /article (More details in Advanced Features section)

At the top of the article body, the article icon and cover can be added using
their respective "Add" buttons.

- *Icon:*
Can be modified by simply clicking on it.

- *Cover:*
Can be modified using the "Pen" icon at the top left of the cover,
and deleted using the "Bin" icon at the top right.

Frontend View
=============

The frontend view is basically a simpler version of the backend view where users
can only read the article and add them to their favorites (if user is
identified).

The frontend view is composed of the side panel in the left, the article title
and favorite button on the top and the main body view.

From the side panel, the user can navigate to each available article, reorganize
them favorites and filter the articles using the search bar.

From the main body view, the user can consult the content of the article and
download eventual attached files from the '/file' sections.

Access Rules
============

Basics
------

The access is defined depending on two criteria:
- The Internal Permission
- The article members and their permission

Both have 3 level of permission:
- none (No Access)
- read
- write

The internal Permission is the base permission for internal users. By default,
all internal users can write on the article, unless the permission have been
downgraded to 'Read' or 'No access'.

An internal user however can be added as a member of the article with a
specific permission that applies only for them. This member permission takes the
priority on the internal permission.
The internal users will always be redirected to the backend view when they want
to consult an article.

By default, external users (portal or public users) cannot have access to the
articles, unless they have been added as member. They can only be invited with
read acces on the articles.
External users will always be redirected to the frontend view when they want to
consult an article they have access to.

An administrator (group_system) will always have write access, even if
permissions tell the contrary. However, only the articles they have the
permission to see or write on will be listed in the side panel. They can find
the other articles in the Advanced Search view.

Only the users with write access can edit the article body and title, reorder or
change the parents and children, invite members and edit the access rules of the
article.

- *Constraint:*
An article should always have at least one user having write access on it.

- *Lock mechanism:*
Only users with write access can lock or unlock the article.
when an article is locked, the title and body of the article cannot be edited,
even by a user with write access on it.

Access Inheritance
------------------

By default, a child article inherit the access rules from its parent.
That means that access rules can be defined on the root article and those rules
will apply for each descendant article (children and their own children, etc.).

However, a child article can have specific rules that will apply only on itself
(+ its descendant):

- *Synchronized:*
That can be done by adding a member on that article, or by upgrading any of the
permission based on its parent(s). In that case, the article access rules still
depend on its parent(s). If an additional member is added on the parent,
the child article will still inherit that member. The rules that applies
specifically on the child article have the priority on the inherited rules.

- *Detached:*
When an access rule is downgraded in a child article that initially depends on
parent's access rules, the article access rules are detached from the parent's
access rules. All the access rules that applied on the parent are copied on the
child article and that article is flagged as detached. The children of that
article will, for now on, only depend on it, and not on higher parents anymore.

An detached article can be resyncronized with its parent. In that case, all the
specific access rules that do not apply on its parent will be removed. The child
article will still keep its specific upgraded access rules but will, once again,
depends on its parent.

Share Modal (and access rules application)
------------------------------------------

The share modal (or permission panel) is where the access rules of an article
can be configured.

From there, a user with write access can:

- *Invite new members:*
A modal opens and the user can:
- add existing partners or type email addresses and create new partners
- select the permission that should apply on all selected partners.

If there are external users among the selected partners, only the read access
can be used. That means that if the user select:
- Write permission: the read permission will be given to that partner.
- No Access: The partner will not be added the members.

An invitation email is sent to the invited partner.
If the partner is already registered (has an active user), them can directly
access the article with the link provided in the email. They may need to log in
first.

If a partner is not yet registered (have no user), when using the link provided
in the email, them will be asked to register first, and will be afterwards
redirected to the article.

- *Modify the Internal Permission:*
The user can select the new permission to set for all internal users.

    - Special use cases:
        - If the user sets internal permission != write, the user will be added as
member with write access. The purpose is to let the user continue to edit the
article.
        - When downgrading internal permission on a child article (that depends on its
parent), detach it from parent in terms of access rules.
        - when upgrading internal permission on a child article, just set the
permission. The article is not detached from parent, but the article will use
its own internal permission to compute the user accesses.

- *Modify a member's permission:*
The user can select the new permission to set on the target member. The user can
also remove a member.

    - Special use cases:
        - When downgrading or removing a member based on parent: Detach the article
from it's parent
        - When upgrading a member based on parent: add a new member with the selected
permission.

Website Published (Access for public users)
-------------------------------------------

When the Website App is installed, users have the possibility to publish the
articles. When an article is published, everyone can read the article.

- *Internal users* can read a published article even if their permissions does not
allow them to read it. They can access those published articles like every other
articles, still in backend view.

- *Portal users* can read a published article even if their permissions does not
allow them to read it. They can access those published articles like every other
articles, still in frontend view.

- *Public users* can read a published article. They can access it by using the
article link from the frontend view.

Advanced Features
=================

Search and Advanced Search
--------------------------

- *Command Palette:*
Searching is done through the command palette. Just as we have '#' for channels,
'/' for menus and '@' for users, '?' has been added for articles.

The command palet is accessible by either
- Hitting CTRL+K (and then adding ? to search among articles)
- Clicking on the fa-book icon of the chatter, which already
adds the '?' so that one can start searching straight away.
- Clicking on the "Search An Article" button (in the side panel)
while reading another article, where the '?' is automatically added too)

The search result are ordered as followed:
My Favorites > Most Favorites > the rest.

The results display the article name + the subject (highest parent name).

If no results are found and user have write access, them can create a new
(private) article with the search query as title.

- *Advanced Search:*
If the user is not happy with the search results, them can do an
"Advanced Search", which sends me towards a normal Odoo list view where I can
search, filter, groupby, ...

Editor Commands
---------------

Some new editor commands have been added:

- */article:*
This command is available on every html field using the Odoo Editor.
This command allows to add a direct link to the selected knowledge article.

- */file:*
This command is only available in the Knowledge App.
This command allows to add a file (or an image) download button inside the
body. The user can choose a file to add from its own file directory or an
existing attachment already present in the database.

- */template:*
This command is only available in the Knowledge App.
This command allows the user to create a block where them can write and lay out
content destined to be reused by the readers of the article. The lasts will be
able to copy and paste it to send it as message or use it as a description on
other records.
No /command can be added inside a template.

Technical notes:
/file and /template commands can be activated in other modules by adding
knowledge_commands = True on the html field in the view where they should
be activated.

Technical considerations
========================

Access Rules Computation
------------------------

Articles access rules are based on inheritance from parent articles. Purpose is
to avoid making copies of all member rules on each article in the hierarchy.
This allows to lower database storage. The counter part is that the computation
of user accesses is made more complex. Instead of simply reading the article
internal permission and members permissions on the article, access is computed
based on each parent above the article.

To speed up batch compute, user permissions are computed directly with recursive
SQL queries. They collect all the needed information for multiple users (based
on their partner) and multiple articles.

Ordering on is_user_favourite
-----------------------------

To allow ordering on is_user_favourite computed field, the search method have
been overridden to add the favorite articles of the current user to the search
result. This is used in the advanced search view but will also be used in
the ctrl+K command.

Sequences and resequencing
--------------------------

Sequences in knowledge article does not respect the conventional sequencing
(one sequence for all the records of the model). Instead, the sequence is
specific for all children of same parents. Resequence had to be overridden to
take that into account and only resequence the children of same parent, and not
the entire table. Moving an article in the middle of a 'folder' should not
impact the other folders but only the children of that target folder.

Breadcrumb
----------

On the form view, the breadcrumb will be located in the control panel.
For the knowledge module, we needed a headless layout. In the mockup,
the breadcrumb has to be placed within the form sheet.

Unfortunately, the breadcumb is a owl component and its logic is
encapsulated in a function which makes it not editable.

To avoid having to update the core, we will render a custom breadcumb
that will be generated based on the `breadcrumb` parameter passed to the
`init` function of the form view.

Task-2674460

Part-of: odoo/odoo#82315
Co-authored-by: Damien Abeloos <abd@odoo.com>
Co-authored-by: Julien Banken <jbn@odoo.com>
Co-authored-by: David Beguin <dbe@odoo.com>
Co-authored-by: Fabio Barbero <faba@odoo.com>
Co-authored-by: Thibault Delavallee <tde@odoo.com>
Co-authored-by: Aurelien Warnong <awa@odoo.com>
2022-05-13 02:58:50 +02:00
Bruno Boi 551f894b03 [FIX] web: conflicting accesskey/data-hotkey attrs
Issue:
Sometime an element with an [accesskey] attribute could be triggered
through the standard mechanism (accesskeys) instead of the hotkey
service mechanism (elements with [data-hotkey] attributes).

Steps to reproduce:
- open a record on a form view with a pager
- open some dialog (without using the keyboard)
- use ALT+N => the pager behind the dialog switch to the next record

This comes from the browser default mechanism for elements with an
[accesskey] attribute.

The hotkey service should have taken over on this standard behavior but
it did not because of the dialog which became the UI active element.

NB: this occurs only on a certain set of browser/OS combination. See the
following table https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey#try_it

Before this commit:
The hotkey service would take over the accesskey standard behavior ONLY
inside the UI active element.

After this commit:
The hotkey service will always take over the accesskey standard
behavior, disregarding the UI active element.

closes odoo/odoo#91261

X-original-commit: 582963a6a18ea3a2e8d3e050af4978067bfe21e1
Signed-off-by: Bruno Boi <boi@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-05-12 20:18:58 +02:00