Commit Graph
7115 Commits
Author SHA1 Message Date
Jorge Pinna Puissant ef424a9dc2 [REF] *: remove owl from linter's accepted global variables
Before this commit, owl was in the linter's accepted global variables.
This allowed  direct access to owl global object.

For instance, to use xml from owl, you could do :
`const { xml } = owl;`
or you could use it directly:
`owl.xml`

Now, owl is not accepted on linter's global variables anymore, so to
import xml, now you need to use a proper import:

`import { xml } from "@odoo/owl";`

task-id 3498859

closes odoo/odoo#137517

Related: odoo/enterprise#48364
Related: odoo/design-themes#709
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-10-05 10:21:53 +00:00
Louis (loco) 94b55d913b [FIX] web_editor, *: store the correct mimetype of an image with a shape
*: tools

Steps to reproduce the bug:
- Add an image on the website.
- Replace it by a "jpeg". Note that the mimetype of the image is
"image/webp" at the upload since [1].
- Add a shape on the image.
- Save and Edit.

-> If you check on the available "Format", the mimetype of the
"original" is "webp" but it should be "jpeg".

Before this commit, there were two types of mimetype data attribute:
- `mimetype`: the current mimetype of the image.
- `originalMimetype`: the mimetype of the image without a shape.
Before [1], it was also the mimetype of the original image. However,
since [1], the user has the possibility to change the mimetype of the
image so the "originalMimetype" attribute does not always refer to the
mimetype of the original image anymore.

To resolve the problem, another data attribute has to be introduced.
Here is a summary of the mimetype related attribute:
- `mimetype`: the current mimetype of an image.
- `originalMimetype`: the mimetype of the image before a shape has
been applied. It is needed when removing a shape to recover the correct
mimetype.
- `mimetypeBeforeConversion`: the mimetype of the original image. It is
needed in order to be able to change the format of an image and come
back to the original one.

In the case of an uploaded "jpeg" image on which a shape has been
applied, `mimetypeBeforeConversion` is "image/jpeg", `originalMimetype`
is "image/webp" (since [1]) and `mimetype` is "image/svg+xml".

The `loadImageInfo()` has been adapted to also handle the case of an
image that has already been loaded but that does not have the
`mimetypeBeforeConversion` attribute (for example all the images that
were uploaded on the website before this commit). In this case, the
mimetype attribute is kept and not set to the original one as the user
could have changed it.

[1]: https://github.com/odoo/odoo/commit/0449fe85cb0e1d639a4e1aeba26e90906f79254d

task-3449866

closes odoo/odoo#137424

X-original-commit: 730588b802506844e6ca54df312333bfd8df1d52
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-10-04 18:27:03 +00:00
Victor FeyensandMorgane Demesmaeker 6d1a78286a [ADD] sale_pdf_quote_builder:
When enable, this new feature adds the possibility to set a PDF header, footer and some product
documents to the quotation report.

These PDF can contains forms that'll then be filled using Odoo database.

This replace the previous sale quotation builder feature.

task-3249142

closes odoo/odoo#133773

Related: odoo/upgrade#5168
Related: odoo/documentation#5863
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Co-authored-by: Victor Feyens <vfe@odoo.com>
Co-authored-by: Morgane Demesmaeker <edm@odoo.com>
2023-10-03 19:19:57 +00:00
Carmen Bianca BAKKER c466b4751d [FIX] base: Prevent singleton ValueError on res.partner's barcode
Fixed the string en passant.

closes odoo/odoo#137356

X-original-commit: 56e44e157f316e7cb0edac7bd0976bea3cbf895c
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
2023-10-03 07:19:03 +00:00
Xavier-Do b67f50a57a [IMP] tests: improve logging of active patcher
Part-of: odoo/odoo#137215
2023-10-03 07:19:00 +00:00
Xavier Morel 9d3de1190b [FIX] core: make model decorators work better with decorator 5
Decorator 5 changed the default decoration method from a transparent
exec-ing to wrapper functions. This makes the decorators visible to
the profiler, and breaks one of the profiler tests as the stack traces
now differ between using decorator 4 and decorator 5. Amongst other
concerns, this is an issue because debian bookworm has updated
decorator to 5 (.1.1), and the next ubuntu LTS (which should be 24.04
hopefully codenamed Nefarious Nematode) will do the same (Ubuntu has
been providing decorator 5 since 23.04).

