Commit Graph
6009 Commits
Author SHA1 Message Date
Xavier Morel 1a65d18ef7 [IMP] core: increase timeout in watch mode & tell client
Currently, when enabling watch mode on a tour the tour's timeout does
not change. This is usually an issue because:

- watch mode makes tours a bit slower, so they can timeout even
  without doing anything
- trying to diagnose what's wrong, it's common to add check steps with
  a long timeout or even a `debugger` statement, which trips the
  python-side timeout and kills the tour

To avoid needing to remember to update the timeouts (then revert them
afterwards), just bump the timeout to 1h by default, or 10x the
original time for very long tours (e.g. qweb test suite, which
currently has a 30mn timeout).

While at it, forward the watch mode status to the client via the QS,
so we can eventually make use of it for one reason or an other.

closes odoo/odoo#96994

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2022-08-01 07:32:39 +02:00
FrancoisGe a4df8804f4 [FIX] web: one2many contains at least 4 lines
An X2many always has at least 4 lines. If the X2many contains less
than 4 filled lines (Record or "Add a line") empty lines are added
to make up the difference.

For example, an X2many in edit mode containing only one record:
- Line containing a record
- Line containing "Add a line
- Empty line
- Empty line

closes odoo/odoo#97070

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-07-29 17:12:50 +02:00
Nicolas Lempereur 65a0eb7272 [FIX] base: fix autoresize and exclude gif
Odoo may resize attachment image with side larger than 1920 pixels.

But for animated gifs, this resizement seems to in general increase size
file which is not what we want (in some case making it grow from 3MB to
60 MB).

So with this change, we only resize and optimize images that are not
gifs.

Reasoning: pillow doesn't seem to resize GIF (and seems to only increase
their size, especially animated GIF, because each frame is not
optimized) so we should just not touch them.

Note:

- currently tiff were not resized (because of a mimetype typo)
- currently image dimensions were not resized (from our test, resizing
  on the dimension does not change the size much, quality is most
  important).

both of these issue have been solved in this commit.

opw-2897291

closes odoo/odoo#97083

X-original-commit: 6d903d61adba11c9e46009511fd4065dbc8a9e0c
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2022-07-29 15:53:43 +02:00
Laurent Smet fd764968b8 [FIX] base: Fix pdf generation for l10n_ch QR-bill
When printing the qr-bill for multiple records, we are no longer passing the code spliting the pdf for each record since 'attachment' is not checked on the qr-bill action report.

Bug introduced by:
https://github.com/odoo/odoo/commit/38e4a5fbc35b6089ec70b27e5ae74cc83c981a17

closes odoo/odoo#97050

X-original-commit: afaf7c1db4500c6115f119ff3592027e7b3b550d
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Laurent Smet <las@odoo.com>
2022-07-29 15:53:31 +02:00
Pierre Paridans 7d9faadc5c [FIX] web,base: switch to newly installed lang button color
Steps to reproduce:
- Open Settings
- Add Languages
- Select a language
- Click Add
=> Text in the "Switch to..." button is miss-aligned and color is
unreadable.

This commit fixes the alignment by removing an exception to the dialog
footer's buttons alignment selector which is no longer needed and to
avoid confusion between inner-fields and buttons container.

Also, it fixes the color by rendering the language name as a readonly
text instead of a link inside a button (sic).

closes odoo/odoo#97007

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2022-07-29 15:53:24 +02:00
Alvaro Fuentes 27854c787a [IMP] test_base: test add/remove implied groups
Given a recordset R of (at least two) groups, and a group A.
We want to ensure that:
* `R._apply_group(A)` adds A to the list of implied groups of _all_
  groups in R.
* `R._remove_group(A)` removes A from the list of implied groups of
  _all_ groups in R

This is especially problematic for config settings of the form
```
class MyConfig(models.TransientModel):
    _inherit = 'res.config.settings'
    group_imply_A = fields.Boolean('x',implied_group='A',group='B1,B2')
```
since activating the implication via `group_imply_A=True` currently
fails in case only one of B1,B2 already implies A.

opw-2832741

closes odoo/odoo#96928

X-original-commit: 81dc64740ba46355462ed2169e57fc0ce694ccdb
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: Alvaro Fuentes Suarez (afu) <afu@odoo.com>
2022-07-28 10:28:03 +02:00
Alvaro Fuentes af886f3673 [FIX] base: correctly apply implied groups
If one of the groups in `self` implies the group `implied_group` then
the rest won't be updated.

