Commit Graph
944 Commits
Author SHA1 Message Date
william-andre 9f13817425 [IMP] base: allow to add country flags on module kanban
The icons made for localization require tedious manual work where it
could be done easily with some css.

task-3166075

Part-of: odoo/odoo#108617
2023-05-10 04:14:49 +02:00
Stanislas Sobieski 7496a710b9 [FIX] cloc: avoid memory issue on big file
Before this commit:
Files that should be ignored in the manifest but aren't (js library for example)
it can happen that files have huge lines, the regex to substract the
comments will overuse memory.
For example, a file of 13M with a line of more that 8M characters, the
memory consumptions peak at 1.7G

The results might be different, but it's an acceptable compromise

closes odoo/odoo#120376

X-original-commit: 63b13af2e49a83168d4304a06b6489c4b86eabf6
Signed-off-by: Thibault Francois <tfr@odoo.com>
2023-05-03 13:57:17 +02:00
xO-Tx c99cd92c14 [FIX] website, tools: make select options translatable
Steps to reproduce:

- Go to a website page > Add a 'Form' block > Add a new 'Selection'
field.
- Go to the page (in 'edit_translations' mode) > The selection field
options are not translatable.

The goal of this commit is to make the select options translatable
by adding an intermediate `.o_translation_select` element.

This element will handle option's text translations from the linked
`<select/>`. The final values are copied to the original element
right before save.

opw-3233360

closes odoo/odoo#120363

X-original-commit: 5ff53d7f289ec531f8369a47d02bd58252bb98a5
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-05-03 13:57:08 +02:00
Michael (mcm) 517d3258f2 [REF] web,*: add dependencies param to odoo.define
This commit makes the `dependencies` param of
`odoo.define` mandatory. It was optional and when
omitted, a regexp read the function to find the
dependencies. We can simplify it now almost all js
modules have been converted to esm.
The transpiler already adds the param for the es
modules except if the module has an alias.

task id: 3271352

closes odoo/odoo#119145

Related: odoo/enterprise#40040
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2023-05-03 12:39:30 +02:00
Denis Ledoux e113d0dd6f [FIX] core, website_slides: incrementing public views
There was two issues regarding the slides public views counter

1. If the `public_views` is set to `NULL` in database,
`increment_fields_skiplock` wasn't properly incrementing the count.
Indeed, in SQL, doing NULL + 1 returns NULL
```sql
16.0=# SELECT NULL + 1;
 ?column?
----------

(1 row)
```
To have the result we expect, COALESCE must be used
```sql
16.0=# SELECT COALESCE(NULL, 0) + 1;
 ?column?
----------
        1
(1 row)
```

2. There is a mechanism, using the session,
supposed to prevent incrementing the public views
counter when a same user visits multiple times the same slide.
However, since 84d17e57e8
the visited slide was never actually added in the session,
because it was adding the slide id in a copy of the set
in session rather than adding in the set from the session.
Or, as this commit does, to re-assign the new set in the session.

closes odoo/odoo#119370

X-original-commit: fa5962d6f08979017842985004b3ec43416ee181
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2023-04-24 20:09:38 +02:00
Julien (jula) 0a267b3336 [FIX] tools: x_studio image field size
__Current behavior before PR:__
The size of an image field is guessed using the field name. For instance, an image field with `field_name = "XXXX_123"` is resized to 123 pixels when fetched.
This is can be an issue if a user creates an image field using studio in a form view.
If the user sets the label of the field as "Image 1", the technical name will become `x_studio_image_1`. Therefore, the image field will be resized to 1 pixel width.

__Description of the fix:__
Refactor the `image_guess_size_from_field_name` method to return `(0, 0)` when the field name starts with `x_studio_`.

__Steps to reproduce the issue:__
1. Open a form view (of any model)
2. Open studio
3. Add an image field with label "Image 1" (notice the technical name becomes in `x_studio_image_1` in debug mode)
4. Close studio
5. Upload an image on the created field
6. Save... The image is resized to 1 pixel width

opw-3242084
opw-3249632
opw-3253133

closes odoo/odoo#118960

X-original-commit: 3318f0e67da40983f52595aba933d8c8fd0f5cc5
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-04-24 16:57:44 +02:00
Michael (mcm) 1e1c447d0d [REF] tools: transpile esm to sync module
This commit changes the js transpiler to write sync module.
The goal is to remove all async module and simplify the
module loader in the future.

task id: 3265979

closes odoo/odoo#119186

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-04-21 23:46:16 +02:00
Julien Van Roy 29e2645f4e [FIX] tools: support recent versions of fonttools
Support recent version of fonttools. In particular, class `_TTGlyphSet`
was refactored between 4.37.1 and 4.37.2 and no longer has an `_htmx`
attribute. Instead, the new attribute `hMetrics` can be used to get the
metrics from htmx.