5.1 added a `decoratorx` function which corresponds to the old
exec-based `decorator`, however it doesn't have a `decorate`
version. So we have to flag the wrappers, instead of decorate-ing the
original method with them. This seems to have the same semantics so
why we were using `decorate` is not entirely clear why we were not
doing that previously (neither
b1e83fd7b8 nor #25383 really provide
explanations). Possibly because pylint is a dum-dum and requires
ignoring one of its rules?

Implement in 14 since it doesn't hurt even though the test in question
does not exist yet.

closes odoo/odoo#137323

X-original-commit: 52e92904eca3cdeaee734b0a83e2d3fb463e8b56
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-10-03 06:16:49 +00:00
diagnoza 19aa9c9ebd [REF] base: introduce hierarchical structure of menus
Introduces a hierarchical structure of some menus. Reasons:

1. Allows testing the child-parent relation of specifically those menus
that do not have `parent` or `parent_id` attribute in the source xml
using standard menus. It's likely a rare use case, but that's precisely
what we currently need in https://github.com/odoo/upgrade/pull/5163
2. Provides a unique example usage of menus written in this manner
as opposed to using the `parent` attribute

closes odoo/odoo#136069

Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
2023-10-02 08:03:41 +00:00
Xavier Morel 6c59eea421 [REM] base: use of PyOpenSSLContext in mail server
The mail server mostly doesn't use the intrinsic features of
`PyOpenSSLContext`, instead it pretty much just uses the underlying
`OpenSSL.SSL.Context`, just through the wrapper.

The only thing it actually uses from `PyOpenSSLContext` is
`load_cert_chain`, and since we are using a keyfile and are not using
a password this is equivalent to *two* function calls. Just perform
those two calls directly, remove all the indirections, and remove the
unnecessary import.

Bonus content: since 2.0 `load_cert_chain` reraises the inner errors
as `ssl.SSLError` which we don't handle, so we avoid this extra issue.

This was discovered because from 2.0.0 to 2.0.4 the
`contrib.pyopenssl` module was marked as deprecated (it was
undeprecated in 2.0.5) but regardless its use is an unnecessary
complication here.

closes odoo/odoo#137198

X-original-commit: e534bbed78a80d1ba0c8edd22e039e5cfb50e613
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-10-02 06:54:42 +00:00
Xavier Morel beb0c25a94 [IMP] core, bus: future werkzeug compatibility fixes
- `Response.charset` is deprecated since 2.3, `Response.set_cookie`
  accesses the currently-extent internal `_charset` directly until
  this too gets removed in Werkzeug 3.0. Add a `_charset` to
  `FutureResponse` so this does not crash.
- Bytes response headers are deprecated since 2.3, and will get
  removed in 3.0, passing bytes in websocket is completely unnecessary
  happenstance which is trivially fixed.

closes odoo/odoo#137145

X-original-commit: 66e3040d4ad9e03aabefebd4799f699ad30fca45
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-10-02 06:54:39 +00:00
Thibault Delavallée 42958e2f5e [IMP] base, mail, sms: directly limit available models depending on usage
Add a computed m2m field giving allowed models for the action. It allows to
avoid choosing the wrong models when designing server actions.

Remove a test that has no use: it checks a model_id field is available on
server action view while we don't want to display it as it is imposed by
the rule itself.

Task-3527758 (Base Automation Refactor Fiximp)
Part of Task-3527752 (Mail: The Pre-Major Freeze FixImpLint)

Part-of: odoo/odoo#137133
2023-10-02 06:54:38 +00:00
Thibault Delavallée b05e7e4da0 [FIX] base, mail, sms: fix server actions naming computation
Fix name compute method:

  * correctly call super in batch;
  * correctly filter records;
  * remove dependency on context key (which was missing in triggers);

In this commit we also consider the name update should always be done even
outside of automated rules context. Having a whole compute method relying
on a context key does not makes sense. As server actions are technical
records, having the name always being correctly updated is better.

Task-3527758 (Base Automation Refactor Fiximp)
Part of Task-3527752 (Mail: The Pre-Major Freeze FixImpLint)