This also contradicts the way the settings are later checked (which is
correct) on
https://github.com/odoo/odoo/blob/f2c214e227db7c9ec2340ef87644f2f7c2e370c5/odoo/addons/base/models/res_config.py#L508

See 4f19f29a

opw-2832741
upg-356843

X-original-commit: 1754c744c8d00925d40c44742de3600389f7af47
Part-of: odoo/odoo#96928
2022-07-28 10:28:02 +02:00
Lin WenwenandJulien Castiaux c06cee44fe [FIX] base: serialization bug when acquiring cron
Start Odoo with multiple cron threads (e.g. --max-cron-threads=4),
trigger many crons at once, there is a chance one of the cron thread
fails due to a serialization error.

Inside of the `_acquire_one_job` function, the query evaluates many rows
to find one that fit multiple requirements. Two of those requirements
are (1) that the `nextcall` of the row is in the past or (2) that it
exists a cron trigger for that cron with a `call_at` in the past.

In case the `nextcall` of one of those rows is modified or the cron
triggers are removed by another transaction then there can be a
serialisation failure in the current transaction. This serialisation
error is important, it prevents the current cron worker from acquiring a
cron job that has been processed in another cron worker.

The problem is that that postgres doesn't tell which row was modified by
the other transaction (=processed by another worker cron) so it is not
possible to just skip that cron and continue with the others.

Our solution is to limit the WHERE clause of the `_acquire_one_job`
function to a single row. In case there is a serialization failure we
know the cron was processed in another job and we can skip it.

Closes #96584

closes odoo/odoo#96926

X-original-commit: 684750a0c2c83acffb32e555bd3140a2c76d7219
Signed-off-by: Julien Castiaux <juc@odoo.com>
Co-authored-by: Julien Castiaux <juc@odoo.com>
2022-07-28 10:27:58 +02:00
Xavier Morel e75f2989b4 [FIX] core, web: Pillow 9.1 deprecations
Pillow 9.1 deprecates most if not all toplevel Image constants:
https://pillow.readthedocs.io/en/stable/releasenotes/9.1.0.html#constants

These constants have been moved to thematic enum classes (e.g. all the
resampling constants in `PIL.Image.Resampling`).

This triggers warnings in Odoo, and the removal delay is quite short
(slated for Pillow 10, release planned mid 2023). Pillow 9.1 is also
already in Debian Bookworm (current testing).

Fix by shimming at the import level: if the enums are available import
them into the local namespace, otherwise alias `PIL.Image` itself as
to the enum.

closes odoo/odoo#96799

X-original-commit: 7be04d31bad078681ef0a2919234c11840a2e8e2
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2022-07-28 02:40:23 +02:00
Nasreddin Boulif (bon) 00fe2a4ba2 [FIX] base: retrieve last rates only from current company
Steps to reproduce:

  - Install accounting module
  - Ensure there is 2 companies
  - Activate both companies (with company switcher)
  - Go to Accounting -> Configuration -> Currencies
  - Select currency `EUR`
  - Add a rate and set second company as company
  - Disable second company (with company switcher)
  - Click on `Show Currency Rates` in action menu
  - Click on create

Issue:

  Access Error

Cause:

  Currency Rate model have a compute field `rate`.
  This last one calls `_get_latest_rate` that will retrieve the last
  rate for the currency. To do so, it will first retrieve all rates for
  the currency (that might include rates with company not same as the
  current one) before fitering regarding company.

Solution:

  Use sudo(). Same issue/fix for `_get_last_rates_for_companies`.

opw-2832708

closes odoo/odoo#96714

X-original-commit: dda5c9084b9913968e67c8b280de870c81227e16
Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com>
2022-07-27 21:21:40 +02:00
Xavier-Do 555ef06fa5 [IMP] tests: allow to disable auto retry
Auto retry can be usefull to avoid breaking a build because of a
small tour or query count, but for long tests like qunit, this can be
painfull when a real error is triggered.

This commit proposes to disable autoretry on demand for some tests
to solve this issue.

This may be applied on all tests longer than a few seconds.