closes odoo/odoo#118571

See: https://github.com/fonttools/fonttools/commit/b818e1494ff2bfb7f0cd71d827ba97578c919303
Signed-off-by: William André (wan) <wan@odoo.com>
2023-04-20 15:21:42 +02:00
abd-msyukyu-odoo 4e115baaad [IMP] web_editor: fully implement oeProtected and oeTransientContent
With the introduction of Knowledge Behavior Component, came a need to create
html nodes which would have limited interactions with the editor. i.e. an Odoo
view already has everything it needs to function properly, and when it is
inserted in the editor, any manipulation on the selection or on the style that
could be done with it should be prevented. Another example would be the
/template block (will be renamed /clipboard in the future) that has a
non-editable part (buttons which have a definite action in Odoo, and which
should not be interacted with) as well as an editable part inside of it).

To solve this use case, this commit proposes to mark specific html nodes with
a `data-oe-protected` attribute which could have one of three values:
- "true"
  - Only mutations of type "attributes" can be registered on the node itself
    which has the `data-oe-protected="true"` attribute
  - Prevent mutations of children (and sub-children) from being registered by
    the mutationObserver of the editor
  - Prevent the selection handling when its anchor is inside a
    `data-oe-protected="true"` element, even if it is `contenteditable="false"`
  - Prevent the command hint
  - Prevent the usage of the wysiwyg toolbar
  - Prevent the dblClick tooltip
  - Prevent the editor sanitization `Sanitize.js`
- "false"
  - Designed to be contained inside a node with `data-oe-protected="true"`
  - Re-enable all features disabled by a parent node with
    `data-oe-protected="true" for the children of a node with
    `data-oe-protected="false"
- ("")
  - This is considered equivalent to have the `data-oe-protected` attribute
    set to "true" (like other html attributes).

Another attribute is added: `data-oe-transient-content`, with the following
values:
- "true"
  - Prevent the serialization of the children of the node, so they are not
    shared during a collaboration.
  - Transient nodes will be removed during `cleanForSave`, meaning that they
    will never be part of the html_field value in the database
- ("")
  - equivalent to "true"

The use case is an embedded view: there is a large quantity of nodes that
are not relevant to share nor to save, since it will be recreated with the
lastest data from the database, with the information relevant to the
currently active user each time it has to be rendered.

Note:
This commit does not handle the dynamic switch from a specific value for
`data-oe-protected` to another (i.e. switching from "false" to "" or "true").
This could cause a number of problems like:
- some mutations from when the value was "true" are not yet handled when the
  switch (to "false") happens => those mutations will be registered as if they
  were always under the "false" value, even though it is not the case.
- in collaborative, some nodes with oids that were not relevant (under the value
  "true") won't necessarily have the same oids in between collaborators.
  Therefore we cannot suddently listen to their mutations and expect the changes
  to be shared by switching to "false".
In conclusion: the `data-oe-protected` attribute value should stay the same
during the entire edition.

Task-2821374

Part-of: odoo/odoo#104680
2023-04-20 10:51:20 +02:00
Rémy Voet (ryv) e5b42a0a20 [IMP] tools: date_range accept date params
Part-of: odoo/odoo#110737
2023-04-19 21:58:27 +02:00
Antoine Dupuis (andu) 33a9db123a [FIX] tools: XSD: handle ZIP files with URL not ending in .zip
In the case of the Basque country EDI, the ZIP archive containing the
XSD files is located at
https://www.gipuzkoa.eus/documents/2456431/13761107/Esquemas+de+archivos+XSD+de+env%C3%ADo+y+anulaci%C3%B3n+de+factura_1_2.zip/2d116f8e-4d3a-bff0-7b03-df1cbb07ec52
which does not end in .zip due to the hash at the end.

The current mechanism for detecting whether the file is an XSD or a ZIP
does not handle this, so the ZIP can't be downloaded.

Instead of trying to guess the file type from the URL, we therefore try
to open the file as a ZIP, and if that fails, we assume it's an XSD.

closes odoo/odoo#118933

X-original-commit: 0f1b128a8bcb01ecd5ca8a8db1dfa41230ecadda
Signed-off-by: Josse Colpaert <jco@odoo.com>
2023-04-18 19:29:08 +02:00
Antoine Dupuis (andu) d1834758ea [IMP] tools, account: remove XSD crons; download XSD button
At the moment, XSD files are automatically downloaded at database
initialization, which is quite unnecessary.

