Commit Graph
6952 Commits
Author SHA1 Message Date
Julien Alardot (jual) b88a846866 [IMP] l10n_ca: Add/Imp COA, taxes, reports
Complete refactor of the module,
adding the tax report

task-3098316

closes odoo/odoo#130476

X-original-commit: fd2c6dce8e5bee5ac526e7f3edeb398a992f84b1
Related: odoo/enterprise#45024
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Julien Alardot (jual) <jual@odoo.com>
2023-08-02 16:00:38 +02:00
Pierre-Yves Dufays 169eaec793 [IMP] base,test_new_api,website:prevent merge of partners with more than 1 user
We prevent to merge partner linked to more than one user (by raising an
exception) to avoid having multiple user pointing to the same partner as a
consequence of a merge.

We want to avoid this situation because it generates weird behaviors. As
res.user inherits from res.partner, having multiple user pointing to the same
partner makes the fields of that partner shared with all those users. This was
decided following the tentative to improve partner merge in website_slides
(odoo/odoo#114840), where we also noticed strange behavior like completing a
lesson with one user were adding karma to all the users linked to a same
partner.

We have also adapted WebsiteVisitorTests tests in website that were failing
because they were merging partners with more than one user: simply by merging
partners with only one user.

Task-3167160

closes odoo/odoo#125322

Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
2023-08-02 15:59:24 +02:00
Martin Trigaux 360915b3f0 [FIX] base: remove wrongly untranslated term
The label was already Status on the field but not in the search view.
"State" is always used for the meaning location.
Sharing the same term meant it was not possible to have two different
translations.

closes odoo/odoo#130444

X-original-commit: 70fcdf30fc842410aafa9e61d2a1903589a15311
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-08-02 14:41:18 +02:00
Victor Feyens f5de88f3b5 [FIX] sale: failing test with localizations
The test verifying the values of the sale report in a multi-comp & multi-curr
environment relies on the fact that the main company is by default in USD.
Nevertheless, the test fails when a localization is installed (if it changes
the currency of the main company).

This commit makes sure the tests always works, and resurrects the right tool
for that, which was dropped in commit 3752b3166e.

Cf runbot build error 22351

closes odoo/odoo#130201

X-original-commit: a73b5fce4fb02eefc681c55eab8f57cd35105226
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-01 13:51:32 +02:00
Aaron Bohy 9d81cff6fd [REF] *: remove always_reload many2one option from archs
This option is no longer necessary since [1] as the value is now
reloaded by default.

[1] odoo/odoo#114024
Part of task~3179751

closes odoo/odoo#130169

Related: odoo/enterprise#44838
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-08-01 09:40:55 +02:00
miad-odoo 7bc89a1c34 [FIX] base: fix traceback install demo data
This commit fixes a traceback when trying to install demo data from the UI.

Steps to reproduce:
	- create a database with website_event_track_live installed and without demo data
	- load demo data from the UI (settings)
	- odoo.exceptions.AccessError: You are not allowed to create 'Website Visitor'
(website.visitor) records.

There is a traceback because the installer can't create `website_visitor`
records because there are no groups that have create access rights for that
model.

This is because xml_import used to get an environment with root privileges, that
can bypass access rights, but now the environment is a parameter passed to the
function and doesn't necessarily have sudo

This change was introduced in
5bf1207#diff-8e4705d5ab335a8dfc2c70eeedc502a92695989f97c4f19184b49634c2c4ad55L583-R583
; with this commit, the environment used by xml_import doesn't necessarily have
sudo, so we simply make sure `load_demo` loads data with sudo.

Task-3202914

closes odoo/odoo#129946

X-original-commit: 85834371e0eede05858cb2dc33412396c6e5c5bf
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
Signed-off-by: Adrien Milis (miad) <miad@odoo.com>
2023-08-01 07:04:53 +02:00
tsm-odoo b5896c9d03 [IMP] *: add generic make_jsonrpc method in tests
*: bus, crm_livechat, crm_mail_plugin, im_livechat, payment, payment_demo,
pos_online_payment, test_discuss_full, test_mail_full, tests, website_livechat,
website_sale.

Several python tests have their own way to make jsonrpc requests. This PR adds a
generic `make_jsonrpc_request` method to the `HttpCase` in order to provide a
generic way to do so.

At the same time, calls to `_open_livechat_channel` are removed in favor of
jsonrpc request to `get_session`. This makes the tests more realistics (some
incoherences were present like passing `country_id` to the open channel method
while the user country id is not set...)

Finally, this will ease the diff in the PR introducing livechat visitors as mail
guests.

part of task-3332628

closes odoo/odoo#130036

Related: odoo/enterprise#44840
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-07-31 23:21:10 +02:00
Martin Trigaux 35a118eff5 [IMP] base: move helpers to tools
closes odoo/odoo#67316

Signed-off-by: Rémy Voet (rvy) <rvy@odoo.com>
2023-06-08 12:11:07 +02:00
Martin Trigaux f4d5752724 [IMP] tools: load also es_MX
The translations on Spanish (Mexico) are more active than on Spanish
Moreover, most other countries speaking a variant of Spanish are
located in Latin America and are closer to es_MX than es.
To solve this, when installing for instance es_AR, the translations
will be loaded in the following order:
1 es
2 es_MX
3 es_AR

In case a term is translated in both es and es_MX (and not es_AR), the
later will be used

closes odoo/odoo#121415

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-07-28 17:53:53 +02:00
Bastien PIERRE 65242e31e9 [IMP] *: Remove alias in JS files
Rename all imports with alias old system to the new js module system
Task ID: 3266759

closes odoo/odoo#127414

Related: odoo/design-themes#671
Related: odoo/enterprise#43716
Signed-off-by: Bastien Pierre (ipb) <ipb@odoo.com>
2023-07-27 11:58:34 +02:00
Xavier-Do fd8ec5001d [FIX] tests: reset sequence at the end of test
Some test may perform a request without being in test_mode

In this case, a check signaling could be called and since the sequence
was incremented the registry may be reloaded.

This is a simple fix to avoid this issue waiting for a stronger check.

closes odoo/odoo#129814

X-original-commit: 41bb17b3046e8f1605d6f893ca1807d77ed21173
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2023-07-27 03:50:53 +02:00
Ali Alfie (alal) 8da5cdf5c0 [IMP] base: Sierra Leone currency update
- adds a new currency SLE for new leones.
- sets the default currency for Sierra Leone to the new SLE currency.

task-3355038

closes odoo/odoo#124239

Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2023-07-26 23:15:00 +02:00
Vincent Schippefilt ac81985126 [FIX] base: traceback when creating a user
The combination of the new basic model and this change dc4dcead6e
made it so that creating a new user would fail with a traceback.

This commit fixes the issue by making sure that the company_id that is used
withing the initial onchange is a integer, and not a new-id.

closes odoo/odoo#129590

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2023-07-26 10:48:49 +02:00
Denis Ledoux 028bf8e0ec [FIX] base: tag test_add_field_valid as post_install
This test can lead to a deadlock,
when trying to drop the constraint on `ir_model_fields`
during the registry loading,
as the test opens a second cursor in addition
to the cursor used for the registry loading,
and drop a constraint on a table which is being read by
the registry loading (`ir_model_fields`), leading to the deadlock.
See screenshot in the PR for illustration.

This has been detected in the runbot nightly builds,
which were pending indefinitely because of that deadlock.
To reproduce, just init a database with `-i base`,
then restart the server with just `--test-tags .test_add_field_valid`.

To avoid to drop the constraint during the registry loading,
and hence to avoid the deadlock,
tag the test as `post_install`.
That way, the test is executed after the registry is loaded,
not during, and the constraint can be drop safely, not leading to a deadlock.

closes odoo/odoo#129660

X-original-commit: 67bc9a9e895245a94aac064e8f5a365ee6052261
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2023-07-26 09:22:19 +02:00
Xavier-Do 1c598d4b00 [FIX] base: avoid being stuck on a test
During the nightly, it looks like some test in
`TestAccountEarlyPaymentDiscount` will reload the registry, restarting
all base tests, including `.test_add_field_valid`

This test cannot be executed on an existing database without providing
a `-i` for a strange reason.

If this is not a real issue, this simple assertion will avoid to get
stuck while running this test on an existing database.

closes odoo/odoo#129491

X-original-commit: 4c6e05cbb43d08c544d9d558f80b67ccb786d482
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2023-07-25 08:19:08 +02:00
Olivier Dony ae57b72e88 [IMP] sql_db: speed up log-sql query matching
The dinosaur regular expressions[^1] used to count SELECT/INSERT queries in SQL
debugging mode were slowing down query execution. They can be replaced by
more efficient ones.

The `re.MULTILINE` flag is not necessary anymore, since there is no more
`$` or `^` in the expressions.

[^1]: f8471796a3

closes odoo/odoo#129473

X-original-commit: 0730e432c470635baec962d16ca09e8423c2b3ba
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Olivier Dony (odo) <odo@odoo.com>
2023-07-24 23:04:17 +02:00
Raphael Collet 7bfbd75d57 [FIX] core: web_read() on new records
This completes 96a98f4f4c in the case
where a many2one field has a new record as value, even when that
many2one field is not a delegate field.

Part-of: odoo/odoo#114024
2023-07-24 20:17:49 +02:00
Martin Trigaux 935857e01d [FIX] base: do not remove groups added in implied groups
If a user goes from "Access Rights" (base.group_erp_manager) to
"Settings" (base.group_system) he gets an error telling him he did not
belong to Access Rights group.

The reason was that the modification of accesses on the user profile
page was doing
write({'sel_groups_2_4': 4})
which was transled, after the _remove_reified_group call into
write({'groups_id':[(UNLINK, [2, 4]), (LINK, [4]]})
so the user was temporary in a state where he was in the group_system
but no in group_erp_manager.
When the implied groups where computed, an access error was raised as
the administrator was not allowed to modify res.users record (need
group_erp_manager).

Simplify the _remove_reified_group call to only convert the call to
write({'groups_id':[(LINK, [4])]})

closes odoo/odoo#129335

Task-id: 3265053
X-original-commit: 0ed2fa018a7716f0fb3abe587983209403445fc8
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-07-24 15:52:05 +02:00
Christophe Monniez 13a4df94b1 [IMP] core: bump master release to 16.5 alpha 2023-07-20 22:44:13 +02:00
Lucas Perais 3c6235d446 [FIX] base: ir_actions_report: context for not using attachment
Before this commit it was not possible to print a report without
bypassing the retrieval of a previous attachment, or to print
a report without creating one.

After this commit it is possible with the context key "report_pdf_no_attachment"

Part-of: odoo/odoo#128228
2023-07-20 17:01:31 +02:00
Damien Bouvy 2437baee53 [IMP] base: better help text for company tagline
closes odoo/odoo#129143

Signed-off-by: Bouvy Damien (dbo) <dbo@odoo.com>
2023-07-20 14:23:31 +02:00
Xavier-Do eb708e5cad [IMP] base: avoid cache_invalidation
A clear_cache was added in _update_xmlids in pr 119813.

If it was needed in case of update, it is not useful when creating an
xmlid or when the value is unchanged.

The initial idea was to detect if an update or an insert was done, maybe
using create_date and write_date. Unfortunately the create_date is the
same as the write_date in the same transaction. This is unlikely but in
this case, we could update the cache in place.

The final behavior is to update the cache in all case, and notify other
workers only if a model was updated.

This will help to avoid invalidating the cache too mush during module
loading. Even if the impact on time is small, the increase in queries
was visible.

This solution would even be a slight improvement on previous query count

closes odoo/odoo#129029

Related: odoo/enterprise#44349
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
2023-07-20 14:23:15 +02:00
Xavier-Do d5ed47a11f [IMP] base: simplify _xmlid_lookup cache
The _xmlid_lookup cache contains the id of the ir.model.data with is
unused, making cache pupulation and usage more complex than needed.

Removing this id in prevision of the next commit

Part-of: odoo/odoo#129029
2023-07-20 14:23:15 +02:00
william-andre 0d30cc2bc9 [IMP] models: manage sub companies with check_company
Allow some models to be delegated to the main company of the object.
For instance:
* Have company Parent and Child
* Child has access to all the accounts of Parent
* When creating a document in Child using an account of Parent, there
  shouldn't be a consistency error.

In order to do that, a new method `_check_company_domain` has been added.
This method is used when `check_company=True` is set on the field
declaration to:
* filter relational fields in the UI [^1]
* validate relational fields when writing on them in `create` and `write`

That method should also be used in the business code for models likely
to be shared amongst company branches instead of hardcoding the domain
based on `company_id`.
The same applies on domain restriction on the field declaration: the
flag `check_company` should be prefered instead of providing the domain
explicitly based on `company_id`.

Since a lot of validation and filtering will now be done based on
`parent_of`/`child_of` of the company, some support has been added for
that special case in `filtered_domain` in order to avoid doing
additional queries.

task-3371677

[^1]: because of that change, support has been added on the python
interpreter of the client to allow concatenatng domains.

Part-of: odoo/odoo#125642
2023-07-20 11:49:05 +02:00
william-andre ba5df07223 [FIX] base: do not depend on active_test to evaluate parent_of
Let's assume that
* Company S is a sub company of it's parent company P
* Company S has access to all the accounts and taxes of company P
* Some taxes are archived, but used

Because of the needed access rules, there will be a `parent_of` on the
record rules of accounts and taxes.
If we consider that we should consider the context key `active_test` to
add a implicit `('active', '=', True)` clause in the domain when
evaluating `parent_of` and `child_of` clauses, an access error will be
raised instead of hiding the archived records, even when simply trying
to read an archived record.

The archive feature and the security rules should be independent; if a
security rules needs to depend on the fact that a record is archived, it
should be explicit in the domain and not rely on side effects of the
implementation of `parent_of`/`child_of`

Part-of: odoo/odoo#125642
2023-07-20 11:49:05 +02:00
william-andre b405bc41fb [IMP] base: restrict currency rates to main companies only
The interraction between currency rates owned by branches can not be
defined clearly.
It would also make the currency rates tables a lot bigger.

task-3371677

Part-of: odoo/odoo#125642
2023-07-20 11:49:04 +02:00
william-andre dc4dcead6e [IMP] base: add more support for sub companies
Add fields and tooling to support sub companies.
The new fields are
* `parent_ids`, which consists of all the ancestors of the current
  company
* `root_id`, the upmost parent, which is the company controlling the
  subsidiaries
* `parent_path` is added to avoid a hit on the performances when using
  the multibranch feature

Also add a mechanism to ensure some fields are shared with a root
company and all it's descendents.
All fields listed by `_get_company_root_delegated_field_names` will be
readonly and copied from the `root_id`.

task-3371677

Part-of: odoo/odoo#125642
2023-07-20 11:49:04 +02:00
Raphael Collet fef1ce7eda [IMP] test_new_api: add more tests about _check_company()
The tests did not cover the cases where:
 - the main record has no company;
 - the linked record has no company.

closes odoo/odoo#129044

Signed-off-by: Raphael Collet <rco@odoo.com>
2023-07-20 05:02:58 +02:00
Ipsita Borisagar 8ffca9da77 [IMP] base: add module category for appointment
Purpose is to introduce Appointment as a real app, meaning it now uses its own
module category.

Task-3280730

closes odoo/odoo#128976

Related: odoo/enterprise#43219
Related: odoo/upgrade#4946
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-07-20 03:56:04 +02:00
Julien Carion (juca) 6c412be2ea [IMP] *: coherent hotkey uses
This commit makes hotkey uses more coherent throughout the entire
codebase by setting alt+q as main shortcurt for confirm and default
actions and alt+x for cancel actions.

task-3370463

closes odoo/odoo#127469

Related: odoo/enterprise#43694
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
2023-07-19 18:24:15 +02:00
Xavier Morel f96988cbe5 [IMP] core: improve test request blocker
Better tag selection
====================

The block was originally hooked onto the `external` tag under the
assumption that this was the tag used to allow external requests.

It's not, it's the tag for the "external" test suite, which is only
one of the test suites allowed to perform external calls. Hook again
onto `standard`, this might have some false positives (allow requests
which we'd rather block), but it should have a lot less false
negatives (block requests we want to allow).

Make Overrides Easier
=====================

Currently `_request_handler` raises a regular `ConnectionError`, this
is an issue because it passes some requests through, which could
themselves trigger genuine `ConnectionError`.

When overriding `_request_handler` to implement fallbacks for bespoke
URL mocks, these two cases need to be distinguishable as overrides
likely want to handle blocked requests, not actual failures.

Therefore `_request_handler` should a dedicated exception. This
exception should be a subclass of `ConnectionError`, so that blocked
requests are treated as regular connection failures by normal Odoo
code.

Class-scope
===========

Originally `_request_handler` was scoped on the instance with the idea
that it'd be a `mock` object, which individual tests could
`configure_mock`. This turned out not to work correctly, because
`Mock.side_effect` does not receive a `self`, hence the `Session` was
inaccessible and it was not possible to passthrough local requests.

While I moved to a regular `lambda` (because a direct method didn't
work either), I forgot to remove the `request_mock` attribute, and
didn't think that the block could now be lifted up to the class
scope. Doing this, requests performed during a "standard" test case's
`setUpClass` are now also blocked, which they very much should be.

closes odoo/odoo#128977

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-07-19 13:13:32 +02:00
Pierre Pulinckx (pipu) 8bfa76a842 [REF] *: Unify _t and _lt
The goal of this commit is to prepare ground to remove
lazytranslate function _lt() and keep only _t()
for a better understanding of the use of the translation function.

In this commit,

the translate function _t() has been updated to return the translation
if they are loaded. If not, it throws an error.
the lazytranslate function _lt() returns _t() function.
Corollaries :
Steps in test tours are now a function that returns an array of steps
to avoid any interpolation of _t in this ones before translations has
been loaded.

Example :

registry.category("web_tour.tours").add("example", {
    test: true,
    steps: () => [
        {...},
        {...},
    ],
});

task-3292454

closes odoo/odoo#124157

Related: odoo/enterprise#43153
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-07-19 13:13:16 +02:00
Benoit Socias 567e5b58d5 [IMP] base, tools, web_editor, *: use original image if size increases
*: web_tour, website

When no transformation is applied on an image, changing the quality
sometimes increases its storage size.

This commit makes sure that the original image remains used if only the
image quality is modified and if this makes its storage size bigger.

Fixes #61619
task-2835144

closes odoo/odoo#103398

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-07-19 13:12:51 +02:00
Arnaud Joset c4ed0a8e6c [IMP] Base ir.cron: _trigger should return the ir.cron.trigger records
Before this commit, when a ir.cron was walling _trigger, the ir.cron.trigger
records were not returned. it would prevent to use them later easily without
making a search.

Taskid: 3270442
Part-of: odoo/odoo#118738
2023-07-19 11:39:37 +02:00
Maximilien (malb) bedfa27e3d [IMP] base: Rename states in their mother language in the data.
In Switzerland, states are really important. Each  state has its rules, its
language, its culture, its parliament, etc. It's quite frowned upon to send an
invoice/offer or even to have backend management using German terms when we're
in a very French-speaking state.

So in this PR, we will add states in the missing languages

closes odoo/odoo#128954

Task: 3268058
X-original-commit: f309fd06cd46a767fee742ec9f634b46a2edf70f
Signed-off-by: John Laterre (jol) <jol@odoo.com>
2023-07-19 09:12:42 +02:00
Nicolas Lempereur e0ef9806a6 [FIX] base: invisible groups default on selection group
In 9deb1e6aa902a09c4f invisible duplicate were added for boolean groups.

But the added test could fail on master when installing only base
module: in this case, there is only the group "base.group_allow_export"
that is shown as a selection group because it is the only field of its
category. When we install other module, the field become a boolean group
that is handled by the aboved mentionned commit.

The previous fix and test didn't take this case into account, with
customization this could be a real issue.

With this commit, hidden selection field are also handled and the test
test_reified_groups pass in master when installing only base.

related to #120310

closes odoo/odoo#128944

X-original-commit: b22fc41d63bded2435cd330517d407abab5035ee
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2023-07-18 21:48:30 +02:00
Xavier-Do 54af24356a [IMP] registry: less invalidation log
The number of invalidation during the test is quite large and
the crons cal also spam this log sometimes.

Waiting for further cleanup, removing this log to avoid spaming runbot
logs and making them harder to read.

closes odoo/odoo#128921

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2023-07-18 20:35:45 +02:00
Raphael Collet 96a98f4f4c [FIX] web: web_read() on new records with _inherits
This commit partly reverts 59afbf6686 and
provides an alternative solution.  In this solution, records.web_read()
returns a list of dicts where the key 'id' corresponds to each record.id
in records, which enables to reliably relate each record to its values.

This also fixes the implementation of web_read() on new records where
the fields contain a reference field with some context.

closes odoo/odoo#128878

Signed-off-by: Raphael Collet <rco@odoo.com>
2023-07-18 19:28:13 +02:00
Moises Lopez - https://www.vauxoo.com/ f8bbec56f2 [REF] core: Improve the message for invalid manifest version
Considering the valid odoo version in the manifest version

The message before of this commit was:

    Modules should have a version in format ``x.y`` or ``x.y.z``

It looks like it enforces to removing the odoo version part as invalid

But it is not, in fact, it is already supported

It is important since OCA enforces ``{odoo.version}.x.y.z`` format

It was already discussed here:
 - https://github.com/odoo/odoo/pull/118420#issuecomment-1635047100

The message after this commit is:

    Modules should have a version in format `x.y`, `x.y.z`, `16.4.x.y` or `16.4.x.y.z`.

Notice the Odoo version "16.4" is the current {odoo.version} for the moment this commit was done

It avoid confusing about the valid formats to use

closes odoo/odoo#128810

Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
2023-07-18 19:28:11 +02:00
Thomas (thbe) 82985296e1 [ADD] base: Revoke access to your account to all devices
Prior to this, there was no way to shut an active session you didn't have the
access to anymore or close every active session remotely.

Adding the RevokeAllDevices class, it is now possible to close every open
sessions, including the one you are performing the action on of the account
you are logged into via the Account Security page in the preferences.

This system is based on the principle that every open session uses the password
hash to maintain it. When the hash is computed, salt is added to it to make it
not reversible. Thanks to that salt, it is possible to change the user's
password's hash without changing the password. Therefore, the flow of this
addition is the following :
1. User clicks on the button and uses his passord to confirm identity.
2. User's input is used to check his identity (_check_credentials()).
3. User's input is used to refresh the password hash in the db (_change_password()).
4. User is logged out.

This adds a way to close all sessions remotely and improve user's control over
their account and therefore their security.

task-3191567

closes odoo/odoo#113899

Related: odoo/upgrade#4951
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-07-18 19:27:19 +02:00
Xavier-Do 4c9968397b [IMP] base: avoid invalidation on xmlid updates
Splitting the cached revealed a missing cache invaldation.
The cache invalidation added a a query in test_related_fields

The query can be avoid by not updating the xmlid if it is not useful.

closes odoo/odoo#119813

Related: odoo/enterprise#42527
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2023-07-18 11:42:27 +02:00
Xavier-Do 88786dde49 [IMP] base, website: add an api to populate the cache
Part-of: odoo/odoo#119813
2023-07-18 11:42:26 +02:00
Xavier-Do b373c32c4d [FIX] base: don't invalidate for all company.write
The cron hr_presence will write hr_presence_last_compute_date on company
leading to an invalidation of the cache.

This commit makes the invalidation based on a list of field.

This may break some non tested behaviour, will be a good opportunity to
add test if any bugfixes is linked to this change.

Part-of: odoo/odoo#119813
2023-07-18 11:42:26 +02:00
Xavier-Do 595aa24843 [IMP] registry: multiple ormcache
One of the main issue with ormcache is that the invalidation clears
everything, meaning that some value, slow to compute but with a long
lifetime, can be removed from the cache because an easy to invalidate
value is cleared, like after writting or creating a product has an
example.

Most example in the code will try to invalidate the cache of the models
doing something like `env['ir.qweb'].clear_caches()` but it is
finally equivalent to `env.registry.clear_cache()`, and cross worker.

The idea is to have multiple cache, maybe with specific sizes for a
specific purpose.

Having one per model is maybe a bad idea because it will be difficult
to size the LRU correcly, and it is too dynamic. Checking invalidation
may be expensive.

The proposed solution is closed allow a limited number of named caches,
using onse sequence per cache. This is actually close to the
cache_longterm.

We want to discourage using a specific cache for one use case in
the buisness code. Adding a cache shouldn't be something easy, doable
in stable.

Note that we could also change the invalisation mecanism using an
insert only table. We an check the sequence of this table, but also
fetch all invalidation messages.
Another possible improvement, especially if we have more than x cache is
to have a global sequence, checking signaling would mean to check the
main sequence, and only the other ones if the main one changed.

Note that this poc is inspired from the long term cache but not all
use case where applie yet.

Part-of: odoo/odoo#119813
2023-07-18 11:42:26 +02:00
Xavier-Do dda0f64cf7 [FIX] base: avoid cache_invalidation on settings
A cache invalidation was triggered when displaying the settings page
because of a write on ir.property

    return call_kw(request.env[model], method, args, kwargs)
  File "/home/xdo/osrc/master/odoo/odoo/api.py", line 461, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/home/xdo/osrc/master/odoo/odoo/api.py", line 448, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/home/xdo/osrc/master/odoo/odoo/models.py", line 6689, in onchange
    record._onchange_eval(name, field_onchange[name], result)
  File "/home/xdo/osrc/master/odoo/odoo/models.py", line 6403, in _onchange_eval
    res = method(self)
  File "/home/xdo/osrc/master/enterprise/sale_stock_renting/models/res_config_settings.py", line 17, in _onchange_padding_time
    self.env['ir.property']._set_default("preparation_time", "product.template", self.padding_time)
  File "/home/xdo/osrc/master/odoo/odoo/addons/base/models/ir_property.py", line 203, in _set_default
    prop.write({'value': value})

This commit will avoid this by checking the current value.

Part-of: odoo/odoo#119813
2023-07-18 11:42:25 +02:00
uso-odoo 07f04e09f3 [FIX] base: prevent traceback while deleting Portal or Default User Template
When the user deletes the 'Portal User Template'  and when any new portal user
will do signup, then traceback will be generated.

If User deletes the 'Portal User Template', then no new portal user will be
created. Also, new portal user will see the traceback as it is generated in
UI.

Steps To Produce for Portal User Template:-

1) Install the 'auth_signup' module
2) Go to Settings > Users
3) Filter only 'Inactive Users'
4) Delete the 'Portal User Template'
5) Open the Incognito tab and click on 'Don't have an account?'
6) Fill required values and click on the 'Sign Up' button