closes odoo/odoo#95440

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2022-07-27 16:33:56 +02:00
arg-odoo ef5a9612f7 [FIX] base: avoid KeyError in res_partner._display_address
In some case, users use custom `address_format` with keys that do not
exists. This lead to errors in odoo and upgrade process. Avoid
`KeyError` by using defaultdict with `str` value.

upg-361146
upg-361241

```
Traceback (most recent call last):
  File "/home/odoo/src/odoo/14.0/odoo/service/server.py", line 1201, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/home/odoo/src/odoo/14.0/odoo/modules/registry.py", line 89, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/home/odoo/src/odoo/14.0/odoo/modules/loading.py", line 457, in load_modules
    force, status, report, loaded_modules, update_module, models_to_check)
  File "/home/odoo/src/odoo/14.0/odoo/modules/loading.py", line 349, in load_marked_modules
    perform_checks=perform_checks, models_to_check=models_to_check
  File "/home/odoo/src/odoo/14.0/odoo/modules/loading.py", line 227, in load_module_graph
    migrations.migrate_module(package, 'post')
  File "/home/odoo/src/odoo/14.0/odoo/modules/migration.py", line 180, in migrate_module
    migrate(self.cr, installed_version)
  File "/tmp/tmp1bew9m7l/migrations/website/14.0.1.0/post-adapt-footer-data.py", line 69, in migrate
    address = html_escape(partner._display_address(without_company=True))
  File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/res_partner.py", line 950, in _display_address
    return address_format % args
KeyError: 'town_name'
```

closes odoo/odoo#96703

X-original-commit: 81bf1d2101202a4a6cb832004500129905c2d3be
Signed-off-by: Christophe Simonis <chs@odoo.com>
2022-07-27 14:04:40 +02:00
Aurélien Warnon 2160315869 [FIX] tools: fix profiler datetime usage
This commit fixes the profiler datetime usage by properly using the
'real_datetime_now' as a callable.

This was breaking the output json file when profiling.

closes odoo/odoo#96456

X-original-commit: 5fec27e42b033f79933afb3d0c85b142360981f9
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-07-25 07:51:02 +02:00
+2 bc0a0cead6 [IMP] web,*: enable owl list & form views
The new list and form views were merged recently [1], but they
weren't activated because they weren't 100% ready yet. This is now
the case. This commit adds those views to the view registry. As a
consequence, a lot of qunit tests and tours needed to be adapted,
mostly for selector changes.