The idea is to change Odoo's use of XSDs from being systematically
downloaded and used for validation to simply being available if desired
(e.g. for development or for customers who want them).

To achieve this, this commit does the following:

- remove the XSD download crons;
- provide a 'download XSDs' button in the Settings (next to the debug
  mode button) which is available in debug mode;
- skip XSD validation if any required XSD file is not present; and
- deprecate the 'force_reload' option.

Entreprise PR: odoo/enterprise#38350
Task id: 3010716

closes odoo/odoo#118790

X-original-commit: c8174c7914e567489de74b574b076467440bdb2d
Related: odoo/enterprise#39879
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-04-17 18:01:18 +02:00
Renaud Thiry f7e5fd7aab [FIX] base: use html method from lxml
Prior to this change the convert tool did could mangle
the value of html fields when importing static data.

This is because html does not support 'self-closing'
except for HTML5 where it is allowed on void elements (such as img).

Browsers will assume that they are opening tags, left unclosed.
<span/> becomes <span>
They will then try to repair them with variying degrees of success.

Example where it fails:
`<t><t/></t><t><t/></t>`
should become
`<t><t></t></t><t><t></t></t>`
but it becomes
`<t><t></t><t><t></t></t>`

i.e. instead of closing the 'self-closing' tag immediately,
it puts everything inside a single t node

More concretely:
```
<t t-if>
  <t t-out />
</t>
<t t-else>
  <t t-out/>
</t>
```
becomes
```
<t t-if>
  <t t-out></t>
  <t t-else>
     <t t-out></t>
  </t>
</t>
```
which is invalid

-------------------------
The fix is simply to tell lxml that we want to print the xml nodes
as HTML nodes. This will make sure the output is compliant with
the standard and keep the semantic clear for the browser.

The issue does not appear before 16.2, as jquery used to fix it
for us until an update here 9c41ee5091ac06ac3ca71aeac607195c70061e4a

task-3162320

X-original-commit: 8ff2e1018264972107f19755ecda352d78dfa829
Part-of: odoo/odoo#118710
2023-04-17 11:47:11 +02:00
Denis Ledoux 536e670f8c [FIX] http: ensure values of session are serializable when stored
closes odoo/odoo#86015
Signed-off-by: Julien Castiaux <juc@odoo.com>
2023-02-07 09:12:32 +01:00
Xavier Morel 8932d447aa [FIX] core: table_kind semantics (incorrect classification of toast as temp)
17c4f47b0a updated table_kind to return
`pg_class.relkind`, however the semantics are *not* the same, and that
was ignored: `relkind = t` is for *toast* tables, not *temporary*
tables. In `pg_class` the temporary-ness is instead signaled by
`relpersistence` (which applies to both tables and sequences), temp
(and unlogged) tables have `relkind = r`. `existing_tables` does that
correctly, possibly unwittingly.

While at it, upgrade `table_kind` to return an `enum` (whose value is
the old discriminant).

closes odoo/odoo#117444

Related: odoo/enterprise#39185
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-04-07 11:37:25 +02:00
Denis Ledoux 70a8758760 [FIX] core: convert_file and xml_import must ingore env.lang
Before revision 5bf1207c8c
a new environment was created for each call
at `xml_import` or `convert_file`,
with `odoo.api.Environment(cr, SUPERUSER_ID, {})`
meaning the context was empty, meaning the lang was never set

Now that we pass from end to end the environment,
the caller of `xml_import` or `convert_file`
passes his own environment, therefore propagating
his `context` variables, therefore potentially passing
a lang in the context.

Therefore, since this change, the lang of the user
is taken into account when calling `xml_import`/`convert_file`,
and it updates the translation term rather than the source term
for translated fields.

This could be an actual/intended valid behavior,
this needs to be discussed,
but currently the places where `xml_import`/`convert_file`
is called expects to update the source term,
not the translated term.
See for reference
https://github.com/odoo/odoo/pull/116780#issuecomment-1486506663

Therefore, as this is an unexpected/unintended change of behavior
of the refactor 5bf1207c8c,
and as code blocks calling `xml_import`/`convert_file` have not
been adapted, we prefer to play it safe
and revert the behavior to what is was.

This is very possible other context keys will need to be dropped,
but one of the desired change of the refactor was to be
able to pass keys in the context, currently we prefer
to not wipe the environment context and just blacklist the one we
do not want to propagate, such as the lang.
If other related issues arise, we will then re-consider.

closes odoo/odoo#117621