Traceback will be generated on the portal user side as well as in the
backend (Terminal)

Steps To Produce for Default User Template:-

1) Go to Settings > Users
2) Filter only 'Inactive Users'
3) Delete the 'Default User Template'
4) Try to install 'website' or 'hr_timesheet' module

Traceback will be generated

Applying these changes will resolve this issue.

sentry-4184429514,4274176666,4147914005

closes odoo/odoo#127516

X-original-commit: c3e5bed9307498b435857f7736c20cefde3ed6a7
Signed-off-by: Vranckx Florian (flvr) <flvr@odoo.com>
Signed-off-by: Urvi Soni (uso) <uso@odoo.com>
2023-07-17 18:13:08 +02:00
Xavier Morel 4111f02fb3 [ADD] core: block requests calls during tests
Non-external tests should not be performing requests to external
websites or services.

Add a mock to handle such requests:

- if the test is not tagged external
- and the request is not to localhost
- and the request is not to `file:` (it's possible to install a
  FileAdapter in a session to resolve file URLs)
- raise a connection error (and log, both with some details of the
  blocked request for debugging)

The mock is layered on the lowest possible level (`Session.send`), so
tests can either:

- reconfigure the mock to handle cases differently (the mock is
  re-created on every test)
- layer their own mock at a higher level of the library