We also add legacy list and form views to the view registry, with
keys 'legacy_list' and 'legacy_form'. This allows to force those
legacy views when necessary. For instance, we did it in views
using complex custom legacy x2many field widgets that haven't been
converted yet (we have a compatibility layer but it isn't complete
and doesn't support every advanced usecases).

[1] odoo/odoo#92475

Part-of: odoo/odoo#78221
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Bruno Boi <boi@odoo.com>
Co-authored-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Samuel Degueldre <sad@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Simon Genin (ges) <ges@odoo.com>
Co-authored-by: Francois (fge) <fge@odoo.com>
Co-authored-by: Michael Mattiello (mcm) <mcm@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Lucas Perais (lpe) <lpe@odoo.com>
Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com>
Co-authored-by: luvi <luvi@odoo.com>
2022-07-22 16:21:45 +02:00
Jorge Pinna PuissantandSamuel Degueldre 2c9db825c1 [REF] base,web,*: convert settings form view to owl
*hr_timesheet,point_of_sale,website

This commit moves the settings form view implementation from base
to web, and converts it to owl.

The setting's search has been improved to take into account more
elements. Before, it was possible to only search on the field's
labels. Now, we can also search on the field's description, and
the titles of setting's group.

Part-of: odoo/odoo#78221
Co-authored-by: Samuel Degueldre <sad@odoo.com>
2022-07-22 16:21:42 +02:00
Simon Genin (ges) aba9f9d25b [FIX] base: restore partner's kanban badge hover effect
This commit fixes the background/text color inversion when hovering the
badge in the Partner's Kanban cards.

This was due to the missed conversion of `.badge-pill` class in BS5,
which removed it in favor of the more generic `.rounded-pill`. For
simplification, the selector is adapted to the more generic `.badge`
(independantly to its form).

closes odoo/odoo#96360

Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2022-07-21 00:50:23 +02:00
Abdelouahab (abla) 5bc83b046a [FIX] base : fix importing file with special character
To reproduce
============

for example on accounting, attempt to import a record from excel containing a special character like `%`.
Gets error stating the system doesn't support these

Purpose
=======

the issue is caused by misfromatted error string :
https://github.com/odoo/odoo/blob/b859d78c3d56526f44fbdd9ce5e84d34cf8a0a35/odoo/addons/base/models/ir_fields.py#L410-L411

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

to solve the issue use :
`str(value).replace('%', '%%')`

opw-2838573

closes odoo/odoo#96336

X-original-commit: eb0152d4c5ec38c33ccc5381d1277543354e3456
Signed-off-by: abla001 <abla@odoo.com>
2022-07-19 21:22:09 +02:00
Pierre Paridans 69f047c26d [IMP] web,tests,test_main_flows: Chrome headless touch option
Before this commit Chrome's "touch mode" was enabled in both desktop and
mobile-like tests suite (when run headless).

To better match real usecases, this commit adds an option to
enable "touch mode" only in mobile tests suites; keeping it disabled in
desktop ones.

Part-of: odoo/odoo#95924
2022-07-19 11:50:51 +02:00
MAHAMADASIF ANSARI 6807eea38c [FIX] various: display full name/title in form views
With commit[1], we added `o_text_overflow` classes at several places to avoid
long names going out of the boxes. However, for the name/title fields in the
form views, we should always show the full name.

So this commit replaces `o_text_overflow` class with `text-break` from
name/title fields in the form views to display full string in the read
only mode, but also keep them from going outside of the form view.

Below are the modules affected:
 - base
 - coupon
 - crm
 - event
 - mass_mailing
 - mass_mailing_sms
 - project
 - sales_team

commit[1] - a0ebb46

task-2889845

closes odoo/odoo#96132

X-original-commit: 4a74c7af6b54bd771f50d3885813f4aae442c9e7
Related: odoo/enterprise#29552
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-07-18 18:42:03 +02:00
Raphael Collet 519d8fe492 [FIX] core: complex flushing when searching on one2many fields
Consider two models A and B, where
 - model A has a many2one_reference field 'res_id' with model field 'res_model';
 - model B has an auto-join one2many field 'stuff_ids' to A using field 'res_id';
 - the field 'res_model' is not flushed on some record.

      model     | A                 | B
     -----------+-------------------+-------------------
      memory    | res_model = B     |
     -----------+-------------------+-------------------
      database  | res_model = NULL  | id = 42
                | res_id = 42       |
                | foo = 'bar'       |

Now, perform a search on model B that should return record with id=42 by
matching some condition on the unflushed record in model A, like:

    B.search([('stuff_ids.foo', '=', 'bar')])

Before this patch, the search method would not flush the field
'res_model', which causes the method to return incorrect results.  This
patch fixes the issue by ensuring that searches on one2many fields flush
all the fields on which the one2many field depends.

The issue was discovered while working on task 2735672.

closes odoo/odoo#96115

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-07-16 17:05:45 +02:00
Raphael ColletandVincent Schippefilt 384fda2c2a [REF] core: replace towrite by dirty flag in cache
Merging both the memory of field values and suspended updates has
several advantages:
 - avoid inconsistencies between cache and towrite
 - cache updates can be made safer w.r.t. dirty flag

However, the dirty flag in cache does not go well with context-dependent
fields.  When a context-dependent field is dirty in cache, the value to
store in the database is accessible through some context values.  But
when the model is flushed, the context values on the current environment
may be different.  When this happens, the method flush() fails to
retrieve the data to flush.

The proposed solution is to store the "dirty" value in cache under
conventional context values, and to retrieve them under the same
conventional context values to flush them.  For instance, when storing
the value of a binary field, it will be stored once under the context
value `context.get('bin_size')`, and a second time under the context
value `None`.  The flush implementation will then retrieve the value
using the context value `None`.

Translated fields are also problematic when a value is put in cache with
an environment where lang=False, and the value is retrieved with another
environment where lang=None.  This issue is addressed by normalizing the
context key 'lang' to None when the context value is False.

Part-of: odoo/odoo#95325
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2022-07-14 22:45:44 +02:00
abd-msyukyu-odoo 40dda26350 [FIX] core, web: handle read_group ranges for multiple granularities
There was an issue with the computed `read_group` `__range` when grouping on
the same date/datetime field on multiple granularities (i.e. month, week).
Since the range was stored with the field_name as a key, the last evaluated
range would override the previous ones.

Impacted Versions:

  - master
  (- exists since 15.0 but it does not impact the user directly so it has been
  decided to fix this only in master, since the API is modified)

Steps to reproduce:

  1. Open a list view and group by a date field with at least 2 granularities
  2. Open the chrome debugger (network) and check a web_read_group rpc preview
  3. Find the web_read_group for groups related to one of the largest
     granularities and check the `__range`

Current behavior:

  - `__range = {field_name: false}`

Expected behavior:

  - `__range = {field_name: {from: range_start, to: range_end}`

Explanation

Since the smaller granularities are evaluated last, and the condition to update
`__range` is related to the field_name and not the granularity, the range is
always overriden by the smaller granularities (even if their value is False)
when grouping on the same field with multiple granularities.

Furthermore, there is a conceptual problem with the current solution: it does
not allow to store multiple ranges when the read_group is not lazy and when
grouping on the same field with multiple granularities.

Therefore, the proposed solution is to use the full groupby keys in the
`__range` to allow storing multiple ranges depending on granularity. The keys
in `__range` would thus match the group value keys and allow more flexibility
if a domain must be forged from the group(s) range(s).

Task-2894519

closes odoo/odoo#95193

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-07-14 18:03:50 +02:00
Florian Damhaut 8646ebb8f5 [IMP] base: On profile, open lang wizard instead of technical view
Step to  reproduce:
- Go to 'My Preference' or User profile as admin
- Click on the world icon to add a language

Old Behaviour:
- Open the technical view of languages

New Behaviour:
- Open a wizard to add a a language

taskid-2774319

closes odoo/odoo#92855

Signed-off-by: Arnaud Joset <arj@odoo.com>
2022-07-14 16:41:56 +02:00
Denis Ledoux 5e4d697b24 [FIX] base: test_create_res_partner with only account_accountant
This is about the same than
d6ad39abba

but with account_accountant installed

```
FAIL: TestFormCreate.test_create_res_partner
Traceback (most recent call last):
  File "/data/build/odoo/odoo/addons/base/tests/test_form_create.py", line 35, in test_create_res_partner
    partner_form.property_account_payable_id = property_account_payable_id
  File "/data/build/odoo/odoo/tests/common.py", line 2179, in __setattr__
    assert not self._get_modifier(field, 'invisible'), \
AssertionError: can't write on invisible field property_account_payable_id
```

closes odoo/odoo#95903

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-07-13 16:22:55 +02:00
std-odoo e9f712278d [IMP] microsoft_outlook, fetchmail_outlook *: improve usability
* fetchmail, google_gmail, fetchmail_gmail

Purpose
=======
Improve the usability of the outlook modules.

Specifications
==============
Remove the checkbox "Use Outlook" and instead use the
smtp_authentication and the server_type, to be consistent with Gmail.

Hide the password field for Outlook / Gmail mail servers.

Add constraints on the outgoing mail server to force the user to use
the right configuration (e.g. the from_filter, so the sending does not
fail).

Add an option in the mail module to install Outlook.

Show a message for the outgoing mail servers to explain each
authentication methods.

Task-2811567

Part-of: odoo/odoo#88215
2022-07-12 15:36:50 +02:00
std-odoo eb2dd1d674 [IMP] base, fetchmail: improve the mail servers list
Purpose
=======
Improve the incoming mail server list view and the outgoing form view.
Show the most used option first, and make the view more responsive.

Task-2811567

Part-of: odoo/odoo#88215
2022-07-12 15:36:49 +02:00
Xavier-Do d6ad39abba [FIX] base: manage non existing ref
If the test is ran on a database without account installed, it will fail
because of the missing ref.

closes odoo/odoo#95735

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-07-12 13:21:24 +02:00
Hardik Prajapati bdc4b4a21b [IMP] base,project: improve project and the uninstall wizard
This commit does the following changes:
 - Improve some project filter and views
 - Align the module kanban buttons
 - Sort the module in uninstallation wizard

task-2731708

closes odoo/odoo#83339

Related: odoo/enterprise#23783
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-07-12 10:37:02 +02:00
Xavier Morel ba37803064 [IMP] core: reintroduce test stats
Uses a dedicated logger (for easier filtering / silencing) for
results output, and provides rough (module-level) stats in INFO but
detailed (test-level) in DEBUG.

Also updates the global query counter (`odoo.sql_db.query_counter`) to
update after each query rather than on close: with test cursors the
actual underlying counter is only rarely flushed.

closes odoo/odoo#95420

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2022-07-11 09:04:51 +02:00
Julien Castiaux 8eed20d6cb [FIX] core: replace empty images by placeholder
Create an empty image attachment and load it via an `<img>` html tag in
a document. Upon rendering the image is replaced by the default browser
placeholder instead of the pretty Odoo one.

closes odoo/odoo#95702

Task: 2886028
X-original-commit: 981d56f131f85d33e2415edaef36cfa501d86f0e
Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-07-09 13:26:49 +02:00
aliya 26b2472f49 [IMP] account: refactor account types
Task: 2856281

- Remove user_type_id, account.account.type model, internal_type
- Add account_type that is a simple selection field
- Move internal_group and include_initial_balance to account.account
- Because of these changes, type_control_ids on account.journal is also removed

closes odoo/odoo#93212

Related: odoo/documentation#2223
Related: odoo/upgrade#3595
Related: odoo/enterprise#28205
Signed-off-by: Cedric Snauwaert <csn@odoo.com>
2022-07-08 19:52:15 +02:00
Rémy Voet (ryv) 193082f6ac [IMP] core: improve search count with a limit
The new feature (search count with limit) introduced by https://github.com/odoo/odoo/pull/95589 lacks of test and code readability:
- Add tests to check the result and query generate
- Increase the readability of SQL/python code.
- Change a little bit the SQL request generate: in the subquery, change `SELECT 1 FROM...` into `SELECT  FROM` which avoid extra work in the postgreSQL side.

task-2761165

closes odoo/odoo#95641

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-07-08 17:10:51 +02:00
Samuel Degueldre 8f2673708a [FIX] tests: stop test runner from opening error dialogs when not ready
Previously, the test runner would evaluate an expression to check if the
browser test that is about to be run is ready, but before the test is
ready, this expression may be invalid as the variables used in the
expression may not be defined yet, causing a ReferenceError to be thrown
by Chrome.

In Chrome >=102, errors that are thrown when writing code in the console
or by using Runtime.evaluate over CDP are thrown in the context of the
current tab, which means that they trip registered error handlers in
that tab. In Odoo, this means that we show error dialogs with the
traceback.

In the tour manager, when we are looking for an element  to trigger, we
only look for that element inside dialogs if there are any dialogs open
(unless the in_dialog option is false on that specific step). This means
that if an error dialog is open, most tours will fail (which is actually
what we want).

In order to avoid opening a bunch of error dialogs while waiting for the
tour to be ready, we simply wrap the ready expression in a try catch so
that it doesn't throw an error, and simply returns a undefined until the
tour is ready instead of throwing a ReferenceError.

closes odoo/odoo#95635

X-original-commit: 3872dbd63233d4c6d961a3cd896b84e4301a1f84
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-07-08 14:34:19 +02:00
Thibault Delavallée 40f4ea486b [UPD] various: update query counters
closes odoo/odoo#95556

Related: odoo/enterprise#29247
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-07-08 14:34:04 +02:00
Denis Ledoux 5ccc32fcf7 [IMP] tests: common.Form, can't write on invisible fields
In the web client, in a real use case, it's not possible
to write on fields which are invisible,
as it's not possible to write on fields which are readonly.

This is a first step in the goal to change the behavior
of the `groups=` attribute in the back-end views,
to remove them for the view instead of making them invisible.

This is mainly to reduce the diff of the revision that will introduce
the mentioned above behavior change.

As nodes with `groups=` will be removed from the view
when the user doesn't have the group, it's no longer possible
to set a value on a field having a `groups=` the user doesn't have
in the `Form` test class, as the field will no longer be at all in the
view.
However, these unit tests shouldn't have been able to set values
on invisible fields in the first place.
This revision therefore aims to correct the unit tests setting value
on fields which were invisible because the user executing the
test was not part of the required group(s) for these fields
to be visible in the view.

closes odoo/odoo#94337

Related: odoo/enterprise#28936
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-07-08 14:33:47 +02:00
Fabien Pinckaers a01e8b5232 [IMP] base: Adding a limit=None argument to search_count(), like search()
Search count on large tables can be very slow (it takes 4s to
search_count the list counter of res.partner on our production DB)
This will allow to display a 10000+ counter for large DBs.

closes odoo/odoo#95589

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-07-07 19:46:55 +02:00
Denis Ledoux f2f5ce7790 [IMP] repair: convert repair uom and location onchanges to compute
This allows to create a repair.order record without
the need to call the onchanges to set the uom and locations
or to set them manually during the `create` call.

For instance, this makes easier to create repair orders
using XMLRPC when you do not use multiple UOMs or multiple locations.

closes odoo/odoo#95321

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-07-07 17:30:35 +02:00
Romeo Fragomeli 1fcd098af5 [REF] *: BS5: migration
Automated change made by a lot of RegEx to change all think that is
possible to automate.

https://getbootstrap.com/docs/5.1/migration

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:24 +02:00
Romeo Fragomeli f936513466 [REF] *: BS5: avoid multiple usage of BS handler
In BS5 there is a check to avoid having multiple handler for one
element and we can't add two components' instance on an element.

So, before disposing a tooltip we check if there is an instance of a
tooltip and we avoid instantiation of tooltip if not already done.

e.g.:
> Bootstrap doesn't allow more than one instance per element. Bound
> instance: bs.collapse.

e.g.:
> Bootstrap doesn't allow more than one instance per element. Bound
> instance: bs.carousel.

> Bootstrap doesn't allow more than one instance per element.
> Bound instance: bs.tooltip.

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:20 +02:00
Romeo Fragomeli 0b94da214b [REF] web,website: BS5: Convert JavaScript MonkeyPatch
Converted for new Javascript of Bootstrap 5.

Note: some parts are removed as not found equivalent function name in
BS5.

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:20 +02:00
Romeo Fragomeli e1ea58c941 [REF] *: BS5: Migrate dropdowns
- BS5 JS use the `data-bs-toggle="dropdown"` attribute to
automatically enable the BS Component.
But in this case as the `.dropdown-menu` is only rendered when the
`.dropdown-toggle` is clicked we can't initialize the Dropdown at the
first render. So we do it manually.

- change .dropdown-menu by .o-dropdown-menu (owl)
  -> to handle keyboard navigation we can't use BS dropdowns

- use currentTarget of event
  As the event can bubble we use currentTarget to be sure to be at the
  higher level in the DOM.

> All the events for the dropdown are now triggered on the dropdown
> toggle button and then bubbled up to the parent element.

- BS5 don't add .show on parent group anymore
  -> dropdown show class not on the same node on BS5

- avoid dropdown warning using margin in CSS
  BS5 show a warning if we use margin statically in CSS for a dropdown.

> Popper: CSS "margin" styles cannot be used to apply padding between
> the popper and its reference element or boundary. To replicate margin,
> use the `offset` modifier, as well as the `padding` option in the
> `preventOverflow` and `flip` modifiers.

- adapt the systray activity dropdown for mobile
  On desktop positions are now dynamic and on mobile it's static

- In BS5 the CSS `bottom: 100%;` is not more applied to the
  `.dropup .dropdown-menu` selector.

- Change right -> end and add data-bs-popper="none" to avoid
  Popper interaction

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:19 +02:00
Romeo Fragomeli 68a3bd651f [REF] *: BS5: Migrate tables
- avoid black border in table of BS5

In BS5 there is a new rule:
```css
.table > :not(:first-child) {
    border-top: 2px solid currentColor;
}
```
This rule generate unwanted border in our visual, so we change the color
to the old one we have in BS4 and in some case set the `border-top` to
´none´.

PS: another solution is to use the `table-borderless` class, but then
we have `tr` flickering for the height in list view (edit mode).

- table background-color :
  * BS4:
  the background color is set with the `background-color` property
  * BS5:
  it's set with a box shadow and the `--table-accent-bg` CSS variable

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:19 +02:00
Romeo Fragomeli b82ba2a8fd [REF] *: BS5: Migrate modals and .btn-close for modals and alerts
- modal 'show' option doesn't exist anymore
  -> We need to call .show()

- by default, show is not the default
  -> we need to call .show() explicitly.

- generic close button for dismissing content like modals and alerts.

- BS5 modals needs `modal-dialog` class to work

- normally we need also to add `modal-content` class but as the original
XML don't have this nested level of div we don't use it, but instead
we add `pointer-events: auto` for all children `DIV` of `modal-dialog`
-> See DocumentViewer

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:18 +02:00
Romeo Fragomeli c48f57ea25 [IMP] web,*: upgrade to Bootstrap 5.1.3
* = base,http_routing,hw_drivers

- Update Bootstrap from 4.3.1 to 5.1.3

- Update PopperJS to version 2 for Bootstrap 5 (JS part)
  Some code was for PopperJS V1, but it's not compatible anymore.

- Remove some BS5 classes utilities backport

- Fix path for BS5

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:15 +02:00
Romeo Fragomeli 7f3923cf2d [FIX] base: SCSS don't compile Bootstrap 5
- Fixes the RegEx that insert our internal structure path
for some assets like image font...
BS5 uses inline SVG and the function `escape-svg` to escape some
characters in HTML. But we can't add the path as the image is inline.

- Don't include Bootstrap in LESS assets;
Since Bootstrap 4 (and also in 5) there are no more LESS files for
Bootstrap. So, there is no reason to include the path when we compile
LESS assets.

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:15 +02:00
Guillaume (gdi) fadf643f97 [FIX] base: force to specify the language when installing a new language
Before this commit, the user could try to install a language without
specifying which language he wanted to install, resulting in a TB. This
commit forces to specify which language you want to install. The bug
appeared with this commit [1] which allows to install several languages
at the same time.

[1]: https://github.com/odoo/odoo/commit/47041f2d45915e2ed74c4317f9aafe3dfa840f0a

task-2878405

closes odoo/odoo#95426

X-original-commit: bc083e6616859d51364b90ad4d0c6f0d99e34631
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-07-06 17:10:32 +02:00
Victor Feyens efcf488d23 [FIX] core/tests: test form without fields specified
Since #91909, the settings form view is tested with different levels
of access rights, post install.

But when the test is run with only the base module, it crashes because
the settings view specified in base is empty, without any field.

On save, the test form reads the view fields, but read fallbacks on
all fields if no field is specified, and it breaks when we try to
compare the read results to the fields requested (empty).

This commit skips the read when no fields is present in the view.

closes odoo/odoo#95340

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-07-05 16:20:56 +02:00
Aaron Bohy e37a663b52 [FIX] web,*: kanban: support t-set defined outside cards
*base, event, hr_holidays

Before this commit, `<t t-set/>` nodes declared outside the main
div of a kanban card where ignored by the kanban compiler. This
commit fixes that issue. To do so, we refactor a bit the way the
compiler and KanbanRecord handle multiple root cards (typically,
several roots with a t-if/t-elif/t-else, s.t. there's a unique
rendered root), by removing the faulty logic from the compiler
that identified card root nodes (and filtered out t-set nodes),
and introducing a div for the KanbanRecord component on which we
can set classNames, attributes and handlers.

The issue could be observed on the Apps kanban view, as it
displayed the "Install" button, whether the app was already
installed or not.

closes odoo/odoo#95211

Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-07-05 11:35:16 +02:00
Xavier-Do 61f54e5b88 [FIX] profiler: make profiler work with freezegun
When freezegun is used, the profiler and sql_db time are freezed,
Making the profile and sql perf counters invalids.

A possible solution would be to black list some modules in freezegun but
this doens't look possible in the pinned version (0.3.x).

Saving the builtin time.time is not enough, it looks like freezegun will
find all occurences and replace them.
We need to get the __call__ instead.

closes odoo/odoo#95100

X-original-commit: 9ac5fdf1e6d00e6e4b4ff4b6e94a3cd28f8cae11
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-07-05 11:35:13 +02:00
Raphael ColletandVincent Schippefilt eb67feb590 [FIX] *: cache consistency
In module mail, invalidating 'message_ids' on a mail thread also
invalidates its inverse field 'res_id' on messages.  If you haven't
flushed it before, your cache will be inconsistent, as shown by the test
/mail:TestMailgateway.test_message_process_bounce_records_channel.

In module purchase_stock, add depends on report.stock.quantity.  This
ensures that when the model is queried after changes in other models,
the data on which the SQL view depends is flushed to the database before
querying that model's table.

closes odoo/odoo#66938

Related: odoo/enterprise#16722
Signed-off-by: Raphael Collet <rco@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2022-07-05 11:35:01 +02:00