X-original-commit: 44fa57e52fbc853b7756a96c73c94baa469c99ca
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2023-04-04 16:02:09 +02:00
Julien Castiaux ca5ca24bc6 [FIX] core: check browser lang is installed
A visitor could visit a web page having a lang in its context that is
not installed in the databased he is connected to. The problem is that
visitors are not logged-in thus it is not possible to determine their
lang via their `res.users` preferences. The lang used instead is the
lang set in the `Accept-Language` header of the incoming request, that
header is set by various browsers in accordance to the user system
preferences or browser settings.

The browser lang (`Request.best`) is only parsed according to the
`babel` database, it is a lang syntactically speaking but not necessary
a lang that is installed in the database.

At the moment the browser lang is set in the context (inside of
`Request._get_dbname_and_session`), it is not possible to verify it is
installed in the database as no connection to any database as been
established yet. Instead the lang is validated inside of
`ir.http._pre_dispatch` which is the method responsible to prepare/fix
various stuff on the request/session/context.

In regard to 93b684d3c7, we prefer to fallback on English, hence the
modification in `get_lang`.

closes odoo/odoo#116683

Reference-to: 93b684d3c7 ([FIX] base: lang should fallback on english instead of arab)
X-original-commit: 743e97667e44cdaab6db334d807cf3d409cea621
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
2023-03-28 10:30:02 +02:00
Roy Le 42d498f672 [FIX] translate: cannot translate code outside of addons
before this commit, code in files for Odoo core which are outside of
root_path/addons/
e.g. odoo/models.py, odoo/service/model.py
cannot be translated. Because the translation tool thinks they don't
belong to any module

after this commit, by reusing the same logic while exporting these code
translations,
they will be translated by using po files of the 'base' module

closes odoo/odoo#116602

X-original-commit: e29aca207e95725d4072fe2a6dfc928128c1e47b
Signed-off-by: Wang Chong (cwg) <cwg@odoo.com>
2023-03-25 02:47:09 +01:00
HydrionBurstandwilliam-andre 4feb7ba3c8 [FIX] translate: upgrade interraction with l10n_multilang
When upgrading a database with `l10n_multilang` installed, the
translations kept were not the right ones.
Here is the process that was executed during the upgrade:
* `base` is loaded: registry is loaded with `translate=True`, which
  calls `convert_column_translatable`. This has the effect of setting
  the value of the field to `{'en_US': name}`, with only that language
  installed.
* `l10n_multilang` is loaded: the function `lang_install` is extended to
  copy the translations of the templates on the instanciated records.
* `l10n_*` is loaded: the translation values are loaded from the `.po`
  files. `lang_install` is called after the loading on the templates,
  copying the value on the records. The value on the records is now
  something like `{'en_US': name, 'fr_BE': nom, 'nl_BE': naam}`.
* `base/end-migrate` is executed: it copies the values coming from
  `ir_translation`, without overriding the values that are already on
  the record because of the order of the `||` operator.

This means that any value inputed by the user[^1] will be overriden by
the value in the `.po` files.

opw-3175383

closes odoo/odoo#115254

X-original-commit: 5d46cdee878d752b9a61a74762a8710be0890e9d
Signed-off-by: Christophe Simonis <chs@odoo.com>
Co-authored-by: william-andre <wan@odoo.com>
Co-authored-by: HydrionBurst <cwg@odoo.com>
2023-03-14 20:42:11 +01:00
Louis Wicket (wil) 9afe7c74c9 [IMP] *: remove "French spacing" 👺
According to Wiktionary, French spacing is "the archaic practice (though
still current in French) of inserting a space around colons, semicolons,
question marks, and exclamation marks". This is not standard practice in
English and most languages of the world.

The purpose of this commit is to start purging the code from this typo,
as it may reflect poorly on the software for some people.

closes odoo/odoo#114533

Related: odoo/enterprise#37853
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-03-14 15:52:10 +01:00
Xavier Morel e37109c8c3 [REM] core: support for werkzeug interactive debugger
With the special support for postmortem debugging removed, the
likelihood of needing / wanting the werkzeug remote debugger seems
even more remote (as it works in strictly less situations, only for
frontend non-json requests).

So remove that as well.

closes odoo/odoo#115176

X-original-commit: a2022783b652299155c460294c00dbced9b619ac
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-03-14 13:30:19 +01:00
Xavier Morel 09023b6f87 [REM] core: remnants of debugger support
It's done nothing since #78857 and it doesn't seem like anyone has
cared (found no issues or tickets).

Rather than restore the feature, just remove the leftover bits.

X-original-commit: 4a7cfc8844eb9b754f16f9d013452d5bde8770b5
Part-of: odoo/odoo#115176
2023-03-14 13:30:19 +01:00
Denis Ledoux 2541cf636b [REM] core: remove search_view from ir.actions
This field has been introduced in
https://github.com/odoo/odoo/commit/c68600cc5397700df4f40095c27723a2b1f90a22