Part-of: odoo/odoo#137133
2023-10-02 06:54:38 +00:00
Xavier Morel a92e88d547 [IMP] base: make tests less sensitive to babel / CLDR updates
Babel's named / implicit formats (short, medium, long, ...) come from
the CLDR, which can get tuned as debates get settled, cultures shift,
etc... as a result using these formats can break tests on any babel or
even CLDR release (technically nothing stops distros from updating
their bundled babel with new CLDR data).

b77eb98bbf6bc937efb7941802c0794ae3622094 previously did some
mitigation of this issue, but even if they're not yet in distros
further Babel updates (e.g. 2.12) already affect some of the patterns
we're using.

Proactively mitigate this issue more by only using explicit datetime
patterns (and time patterns, date is fine because it retrieves the
pattern from the lang rather than default to babel patterns) in the
date/time formatting tests. This means only specific terms still vary,
and those should be a lot more stable / reliable than e.g. futzing
with separators and minor formatting issues.

closes odoo/odoo#137181

X-original-commit: 3547e980428cc1dd11c8e82446e7d7f824b9f6f8
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-10-02 05:56:06 +00:00
Rémy Voet (ryv) eb0ba7f79b [IMP] core: check field groups for search domain and order
In order to boost the read security of groups on field, we now
check groups of field used in search domain and search order.