Eventually we might also built-in a routing / dispatch mechanism so
it's easier to declare external services you want to mock, somewhat
similar to what's available client-side.

Whitelist `file:` because e.g. zeep performs `file:` request, using a
bespoke adapter installed in its session.

Part-of: odoo/odoo#128497
2023-07-15 12:00:11 +02:00
Benoit Socias 706e696e3d [IMP] base, tools: compute webp image size
This commit introduces the computation of the image size from a webp
binary source without relying on PIL.

This is needed by eCommerce to determine which image to fetch when using
the zoom functionality on the product page.

task-2774352

Part-of: odoo/odoo#85494
2023-07-15 05:10:47 +02:00
Benoit Socias 0ba3617f9d [IMP] base, web_editor: precompute and use resized webp on upload
`libwebp` cannot be used to perform resize operations on webp images on
the server.

This commit uploads all resizes of webp images whenever a webp image is
uploaded:
- resized to any smaller size in 1024, 512, 256 & 128,
- each size converted to jpg as well to be usable in `wkhtmltopdf`.

When an Image field requires `_imageProcessing` to resize a webp image,
it retrieves the pre-resized image instead of running through the
Pillow toolbox.

Pre-converted images are stored as `ir.attachment`s with:
- `res_model` = ir.attachment
- `res_id` = id of transformed attachment
  i.e. id of original size webp for resized images
       id of webp for jpeg-converted images
- `description` = "format: image/jpeg" for jpeg conversions,
                  "resize: [size]" for resized images.

task-2774352

Part-of: odoo/odoo#85494
2023-07-15 05:10:46 +02:00
Benoit Socias 8210bf4f27 [IMP] base, web: use converted WebP images in wkhtmltopdf
Wkhtmltopdf is unable to render WebP images.
This commit intercepts the requests for the image data during PDF
reports rendering to replace them by the converted image that was
uploaded with it.

task-2774352

Part-of: odoo/odoo#85494
2023-07-15 05:10:46 +02:00