The reason why is not really clear, given the commit message.

But, it looks completely unused nowadays.
We can therefore safely remove it.

In addition, this will save a lot of transferred data to the web client,
as currently all the fields of an action are read when the web client
loads an action,
including this one, which contains a long xml content.

For instance, with just base and the contacts modules installed,
to load the action of the Contacts menu,
it goes from 5.51kB to 1.05kB.

closes odoo/odoo#114041

Related: odoo/upgrade#4390
Signed-off-by: Rémy Voet <ryv@odoo.com>
2023-03-07 01:59:38 +01:00
Raphael Collet e962860c6f [IMP] core: introduce search_fetch() and fetch()
This fulfills the goal of searching and fetching fields in a single SQL
query.  We introduce the new method search_fetch() for that purpose.
Also introduce method fetch() to fetch some fields for a recordset if
they are not in cache yet.

The call graph is as follows:

    search()        calls   search_fetch()
    search_read()   calls   search_fetch() and _read_format()
    read()          calls   fetch() and _read_format()

    search_count()  calls   _search()
    search_fetch()  calls   _search() and _fetch_query()
    fetch()         calls   _search() and _fetch_query()

The methods _search() and _fetch_query() are usually the ones to
override to implement business-specific logic.  The method _search()
returns a Query object to retrieve the records that satisfy the given
domain and are accessible for reading.  The method _fetch_query() uses a
Query object to retrieve fields from the database and store them in
cache.

Also use search_fetch() to save one query in search_read() and the
reading of one2many fields.

Part-of: odoo/odoo#112126
2023-03-05 15:12:55 +01:00
Raphael Collet 46c23fd64d [IMP] *: _search() always returns a Query
Goal: make _search() always return a Query object, in order to make
search_read() in a single query when possible

Adapt the overrides of _search() towards the given goal.

Part-of: odoo/odoo#112126
2023-03-05 15:12:55 +01:00
Raphael Collet 136eb34f07 [IMP] core: _search() no longer uses a default order
This simplifies the use of subqueries by avoiding some costly default
order on the model or the idiotic order='id'.  Method _flush_search()
has been adapted accordingly.

Part-of: odoo/odoo#112126
2023-03-05 15:12:54 +01:00
Raphael Collet 7e6cff5479 [IMP] core: search() and _search() no longer have parameter count
The parameter in search() is redundant with method search_count(), and
was making the calls less readable.

The method _search() is aimed at always returning a Query object.  The
method can therefore never return an integer, hence the removal of the
parameter.  This does not actually remove any functionality from the
method; counting result is simply given by using it differently.

Part-of: odoo/odoo#112126
2023-03-05 15:12:54 +01:00
Raphael Collet 789c643925 [IMP] core: improve Query for subqueries
The goal is to be able to use Query objects for both subqueries and
known ids tuples.  This provides a single API for injecting either a
subquery or its resulting ids into another query.

Part-of: odoo/odoo#112126
2023-03-05 15:12:53 +01:00
Raphael Collet 537a60ffd1 [IMP] core: quote field "id" in SQL queries
Part-of: odoo/odoo#112126
2023-03-05 15:12:53 +01:00
Laurent Smet 955091e707 [IMP] account*: send&print with documents
Refactoring send&print wizard.
==============================

Main reason for this commit is that we want to let the user
decide when to generate the relevant documents / approvals
for its invoices. The natural choice is when the information
leaves Odoo. So now, each time the users decide to
download/send its invoices, he will be able to select the
relevant documents to be generated and the approvals to be
requested from the send&print wizard.

This used to happen automatically during the posting with lots
of undesirable behaviors (difficulty to update/revert, hard to
know exactly what will happen,...)

Main changes:

1/ Send&print wizard

- The model 'account.invoice.send' has been replaced by
'account.move.send' and became models.Model to handle
asynchrounous generation of documents (webservice,..) in
case of more than one invoice.

- The wizard is meant to be overriden in order to add
checkbox and document to be generated. A comprehensive exemple
can be found in account_edi_ubl_cii.

2/ Import invoice from attachments

- The decoding logic has moved from account_edi to account
on the attachemnts.

- The function _extend_with_attachments() serve as a common
entry point for import (from chatter, dashboard).

3/ Export invoice pdf / document

- All the specific actions to export attachments should be
implemented on the account.move and called from the wizard in
 _generate_documents()

- The official pdf for the invoice is now only generated once
 the user request it. In order to regenerate the pdf and
documents, it needs to be deleted.