Part-of: odoo/odoo#135111
2023-09-29 14:48:09 +00:00
Xavier Morel e2752a04ff [FIX] safe_eval: 3.11 compatibility
Complement on 1e35315399 (#112450):
alongside the split between forwards and backwards jump we missed that
3.11 has a specialized version of each for the `is None` and `is not
None` cases. A use of that was added in standard in 16.5 (#120446) but
more generally it makes sense that server actions would support
conditional tests against `None`, probably...

closes odoo/odoo#137099

X-original-commit: 3227ae45fb79cd08a102aecb484e4f0a4f2597c1
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-09-29 13:11:58 +00:00
Jinal Patel 6609a56f8b [FIX] tools: Avoid to delete translation for Structured Model fields
Issue: Translation missing after upgrade when the customer had any
       other language except English and he changed the value instead
       of translation.

In this commit, avoid to delete the translation.

closes odoo/odoo#137087

Opw: 3489453
X-original-commit: b3bfdf676d0daedbd71501d153170f37e97c94d8
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-09-29 13:11:54 +00:00
Mahdi Cheikh Rouhou (macr) efea7e13c5 [FIX] base, test_read_group : process duplicated groupbys without lazy
Issue:
======
When you have duplicate groupbys with `lazy=False` you will get an error.

Steps to reproduce the error:
=============================
- Install timesheet
- Go to timesheet / reporting / By Employee
- Add a groupby by month for one employee
- I will show an error.

Origin of the issue:
====================
The timesheet component will the send a request for read_group having
`['date:month', 'date:month']` so we will have duplicated groupby which
will be processed later in `_read_group_format_result` which update the
value of `row[group]` for each group so the first group will have the
original values which is ok but the second one will have the updated
values by the first iteration which will result in error.

Solution:
=========
We need to check that the value is of class BaseModel to update it , it
means that's the first time encountered.

opw-3497803

closes odoo/odoo#137000

X-original-commit: 91d6dc7ed56f67d41adab90ec0019fbb920d9042
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
2023-09-29 08:07:02 +00:00
Julien (jula) d7bd885170 [FIX] base: merge partner with mixin field
__Current behavior before commit:__
The page crashes when we try to merge two partners and the
`mail.activity.mixin` model has a field with `ttype = "reference"`.

This is because a `search()` on a `mixin` model will always crash as
they are abstract class that don't represent real records.

__Description of the fix:__
Add a check to skip the iteration if `Model` is an abstract class (like
a mixin).

__To reproduce:__
1. Go to Settings > Technical > Fields
1. Create a new field
1. Set **Model** as `Activity Mixin`
1. Set **Field Type** as `reference`
1. Go to the Contacts app
1. Select two contacts
1. Click on Action > Merge > MERGE CONTACTS

opw-3458640

closes odoo/odoo#136880

X-original-commit: cb7589cb4bb3ede1b4c4d3f8d04c376a95d42247
Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
Signed-off-by: Julien Launois (jula) <jula@odoo.com>
2023-09-28 09:04:12 +00:00
Jorge Pinna Puissant b89f53095c [REF] base: remove unused test
Since [1] qweb library is not used anymore, rendering this test useless.

1 : 4b0a951af6

closes odoo/odoo#136610

Signed-off-by: Raphael Collet <rco@odoo.com>
2023-09-27 18:56:19 +00:00
Michael (mcm) 7422eb643c [IMP] *: remove legacy rpc
This commit removes the files ajax.js and rpc.js then adapts all the
places where their exports were used. For most of the changes, it's a
replace of `this._rpc({...})` by a new `useService("rpc|orm")` like
pattern in the widgets.

closes odoo/odoo#136271

Task: 3439226
Related: odoo/enterprise#47775
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-09-27 11:33:01 +00:00
Rémy Voet (ryv) f9e75d19a9 [FIX] *: Fix bad usage of 'like'/'ilike' operator
The 'like'/'ilike' operators automatically add the wildcard character
(`%`) at the beginning and at the end of the value. This commit fixes
the incorrect usage.

closes odoo/odoo#136007

Related: odoo/enterprise#47886
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-09-27 09:11:44 +00:00
Rémy Voet (ryv) 51a795d363 [FIX] core: '=like'/'like' doesn't use unaccent anymore
The `=like`/`like` domain operators are accent-insensitive, but still
case-sensitive. This is not really coherent, since `unaccent` is a best
effort to find records from the client, and it is the same idea behind
being case-insensitive. Also, `=like`/`like` cannot be used from the web
client, and we use them in domain to search from the Python side.

Moreover, adding `unaccent` to `=like` can be very inefficient when
searching for a prefix ('prefix%'). In fact, PostgreSQL can use btree
index to find prefix matches, but because we create dy default btree
index without unaccent (when we put
`index=True/'btree'/'btree_not_null'` on the field), PostgreSQL cannot
use this index.

Part-of: odoo/odoo#136007
2023-09-27 09:11:44 +00:00
Christophe Simonis 407542b008 [FIX] core: harden the legacy migrations package matching regex
Since odoo/odoo#122569, we now try to import the `migrations`
sub-package of each module to find upgrade tests.
However, this badly written regex match the OCA module `base_maintenance`,
which generate a RecursionError.

closes odoo/odoo#136549

X-original-commit: abd9e6686bdb1f84d67bd536d9cecda627cd001a
Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
2023-09-27 07:28:12 +00:00
Raphael Collet 758780c03b [IMP] core: remove parameter 'extra' from Query.join() and Query.left_join()
Part-of: odoo/odoo#134677
2023-09-27 03:01:45 +00:00
Raphael Collet 66a0cdd637 [IMP] core: make an API to get rid of Query._raw_joins
Part-of: odoo/odoo#134677
2023-09-27 03:01:45 +00:00
Raphael Collet b622ffc373 [IMP] core: use SQL wrapper in models.py
Part-of: odoo/odoo#134677
2023-09-27 03:01:45 +00:00
Raphael Collet 6a61d2b322 [IMP] core: use SQL wrapper in Query
Part-of: odoo/odoo#134677
2023-09-27 03:01:45 +00:00
Raphael Collet 353fbb33ef [FIX] registry: misuse of psycopg2.sql import
Part-of: odoo/odoo#134677
2023-09-27 03:01:44 +00:00
Raphael Collet 020ddc3a6b [IMP] core: introduce SQL wrapper
We introduce a new class of objects to wrap SQL code together with its
parameters.  It is designed to be easily composable and to discourage
SQL injections.  Its API is similar to the methods of module 'logging':
the code is a format string, and the positional parameters are meant to
be merged into it using the string formatting operator.

    # default and increment are parameters of the SQL code in first argument
    term = SQL("COALESCE(value, %s) + %s", default, increment)

    # term can safely be injected into another SQL, besides regular parameters
    query = SQL("SELECT %s FROM mytable WHERE id = %s", term, id_)

The SQL wrapper can return the final SQL code string as query.code, and
the corresponding parameters as query.params (list).  The cursor method
execute() can now take an SQL object, and execute it just like

    cr.execute(query.code, query.params)

It is quite easy to make SQL objects safe against SQL injections: if the
code is a string literal, then the SQL object is guaranteed safe,
provided the SQL objects within its parameters are themselves safe.

Part-of: odoo/odoo#134677
2023-09-27 03:01:44 +00:00
Florian Damhaut 91baffb746 [IMP] data_merge: merge company_dependent fields
Merge company_dependent fields when merginf base_partner

closes odoo/odoo#129175

Task-id: 3103035
Related: odoo/enterprise#44401
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
2023-09-26 21:35:12 +00:00
erl-odoo 8c62f4a563 [IMP] core: ease testing upgrade scripts in custom modules
Upgrade (aka migration) scripts are a core part of Odoo, allowing
database manipulations for modules during version changes.

Any module, including custom ones can run upgrade scripts, even if the
`--upgrade-path` flag (and with it, the `odoo.upgrade` sub-module) is
not present. Currently only the "standard" modules benefit of easy
upgrade script testing. Any custom modules that want to run tests of
their upgrades have to import the tests in the usual `tests` folder,
which is not ideal.

Therefore, to allow TDD and programmatic testing of upgrade scripts in
custom modules, the test discovery is here modified to also parse the
module's `migrations` and `upgrades` sub-modules for tests.

closes odoo/odoo#136505

X-original-commit: c924434d35f80c223491371a87da7eab18956004
Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
2023-09-25 17:11:32 +00:00
std-odoo 91979b0fcf [IMP] http_routing, website_slides: redirect the user on /slides on AccessError
Purpose
=======
When a user tries to reach a course, an AccessError can occur when we
unslug the URL. Instead of the traditional error page, we want to
redirect the users to /slides, and the error will be displayed there.

Task-3477630

closes odoo/odoo#135926

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-09-25 09:38:33 +00:00
jorv 16179c9399 [FIX] core: assert _get_func_code code argument
closes odoo/odoo#33682

Signed-off-by: bve-odoo <bve@odoo.com>
2023-08-28 15:15:19 +00:00
Martin Trigaux 07fd6277f9 [FIX] module: use file_path
The method get_resource_path is redundant with file_path but without
all the checks.
The method will be deprecated in master but make it use file_path in
stable.

closes odoo/odoo#136272

X-original-commit: 64ab4a6914dadd741cfe61d9bd1959ae4509a1ca
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-09-23 14:24:13 +00:00
Antoine (ande)andRémy Voet 2c377f4cb8 [FIX] base: external identifier traceback
Current behaviour:
Traceback when trying to create
a new external identifier

Steps to reproduce:
1. Activate the developer mode
2. Go to settings
3. Technical > External Identifiers
4. Click on "New"
5. Traceback

Cause of the issue:
Introduced by https://github.com/odoo/odoo/commit/3c62ca1eb96d571b2b686b5caee370324c589ab4
When computing display_name, the model
can be false, and not be in self.env

opw-3489581

closes odoo/odoo#136279

X-original-commit: 2462df26977acc9e3ccafd57863703aacd2f059e
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
Co-authored-by: Rémy Voet <ryv@odoo.com>
2023-09-22 15:06:09 +00:00
Bastien PIERRE 3192051806 [IMP] web: Add duplicate action on view list
Include the 'duplicate' action in the action menu in list view. The copy_batch
method will call the copy method with a loop to keep any existing override.

closes odoo/odoo#133977

Task-id: 3456679
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-09-22 15:06:01 +00:00
Damien Bouvy 264ec1c4dd [IMP] web: support explicit mobile view mode on window actions
Up until this commit, which view was displayed by default on mobile was
somewhat of a lottery.

Initially, only kanban views were considered as 'more adapted to mobile
devices' and used as a main fallback to display records who had a kanban
view in the window action definition.

The the concept of 'mobile-friendly view' was extended to map and grid
so that these views could take precedence over the kanban view in
specific circumstances (indsutry_fsm and timesheet_grid, both of which
are enterprise edition apps) - basically they were marked as
mobile-friendly not because they *are*, but because it was the only way
to override the kanban override.

But this comes with its lot of problems and limitations, namely that the
mobile friendly view will be found based on the order of view modes for
a window action, so if you have a window action with the view modes
`kanban,map,tree,form`, you will never be able to have e.g. the kanban
view shown on desktop by default and the map view on mobile.

This commit introduces the notion of a 'default mobile view' on window
actions so that one may decide on an *arbitrary* view mode to use on
mobile for an action - without impacting the ordering of views on other
models, etc.

Task-3460374

closes odoo/odoo#133608

Related: odoo/enterprise#46562
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-09-22 15:06:00 +00:00
Sébastien Theys cc9e2c147c [REF] web, mail, *: tests: remove legacy file utils
* = mrp

closes odoo/odoo#136141

Related: odoo/enterprise#47716
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-09-22 11:55:58 +00:00
Gorash ba1a5509fa [IMP] base: Remove context dependencies from get_views method
In this viewtiverse, the heroes remove the context dependencies for
`get_views`, from the views and python fields (such as domain). To reduce
inconsistencies and the number of rpc.

Current issues:
* There may be inconsistencies in views at the JavaScript level. Some
overrides modify the behavior of get_views or domains on fields via
context keys, therefore by changing the action, the rendering may be
different. However, these views are cached. However, the cache key
(Javascript) does not reflect the entire context, and requires additional
post-processing from the server.
* Multiple rpc for the same rendering. get_views being dependent on the
context, as soon as it changes, a new rpc is performed. In most cases,
when JavaScript needs the same view, there is no change depending on the
context, the rpc is useless.
* Inconsistency when rendering subviews, some views could be different
depending on the context, this context can be modified in the view itself
via the context attributes. However, the JavaScript client does not redo
an rpc for each change of these sub-contexts. Therefore the result may be
inconsistent.

Solution:
Limit as much as possible the number of context keys provided when calling
get_views, and use the context provided as a cache key. The authorized
keys are 'lang' and '*_view_ref'. For the cache key, options are added in
the get_views method.
Instead of using the context, it is inserted into python expressions.
This will be evaluated by JavaScript and thus avoids inconsistencies.

task-3414108
task-3414068

closes odoo/odoo#135145

Related: odoo/enterprise#47584
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-09-21 16:52:10 +00:00
abd-msyukyu-odoo ed0bf2baec [FIX] base: filled week groups should be dependent on the locale
How to reproduce:
- open CRM > Forecast
- group by Expected Closing > Week

Current behavior:
- some week numbers appear multiple times

Expected behavior:
- each week should only appear once

Technical explanation:
Since [1], week groups are dependent on the locale, but the
`_read_group_fill_temporal` method was not updated to also produce groups
dependent on the locale.

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

task-3478451

closes odoo/odoo#135952

X-original-commit: 980786e301bdf80a9a39260a95359431c5cb5e86
Signed-off-by: Damien Abeloos (abd) <abd@odoo.com>
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
2023-09-20 08:36:40 +00:00
Xavier Morel 4fec630081 [FIX] base: correctly check debug mode when formatting access errors
Intent of checking `group_no_one` was always to query the advanced
info / debug mode, however when the semantics of group_no_one got
changed in 31518bc09b this site was
missed, and now always displays "advanced" errors for internal
users. Which was not the intent.

Also since we're printing `display_name` and some of them annoyingly
hook onto context variables to show extended information, reset the
context to the user's default in order to avoid such
extended-formatting `display_name`.

Also fix "debug mode" in `TestIRRuleFeedback`, which has been broken
since time immemorial (likely as long as the group_no_one semantics
changed).

closes odoo/odoo#135940

X-original-commit: 9d3ffa6540c07e97b7160167756edd8e71f2308a
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-09-20 06:16:47 +00:00
Thibault Delavallée 8409ebe5fb [FIX] various: update query counters to runbot state
Update (some) query counters according to runbot state.

Also make some tests deterministic when involving company name.

Task-36879 (Mail: Support MultiCompany Aliases)

closes odoo/odoo#135288

Related: odoo/enterprise#47345
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-09-19 16:37:13 +00:00
Raphael Collet f012e33769 [IMP] core: warn about compute methods mixing stored and non-stored fields
We explicitly discourage a compute method used for both stored and
non-stored fields, because it may be unexpectedly update the database.
Indeed, we don't expect the computation of a non-stored field to update
the database.  Allowing this kind of compute method makes reasoning
about readonly code much more difficult, and would prevent readonly
transactions with such fields.

For instance, consider a compute method for both fields F (non-stored)
and G (stored), and assume that none of those fields are in cache.
Whenever F is accessed, the compute method is invoked, and both fields
are assigned, which potentially generates an SQL update for field G.
This is problematic if we require the current transaction to be
readonly.

Part-of: odoo/odoo#98565
2023-09-19 16:37:03 +00:00
Rémy Voet (ryv)andWilliam Henrotin a62baec7f6 [FIX] core: fix onchange first snapshot
The 'sale_ebay' module adds the `product_variant_ids` one2many field on
the `product.template` form view. The `product_variant_ids` view
contains `virtual_available` (depending on `uom_id`). When the user
changes the `uom_id` of the `product.template`, onchange is triggered,
it takes a snapshot of the previous data, and it will computes the
previous value of `virtual_available`. But the associated compute
method will fail with a traceback:

File "/data/build/odoo/addons/stock/models/product.py", line 199, in _compute_quantities_dict
res[product_id]['qty_available'] = float_round(qty_available, precision_rounding=rounding)
File "/data/build/odoo/odoo/tools/float_utils.py", line 54, in float_round
rounding_factor = _float_check_precision(precision_digits=precision_digits,
File "/data/build/odoo/odoo/tools/float_utils.py", line 29, in _float_check_precision
assert precision_rounding is None or precision_rounding > 0,\
AssertionError: precision_rounding must be positive, got 0.0

The `precision_rounding` is `0.0` because the `uom_id` of the product is
empty. It is is empty because we force the `uom_id` of the
`product.template` to be `False` in `initial_values` (before the
snapshot), and then the `uom_id` takes the value of its
`product.template` (`False`). But actually, the cache of the product
should be full with its previous values before doing the snapshot.
This was not the case because we only copy data from store fields
(see `fnames`). Then compute fields was computed after setting field
change to `False`.

opw-3334822
opw-3419392

X-original-commit: 5021e77ba52fac465a5d842ac04c0a3a22aea2dd
Part-of: odoo/odoo#135635
Co-authored-by: William Henrotin (whe) <whe@odoo.com>
2023-09-18 22:17:06 +00:00
Martin Trigaux bf81596aa7 [IMP] base: use es_419 and not es_MX as reference
And load only two languages, not three.
Faster to load and avoids ambiguity when a Mexican sees es_ES content

closes odoo/odoo#134785

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-09-18 22:17:02 +00:00
Chong Wang (cwg) 007d2bde2a [REF] translation: better get_po_paths
make the tool function get_po_paths to reduce duplicated code

Part-of: odoo/odoo#134785
2023-09-18 22:17:02 +00:00
Martin Trigaux dccc8f39d0 [ADD] base: add Spanish Latin America
Before es_MX was informally considered as the "reference spanish" as
we have an office in Mexico.
Create a new language that will be used by all the local variations of
Spanish and that we can push without overlapping with es_ES content.

Part-of: odoo/odoo#134785
2023-09-18 22:17:02 +00:00
Damien Bouvy 500a17a20a [IMP] base: correct symbol position for MVR currency
Source: http://www.mma.gov.mv/#/currency/currencysymbol

Task-3508431

closes odoo/odoo#135744

Signed-off-by: Bouvy Damien (dbo) <dbo@odoo.com>
2023-09-18 19:43:06 +00:00
Dawn Hwang fd1f6e1621 [FIX] base: Fix Swiss date and number formats
The fr_CH date format has been broken for years, with unnecessary spaces
after the period. This has been removed.

The de_CH thousands separator prematurely ends after the millions
because it does not loop indefinitely. This has been fixed as well.

closes odoo/odoo#135355

X-original-commit: 287a03224c9144bb547d2cf7cdc046b83b830a16
Signed-off-by: de Wouters de Bouchout Jean-Benoît (jbw) <jbw@odoo.com>
2023-09-18 10:14:05 +00:00
Ivan Rasputin 1711e91257 [IMP] core: test exporting of translation files
Static qweb files are not tested for syntax errors.
This commits adds a hacky way to do this job: we test exporting of translation files.

Inspired by the following PRs, that were made as a response for errors caught by sentry

* https://github.com/odoo/enterprise/pull/43975
* https://github.com/odoo/odoo/pull/128221

closes odoo/odoo#128445

Related: odoo/enterprise#44074
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-09-15 09:22:04 +00:00
Chong Wang (cwg) 13957b6281 [FIX] core: support cr.execute_values
psycopg2.extras.execute_values was introduced in PR #101237
however it pypasses the override logic for cr.execute. As a result
1. --log-sql cannot log these queries
2. assertQueryCount cannot notice these queries
...

This commit create a new api cr.execute_values to support the same SQL feature
without losing the override logic for cr.execute

closes odoo/odoo#131190

Related: odoo/enterprise#47374
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
2023-09-14 11:22:42 +00:00