task-id: 3117238
[enterprise](https://github.com/odoo/enterprise/pull/36757)
[community](https://github.com/odoo/odoo/pull/111857
)

[IMP] web: enable close on ir.actions.act_url in wizard

Before this commit, calling ir.actions.act_url on a modal
leaves the modal open. Which feels ackward in the send&print
wizard.

We now enable 'close' parameter on ir.actions.act_url. If set,
the wizard will close after act_url.

closes odoo/odoo#111857

Related: odoo/enterprise#36757
Related: odoo/upgrade#4387
Signed-off-by: Laurent Smet <las@odoo.com>
2023-03-03 19:10:10 +01:00
Xavier Morel 0d5b9d2030 [IMP] core: increase FileStorage buffer size
Closes odoo/odoo#83176

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-01-23 09:32:06 +01:00
Christophe Monniez bcf9ba01dc [IMP] base: adapt for PyPDF2 >= 2.0.0
X-original-commit: 8e0564dff20876105295a1efec0bc519f4bd1aeb
Part-of: odoo/odoo#113354
2023-02-22 12:42:59 +01:00
Christophe Monniez a3dffa86f5 [FIX] base, tools: use getlocale vs deprecated getdefaultlocale
As getdefaultlocale is deprecated in 3.11 in favor of getlocale which is
available since at least 3.0.

Part-of: odoo/odoo#112450
2023-02-14 08:03:23 +01:00
Pierre Masereel 1e35315399 [FIX] odoo,base: new Python 3.11 opcodes
When python expression is evaluated in odoo form an action or qweb, we
are checking the opcodes generated by the evaluation of this code. We do
such a verification, because the code from actions and templates can be
written by someone having not access to the server and we don't want to
let them perform actions out of the scope of their database.

In python 3.11, some opcodes from previous versions of Python have been
renamed, grouped or sepcified. There are also new ones that have been
introduce.

In this PR, we are whitelisting the new ones that are needed by odoo to
properly work in this version of Python.

Part-of: odoo/odoo#112450
2023-02-14 08:03:23 +01:00
Abdelouahab (abla) 82e17cff03 [FIX] account: print image in pdf
To Reproduce
============
- create a vendor bill and add an image as attachment
- print Original Bill -> the generated pdf can't be loaded

Problem
=======
when trying to add an image attachment to pdf report, the image needs
a special process.

Solution
========
add the image processing when printing pdf
fix inspired from 15 [commit](https://github.com/odoo/odoo/commit/b82a6cdea21a66588ddcafcdfb5026ec22546745)

opw-3127535

closes odoo/odoo#112596

X-original-commit: 41c79f66cfb5cdb558110d32842198157932397e
Signed-off-by: William André (wan) <wan@odoo.com>
2023-02-13 23:42:06 +01:00
Nicolas Bayet 9731e9be6d [FIX] web_editor,project,note: ensure same history
This commit add a mechanism to ensure that someone could never save
changes from an history that diverge (in case there is a partition in
the RTC network or a person A was disconnected while another person B
saved changes that were not transmitted to person A).

task-3002163

closes odoo/odoo#112099

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-09 10:49:00 +01:00
Chong Wang (cwg) 6346f52acf [ADD] transifex: add transifex module to help translation
model/model_terms translations:
A transifex link if available is displayed after the language in the translation
dialog to help translators to contribute their translations. The tooltip message
for mouse hovering is 'Contribute'

code translations:
Setting -> Translations -> Application Terms -> Transifex Code Translations

In order to reuse the list view and search bar, model transifex.code.translation
is created to store all code translations.
This model is
1. readonly
2. reloaded on demand/by cron(7 days) to avoid increasing the Odoo restart time
3. updated for new installed modules/languages while opening the list view
4. shared to all users without duplicated translations

closes odoo/odoo#111685

X-original-commit: 7b30badb52e2a948c41f4340a01f6118818c6711
Signed-off-by: Raphael Collet <rco@odoo.com>
Signed-off-by: Wang Chong (cwg) <cwg@odoo.com>
2023-02-03 06:05:51 +01:00
tsm-odoo fa028a18df [FIX] bus: make bus_service recover faster from offline/online switch
Before this PR, recovering from an offline/online switch could
take up to 20mn. Indeed, WebSocket are based on TCP that uses
FIN packets to close the connection. In case of a sudden loss
of internet connection, the client is unaware of the already
dead TCP connection. It is up to the browser to assume the
connection is dead after some time.

This commit solves the issue by closing the connection properly
upon the reception of the offline event. When the client is back
online, the connection is opened again thus allowing an almost
instant recovery.

At the same time, this PR increases the default keep_alive_timeout
for websocket connections. Indeed, those re-connections lead to cursor
usage bursts and are not required so frequently.

closes odoo/odoo#111274

X-original-commit: d3a3792e5247cc41a58b47d148d4adf4fb0e4631
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-02-02 18:46:02 +01:00
Denis Ledoux 5bf1207c8c [IMP] base, *: re-use env during registry loading
The goal of this revision is to re-use the environment among the
different steps of the registry loading,
instead of creating a new environment for each step.

1. Simply To avoid to repeat the line
   `env = api.Environment(cr, SUPERUSER_ID, {})`
   multiple times in the code
2. This also allows to share the context among the different
   steps. This is not yet used in this revision, but it could
   be, for instance to avoid the current repetition to add the keys
   `install_module`, in `convert_csv_import` and `xml_import._tag_record`

Part-of: odoo/odoo#108254
2023-02-01 10:25:01 +01:00
Romain Derie fff31b316f [FIX] core: extract normalize from HTML sanitizer
Since [1], it's possible to conditionnally bypass the HTML sanitizer in field
definition with the `sanitize_overridable` attribute.
In a nutshell, when someone is part of the required group(s), it won't go
through the sanitizer, while the people not part of the group(s) will.

A behavior was thus introcuded to prevent a "restricted" user to wipe the
changes done previously by an "elevated" user (which bypassed the sanitizer).
But that behavior was not correct as there was unforeseen cases which led to
raise this error which are not due to the sanitizer but to normalization.

Indeed, while named `html_sanitize()`, it also does some normalize stuff on top
of the real sanitize part.
For instance, there is also (not exhaustive):
- some MAKO compatibility, replacing some chars
- special case for quotes, related to mail clients, which will add data
  attributes, add nodes in dom etc. This happen when the following are found:
  - `<blockquote/>` tag
  - text-based quotes (>, >>) and signatures (-- Signature)
  - html signature (-- <br />blah)
- some editor compatibility which removed the wrapping `<div/>` element
- `nbsp` handling..

See commit list below for detail about how/when/why those normalize cases where
introduced.

At the end, the issue was that the normalize part should not prevent a
"restricted" user to modify the content of an "elevated" user. Only the sanitize
part should.

For instance, the `Quotes` snippet dropped by an "elevated" user was preventing
further edition by a "restricted" user because there was a "false positive"
raised when checking if the save would wipe the existing changes.
Indeed, when the "elevated" user droped the snippet, it was saved as:
```html
<blockquote class=".." data-name="Blockquote">
```
But when the "restricted" user then wanted to do some changes, it would become:
```html
<blockquote class=".." data-name="Blockquote" data-o-mail-quote-node="1" data-o-mail-quote="1">
```

Same for `Share` snippet:
```html
<a href="https://www.facebook.com/sharer/sharer.php?u={url}">
<a href="https://www.facebook.com/sharer/sharer.php?u=%7Burl%7D">
```

[1]: https://github.com/odoo/odoo/commit/cf844e34dd0ce4830eb99fd0fa5b6b9cb58c867c

Normalize commit list:
https://github.com/odoo/odoo/commit/5f1ec49ecdac6d72cd42755c41fbe75d6a1f3587
https://github.com/odoo/odoo/commit/69af79ff3d705d19a71ba3ba7851b981cb301077
https://github.com/odoo/odoo/commit/2bcf4cca79a57dfba84d1f3e3fa7b8908bfe66e8
https://github.com/odoo/odoo/commit/f5688cd8fd515d1b668e8eb1d74de68faa681a01
https://github.com/odoo/odoo/commit/cb8c2d2b7e15c7c16e02d078767e27a07e5012c6
https://github.com/odoo/odoo/commit/275ee5825d38841a3eb21bb195722f3ceed09005
https://github.com/odoo/odoo/commit/b51d21c5b83b88e8d56dbbbb7600bcbe554d1b07

closes odoo/odoo#110903

X-original-commit: 3a2e82cf40f3265650b4f79f9ad5fe309906311d
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-01-25 05:06:02 +01:00
Romain Derie c5ebd4dc4e [REM] core: remove mako support in html sanitize
X-original-commit: 8f0f36a2199e738ed5a7905e4c76c5720347dbb5
Part-of: odoo/odoo#110903
2023-01-25 05:06:02 +01:00
Romain Derie 48c7827d6b [MOV] core: move tag_quote() method to ease reading next commit diff
X-original-commit: b1138e8cc5b8802e5a86315b66387e1576e25bab
Part-of: odoo/odoo#110903
2023-01-25 05:06:02 +01:00
Rémy Voet (ryv) f6cf94d4bd [FIX] *: ormcache works with annotation
The `ormcache` decorator fails to create the key method
(`determine_key`) when the method signature contains any annotation.
Fix it by removing annotation of the signature.

closes odoo/odoo#109777

Signed-off-by: Raphael Collet <rco@odoo.com>
2023-01-23 14:25:14 +01:00
Renaud Thiry a64a72188b [FIX] mail: remove MAKO compatibility
Before this change URLs would get their url-safe encoding replaced
with regular characters when cleaning up
html content.

This caused signed URLs that use some of those characters to become
invalid if the target did not accept equivalent characters.

Concrete example:

/markers=size%3Alittle%7CAddress
is not the same as
/markers=size%3Alittle|Address
for google maps signed static urls

Do not add special handling for MAKO patterns
as they are not used in templates anymore

task - 3079113

Part-of: odoo/odoo#107200
2023-01-20 19:56:52 +01:00
Nicolas Bayet d51e62c6ae [FIX] web_editor: prevent nbsp convesion in html_sanitize
The fix #14569 was not complete. This fix solve the issue explained in
that PR.

The lxml cleaner transform any utf8 character `U+00A0` to a string
`&nbsp;`. This cause a comparison in the editor to be erroneous
inside `HtmlFieldWysiwygAdapterComponent.updateWidget` when comparing
a value coming from the server with the value coming from the editor.

task-3138358

closes odoo/odoo#110264

X-original-commit: 05e0f65c4120ec7e1420dacab8dc678b8a30f70a
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-18 17:38:26 +01:00
Benoit Socias 0bc3ae0ed5 [FIX] base: ignore spaces around text content when matching translation
When the same text appears several times inside a translated field but
nested in different HTMLs, the matching for each one is done
independently if various spacing appear in the HTML.

This commit strips the spaces around the matched texts so that texts
that are synchronized on purpose do not become desynchronized.
Doing this leads to collisions on the keys of `text2term`, it therefore
also has to replace it with a dictionary of text to list of terms.

opw-3098819

closes odoo/odoo#109798

X-original-commit: 6cec590a2dad43063d3bb747838393a8df13aa04
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-01-13 17:32:35 +01:00
Jordan D. (Joda) a57b214c7d [FIX] tools: add SQL comparaison to fix module translation
When installing both documents and fleet and then, add a translation to
the database. Both fleet and document will be translated the same way.
This is due to the fact that both of them share a lot of similar value
inside of the PSQL database.

opw-3120320

closes odoo/odoo#109700

X-original-commit: fff53f845398ee0f8632cf7cb392f108388f3dc4
Signed-off-by: Raphael Collet <rco@odoo.com>
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2023-01-12 12:27:10 +01:00
Julien Castiaux c59750d824 [IMP] core: smarter geoip
Maxmind offers multiple ip-geolocalization databases, historically we
have been using the City database which contains records on a
city-basis. Many years later it turns out we are primary using geoip to
know the country of the user. Geolocalization in the City database is
considered slow by our standard and we have been clever in order not to
geolocate each request by saving the info in the session.

On the other hand, the Country database that is offered by Maxmind is
much more lightweight and geoip using that country is considered a fast
operation by our standard.

In this work we make Odoo compatible with both the City and the Country
databases. Using multiple database at the same time, we can be smart and
only query each of the two on-demand. If a user ask for its country,
we'll use the fast Country db. If a user ask for its city/timezone we'll
use the slower City db.

By default it loads both database from the `/usr/share/GeoIP/` folder,
respectively the files `GeoLite2-City.mmdb` and `GeoLite2-Country.mmdb`,
you can provide alternative paths using the `--geoip-city-db` and
`--geoip-country-db` CLI options.

In the same mindset as #86015, geoip is still lazy. It is done on-demand
and the result is cached on the current request. The different with the
related PR is that as we know consider geoip to be fast, we no longer
cache the result in the session.

Task: 2848206
Part-of: odoo/odoo#91337
2023-01-03 13:16:02 +01:00
Nshimiyimana Séna 3aeed55764 [FIX] tools: recognize SVG with explicit namespace
Currently, odoo's mimetype guesser does not recognize SVGs with explicit
namespace.

closes odoo/odoo#108938

X-original-commit: a1257cad9d5a63d940da041f355c13ea3eba90ce
Signed-off-by: Julien Castiaux <juc@odoo.com>
2023-01-02 20:39:49 +01:00
Nshimiyimana Séna 68f1529490 [FIX] tools: set correct mimetype for XML files
Currently, the mimetype detection for XML files always returns
`image/svg+xml`.

opw-3062131

closes odoo/odoo#108644

X-original-commit: 6ea9e75d5a14cfe4a846be69e05c3c18f1daffcb
Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-12-24 02:35:46 +01:00