Commit Graph
5658 Commits
Author SHA1 Message Date
Yannick Tivisse 73483c8e5a [IMP] website: Revamp website settings
Simplify settings of website & website_sale;
- understandable
- relevant
- correctly ordered

Part-of: odoo/odoo#82999
2022-02-08 14:53:39 +00:00
Yannick Tivisse fd6bc0cb61 [IMP] base: avoid ormcache clear when setting ir.default to the same value
Purpose
=======

On the res.config.settings model for example, calling execute without
having changed a single parameter will make several writes on
ir.default records.

However, even if the written and the current values are the same,
the cache will be invalidated several times.

Part-of: odoo/odoo#82999
2022-02-08 14:53:37 +00:00
Yannick Tivisse f448b3314e [IMP] all: Improve res.config perf on method execute
Purpose
=======

Several actions are done even if nothing has changed on the configuration.

Example:
Writing on a cron the same value makes a dummy write-lock on the table
...

Part-of: odoo/odoo#82999
2022-02-08 14:53:36 +00:00
stefanorigano (SRI) 4a5dbf6a57 [FIX] web, *: float utility-classes
'pull-[left/right]' classes are discontinued since Bootstrap v3 [1].
The reason why we never noticed is that we were unknowingly
relying on fontAwesome utility classes that are basically the same.

Since v3 we were supposed to use 'float-[left/right]' classes [2], but
these classes will be renamed again in v5 with 'float-[start/end]'[3].

This commit introduces "v5 ready" utility-classes and replaces v2 legacy
occurrences across the UI.
These classes definitions can be safely removed when v5 migration will
be completed.

Notes:
- this commit will *not* adapt frontend occurrences since its CSS
  already relies on a "migration table" [4]. 
- this commit will *not* adapt the few v3 'float-[left/right]'
  occurrences since are supposed to be handled in the v5 migration
  task (task-2704984).

This commit is part of v16 overall restyle (task-2704984).

enterprise: https://github.com/odoo/enterprise/pull/23848
task-2745275

[1] https://getbootstrap.com/docs/4.3/migration/#utilities
[2] https://getbootstrap.com/docs/4.3/utilities/float/#classes
[3] https://getbootstrap.com/docs/5.1/utilities/float/#overview
[4] https://github.com/odoo/odoo/blob/15.0/addons/website/static/src/scss/compatibility/bs3_for_12_0.scss#L49

Part-of: odoo/odoo#83501
2022-02-08 12:05:53 +00:00
Victor Feyens a2991e458c [IMP] base: prefetch actions models in batch during /web menus loading
Gain of ~80% of the SQL queries & ~50% of execution time in a database
with test_main_flows & dependencies installed.

On a benchmark of 100 calls of (load_menus(True) + load_menus(False))

* 266 > 56 queries
* 0.38 > 0.21 sec of execution (mean)

Note that this only impacts the first request since this method is cached.
Unless user groups (or debug status) are different, the cached results
are returned.

closes odoo/odoo#83172

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-02-08 11:07:50 +00:00
Victor Feyens 65baadeb75 [IMP] core: do not try to translate selection values for nothing
When we are only trying to know accepted raw values, there is no
need to fetch the translations for the description part of the
selection tuples.

This performance problem was first observed on res.config.settings
record creation, where the values are pruned to avoid writes and
invalidation for unmodified related values (cf create override
in base/models/res_config.py & 5a4e7b711e).

After more analysis, the 'problem' also impacts record updates on
any related field (readonly or not).

* Res.config.settings performance gains:

In a database with test_main_flows (& its diverse dependencies),
this reduces by ~50% the number of queries done when triggering
the creation of res.config.settings record through the interface
(aka with all the related updatable fields receiving their current
value as create value).

For the creation of 150 res.config.settings records, with full cache
invalidation between each record creation, we notice a gain of:

* 11853 to 6303 total queries
* 11.2s to 7.5s total creation time

Part-of: odoo/odoo#83104
2022-02-08 11:07:46 +00:00
Victor Feyens 856c1691c7 [IMP] core: improve test coverage of selection fields
Part-of: odoo/odoo#83104
2022-02-08 11:07:46 +00:00
Victor Feyens 3d9efc7b5c [IMP] base: clean modules installation logic
* batch module data prefetch in res.config.settings flows.
* manipulate ir.module.module records instead of a strange list of tuples
* Only keep the missing module names logic where useful (useless for the
res.config.settings scope, modules must exists to be referenced by
a settings field).
* drop the support of module fields of type selection, they are not used anymore,
it's not even sure they still work and this feature doesn't bring much added value anyway.

Part-of: odoo/odoo#83104
2022-02-08 11:07:45 +00:00
Victor Feyens 9a0bf4785d [IMP] base: display query counts on profiling records
closes odoo/odoo#83746

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-02-08 10:03:59 +00:00
Christophe Simonis beb6a719bc [FIX] core: do not translate html attributes without actual content
The issue has been introduced by 1fe4b0cc1981382cc3d944ec44276f0aee90945d.

A simple example is an element with attribute "string" like

    <field name="foo" string=" "/>

When the translation process is parsing the value of the attribute as
some HTML fragment html.from_string(" "), it raises an exception.  This
was not a problem before the commit above, but it now is.  For instance,
updating the view "event.view_event_form" triggers the error.

closes odoo/odoo#84144

X-original-commit: 5ffc1704162d8918985964b08f4b2b49e6054958
Signed-off-by: Raphael Collet <rco@odoo.com>
Signed-off-by: Christophe Simonis <chs@odoo.com>
2022-02-08 00:07:26 +00:00
Victor Feyens 272d47868c [IMP] core: do not call create without values
Whenever a record is modified in a demo/data file,
create will still be called, but with an empty list of values.

This flow is correctly managed in the core orm code, but a lot of
custom logic in create overrides is triggered for nothing.

This commit makes sure that create is not called with an empty list
when there is no record to create (i.e. only records to update)
during files imports (including modules demo/data loading).

Part-of: odoo/odoo#84055
2022-02-07 15:24:49 +00:00
Victor Feyens 4d4108e3d1 [IMP] base: correctly prefetch currency fields on monetary updates
closes odoo/odoo#81423

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-02-07 14:17:50 +00:00
Victor Feyens a6c786090c [IMP] test_new_api: test precompute monetary fields
Part-of: odoo/odoo#81423
2022-02-07 14:17:50 +00:00
Paolo (pgi) ee324e8374 [FIX] web, l10n_ch: Error Correction Level QR Bill
l10n_ch QR bill report needs level 'M' (15% red.)
instead of default level 'L' (7% red.) as per:

https://en.wikipedia.org/wiki/QR_code#Error_correction

See specifications at:

https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf

The layout of higher level of Error Correction
are made of a thicker grid with more squares
(more information) at the cost of them being smaller
(a little harder to be read by the scanner).

opw-2584899

closes odoo/odoo#82932

X-original-commit: 0f374b61a6f3b25a1f986afe455c0e42797a5769
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Paolo Gatti (pgi) <pgi@odoo.com>
2022-02-04 19:44:38 +00:00
jpr-odooandBenoit Socias 1bd4f3c7bd [IMP] base, website: prefill the country phone code in website forms
Before this commit the phone fields inside forms did start in a blank
state.

After this commit the empty phone fields are pre-filled with "+" and the
country phone code.
The country is determined based on the IP address with the GeoIP
database.  The phone code is obtained from `res.country` where it is
kept in cache.

task-2463563

closes odoo/odoo#78068

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Co-authored-by: Benoit Socias <bso@odoo.com>
2022-02-04 16:53:54 +00:00
Christophe Monniez 8cc0a225a5 [IMP] core: bump master release to 15.3 alpha
closes odoo/odoo#83945

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-02-04 11:48:34 +00:00
Victor Feyens 405c0dcc9c [IMP] core: warn on duplicate files in manifest data/demo
closes odoo/odoo#83775

Related: odoo/enterprise#23901
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-02-04 07:18:51 +00:00
a6f310fca3 [FIX] base: ignore tags in translations matching
When comparing existing translations to new source value
html tag would invalidate existing translations.
The html tags used for styling (coloring, italic, ...) should not
invalidate the translation as the meaning of the text as not changed.

Changed the logic to compare translations based on textual content only.

+ add some tests.

task-2667950

closes odoo/odoo#83895

X-original-commit: 1fe4b0cc1981382cc3d944ec44276f0aee90945d
Signed-off-by: Antoine Guenet <age@odoo.com>
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
Co-authored-by: rco-odoo <rco@odoo.com>
Co-authored-by: xmo-odoo <xmo@odoo.com>
2022-02-03 11:45:55 +00:00
Gorash e830953570 [IMP] IrQweb: refactoring and add technical documentation
Major changes:
- Remove some of the recursively when compiling
- Compile attributes became a directive
- Compile options became a directive
- `t-field` compilation now uses the same logic as `t-out`
- Simplification of ``t-if`` directive compilation
- Improved handling of errors wrapped by QWebException
- Constants defined outside the class

    Odoo
     ┗━► _render (returns MarkupSafe)
        ┗━► _compile (returns function)                                        ◄━━━━━━━━━━┓
           ┗━► _compile_node (returns code string array)                       ◄━━━━━━━━┓ ┃
              ┃  (skip the current node if found t-qweb-skip)                           ┃ ┃
              ┃  (add technical directives: t-tag-open, t-tag-close, t-inner-content)   ┃ ┃
              ┃                                                                         ┃ ┃
              ┣━► _directives_eval_order (defined directive order)                      ┃ ┃
              ┣━► _compile_directives (loop)    Consume all remaining directives ◄━━━┓  ┃ ┃
              ┃  ┃                              (e.g.: to change the indentation)    ┃  ┃ ┃
              ┃  ┣━► _compile_directive                                              ┃  ┃ ┃
              ┃  ┃    ┗━► t-if            ━━► _compile_directive_if                 ━┫  ┃ ┃
              ┃  ┃    ┗━► t-foreach       ━━► _compile_directive_foreach            ━┛  ┃ ┃
              ┃  ┃    ┗━► t-inner-content ━━► _compile_directive_inner_content ◄━━━━━┓ ━┛ ┃
              ┃  ┃    ┗━► t-options       ━━► _compile_directive_options             ┃    ┃
              ┃  ┃    ┗━► t-call          ━━► _compile_directive_call               ━┫ ━━━┛
              ┃  ┃    ┗━► t-att           ━━► _compile_directive_att                 ┃
              ┃  ┃    ┗━► t-tag-open      ━━► _compile_directive_open          ◄━━┓  ┃
              ┃  ┃    ┗━► t-tag-close     ━━► _compile_directive_close         ◄━━┫  ┃
              ┃  ┃    ┗━► t-out           ━━► _compile_directive_out             ━┛ ━┫ ◄━━┓
              ┃  ┃    ┗━► t-field         ━━► _compile_directive_field               ┃   ━┫
              ┃  ┃    ┗━► t-esc           ━━► _compile_directive_esc                 ┃   ━┛
              ┃  ┃    ┗━► t-*             ━━► ...                                    ┃
              ┃  ┃                                                                   ┃
              ┗━━┻━► _compile_static_node                                           ━┛

closes odoo/odoo#81024

Related: odoo/enterprise#22942
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2022-02-03 08:09:31 +00:00
Gorash 9ce5bc8881 [IMP] IrQweb: merge Qweb engine file qweb.py and ir_qweb.py
QWeb is the primary templating engine used by Odoo. It is an XML
templating engine and used mostly to generate XML, HTML fragments and
pages.

To create new XML template, please see :doc:`QWeb Templates documentation
<https://www.odoo.com/documentation/15.0/developer/reference/frontend/qweb.html>`

In **input** you have an XML template giving the corresponding input
etree. Each etree input nodes are used to generate a python function.
This fonction is called and will give the XML **output**.
The ``_compile`` method is responsible to generate the function from the
etree, that function is a python generator that yield one output line at a
time. This generator is consumed by ``_render``. The generated function is
orm cached.

In the graphic below you can see theresume of the call of the methods
performed in the IrQweb class.

    Odoo
     ┗━► _render (returns MarkupSafe)
        ┗━► _compile (returns function)                                        ◄━━━━━━━━━┓
           ┗━► _compile_node (returns code string array)                       ◄━━━━━━━┓ ┃
              ┃  (add technical directives: t-inner-content, t-tag)                    ┃ ┃
              ┣━► _directives_eval_order (defined directive order)                     ┃ ┃
              ┃                                                                        ┃ ┃
              ┣━► _compile_directives                              (recursive) ◄━━━━┓  ┃ ┃
              ┃  ┣━► _compile_directive                                             ┃  ┃ ┃
              ┃  ┃    ┗━► t-if            ━━► _compile_directive_if                ━┫  ┃ ┃
              ┃  ┃    ┗━► t-foreach       ━━► _compile_directive_foreach           ━┫  ┃ ┃
              ┃  ┃    ┗━► t-*             ━━► ...                                  ━┛  ┃ ┃
              ┃  ┃    ┗━► t-inner-content ━━► _compile_directive_inner_content ◄━━━━┓ ━┛ ┃
              ┃  ┃    ┗━► t-tag           ━━► _compile_directive_tag               ━┫    ┃
              ┃  ┃    ┗━► t-call          ━━► _compile_directive_call              ━┫ ━━━┛
              ┃  ┃    ┗━► t-out           ━━► _compile_directive_out           ◄━┓ ━┫
              ┃  ┃    ┗━► t-field         ━━► _compile_directive_field          ━┛  ┃
              ┃  ┃                                                                  ┃
              ┗━━┻━► _compile_static_node                                          ━┛

Part-of: odoo/odoo#81024
2022-02-03 08:09:31 +00:00
Gorash 39ce6f02a6 [IMP] Profiler: more QWeb directive informations in speedscope graph
Part-of: odoo/odoo#81024
2022-02-03 08:09:31 +00:00
Thibault Delavallée ef9429231c [IMP] various: update query counters
Notably after odoo/odoo@f9442f47eb query counters are heavily impacted
and a lot of them has lessened.

closes odoo/odoo#83832

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-02-02 18:14:54 +00:00
Sébastien Geelen (sge) 207a49275e [FIX] *: adapt some html fields in views
Some html field are not in their ideal style.
As the style for html fields is now dependent of
where you are in the xml view ( in group or not),
we have to adapt some views and flags some fields
to ensure they have the correct look.

This change is only be a visual enhancement
and should not prevent the function of said html fields
even if the views are not updated.

task-2637488

# Conflicts:
#	addons/mail/wizard/mail_compose_message_views.xml
#	addons/website_slides/views/slide_channel_views.xml

# Conflicts:
#	addons/sale/views/sale_views.xml

closes odoo/odoo#83792

Related: odoo/enterprise#23911
Signed-off-by: Antoine Guenet <age@odoo.com>
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
2022-02-02 09:03:44 +00:00
Lucas Perais (lpe) 60643090d3 [IMP] tests: support of touch feature detection for test suite
This commit brings the ability to use some feature detection
mechanism used in Odoo. The jquery.touchSwipe library
implementation requires the browser to get ontouch* events from
the window to be available to assert that the browser has touch.

The switch will make the mechanism to work as expected, and
allow tests to use touch events while being correctly executed
because the library expects such events.

closes odoo/odoo#83588

Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2022-02-02 09:03:35 +00:00
Denis Ledoux a08a0b6454 [ADD] auth_totp_mail: 2FA using code sent by email
Add the possibility to force the two-factor authentication for all users,
using a two-factor authentication by email
when the 2FA using an Authenticator app is not configured for the user.

Two possibilities:
 - Force the 2FA only for employee users using the system parameter `auth_totp.policy=employee_required`
 - Force the 2FA for all users, employees and portals, using the system parameter `auth_totp.policy=all_required`

closes odoo/odoo#83750

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-02-01 17:15:30 +00:00
std-odoo d497dbe919 [IMP] fetchmail_gmail, google_gmail: simplify the mail server form view
Purpose
=======
A field `use_google_gmail_service` has been used in stable to define
a mail server which use Gmail authentication.

But now that the fields `smtp_authentication` exists, we want to use it
to simplify the mail server form view. For the incoming mail server,
the field `server_type` will be used for the same purpose.

Add a new field to have the option to install `google_gmail` in the
main settings page.

Task-2170676

closes odoo/odoo#83413

Related: odoo/upgrade#3199
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-02-01 15:32:16 +00:00
Rémy Voet (ryv)andrco-odoo f9442f47eb [IMP] core: bulk insert
The `_create` don't batch the SQL request to insert of data which it
isn't efficient we there is a several record to create.
Batch the SQL insertion and measure performance
depending of batch size to avoid any regression (see result in the
PR: https://github.com/odoo/odoo/pull/80961).

task-2299314

closes odoo/odoo#80961

Signed-off-by: Raphael Collet <rco@odoo.com>
Co-authored-by: rco-odoo <rco@odoo.com>
2022-02-01 14:37:43 +00:00
Rémy Voet (ryv) 27fe7bf3a3 [REM] core: remove check decorator
The `check` decorator in  `sql_db.py` was on a lot of `Cursor` methods.
It checks if the cursor is close before be using a the method.
Remove it because:
- It is completly redundant because `psycopg2` do already the job
to check the cursor before usage.
- It complicated the call stack and lead to a small overhead of
highly use methods (can be more than 1% of the execute call)
- Also the nature of
the Error isn't correct: raise `OperationalError`
(https://www.psycopg.org/docs/module.html#psycopg2.OperationalError)
instead of  `InterfaceError`
(https://www.psycopg.org/docs/module.html#psycopg2.InterfaceError).

Part-of: odoo/odoo#80961
2022-02-01 14:37:42 +00:00
Rémy Voet (ryv) 5fb6200f46 [REM] base: remove field attribute 'deprecated'
It was only used one time on a unused field.
We don't want to keep useless fields anymore,
the migration is done for that.

task-2735546
odoo/upgrade#3194

closes odoo/odoo#82727

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-02-01 10:54:19 +00:00
Rémy Voet (ryv) 3189b031a2 [REF] base: simplify the _write
Issue:
`_write` checked that the number of modified row in DB was equal to the
number of ids in the RecordSet (raise `MissingError` if not).
This behavior was only used by the ORM to retry
(with exists() on the RecordSet before) if the Missing Error raised.
Then it makes the job a second time (for no reason).

Then:
- Remove the check of number of row (and simplify the call of `_write`)
- Remove the useless return value (always `True`)
- Remove the `set(` before the `split_for_in_conditions`, it adds
randomness for nothing because the `_write` should be call without
duplicate id (even if it is not the case, we don't care).

task-2735546

Part-of: odoo/odoo#82727
2022-02-01 10:54:19 +00:00
Rémy Voet (ryv) ae41be0c5c [REM] base: remove column_format of Field class
The `column_format` of the `Field` class was unused and create useless
noise in the ORM. Then remove it and simplify some flows.

task-2735546

Part-of: odoo/odoo#82727
2022-02-01 10:54:18 +00:00
Rémy Voet (ryv) 6000179384 [REM] base: remove _sequence attribute of BaseModel
The `_sequence` was only used for the insertion of data in the DB for
the `id` value. But in Odoo, the `id` is always a `SERIAL`, then the
PostgreSQL fill already the value by the right SQL sequence. Then,
avoid doing the job of the DB by ourselves.
Sadly, we need to manage the case when we create an empty record to
always get a valid query.

task-2735546

Part-of: odoo/odoo#82727
2022-02-01 10:54:18 +00:00
Christophe Monniez e34430c822 [IMP] various: implement _neutralize method
As an overridable _neutralize model method was added in a previous
commit, the method is now implemented for various models.

closes odoo/odoo#67825

Related: odoo/enterprise#19042
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2022-02-01 09:54:08 +00:00
Christophe Monniez 152310fe26 [IMP] core: add a neutralize CLI command
When debugging a database, it's sometimes desirable to neutralize it to
avoid undesired side effects like sending emails.

This commit adds a generic method `_neutralize` on models to neutralize
the current database. This method has to be overridden by modules models
that needs to be neutralized.

A new CLI command `neutralize`is now available that will permit to
neutralize a database from the command line before starting
investigations.

Pay attention that the neutralize operation cannot be reversed and should
only be used on a database copy.

Task id: 1818795

Part-of: odoo/odoo#67825
2022-02-01 09:54:07 +00:00
Thibault Delavallée 83a0df8693 [IMP] base: add a default signature on users
When creating a new user, add a default signature if none is given. It
should be a simple one like

```
--
<user_name>
```

Implement it using an editable computed field based on name. That way users
can set it explicitly as void, but changing user's name sets a default one
when it is not set.

Task-2712450 (Mail/Sale: Improve 'Pay Now' notification template)

Part-of: odoo/odoo#82167
2022-01-31 17:47:35 +00:00
Thibault Delavallée a018735ec4 [REF] base, mail, various: make get_access_action private and explicit
Purpose of this commit is to make ``get_access_action`` private as it is not
necessary to expose it directly. Website management is also made explicit
using a ``force_website`` parameter instead of relying on context key of the
same name. This allows to better understand the method code flow.

Contains also some code fix / improvements :

  * Website forum: update code to better skip the frontend redirection if the
    forum is not active and frontend is not forced;
  * Website slides: respect force website parameter in redirection;

Task-2710804 (Mail: Clean Mail.Thread API)

Part-of: odoo/odoo#82167
2022-01-31 17:47:32 +00:00
Thibault Delavallée 07fb346919 [IMP] various: update counters
Update some counters at latest runbot results, just to have updated counters.
Note that some counters are somehow not deterministic, hence not updating
everything.

Task-2712450 (Mail/Sale: Improve 'Pay Now' notification template)

Part-of: odoo/odoo#82167
2022-01-31 17:47:29 +00:00
Victor Feyens 34022a35aa [IMP] core: do not log 'loading demo' for nothing
when there is no demo data available for the given module

closes odoo/odoo#83675

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-01-31 16:52:42 +00:00
Tiffany Chang (tic) 3ebe1185a4 [IMP] base, requirements: support datamatrix barcode printing
reportlab package is already in use to print barcodes, but it requires
extra packages (pylibdmtx and libdmtx) to print Data Matrix barcodes.
Unfortunately the python3-pylibdmtx package is not currently in the
Ubuntu version being used by Odoo SaaS and odoo.sh => we cannot install
this package automatically. Therefore we leave both packages as optional
extra installs for users since pylibdmtx is available via pip3 and
additional libdmtx package can be installed at that time (libdmtx0b on
linux, other OS info in pylibdmtx pip page).

We default to Code128 to avoid blocking stacktrace in case
Reportlab cannot print Data Matrices.

Part of task: 2494740

Part-of: odoo/odoo#82389
2022-01-31 12:06:03 +00:00
Luis González 605c2de536 [IMP] base: do nothardcode user fields that trigger cache invalidation
Whenever a user is modified, if at least one of a predefinet-field list
is being touched (e.g. companies or groups), cache is automatically
invalidated. However, that field list is harcoded, which prevents it
from being inherited and extended.

This commit moves such fields to a separate method, which makes
possible to inherit such method and extend the list.

closes odoo/odoo#79986

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-01-31 07:24:11 +00:00
Raphael Collet 95d176c4df [FIX] base: do not put mockup class in future registries
Followup of #82838 and #82844

By default, every subclass of BaseModel is registered in a mapping for
the automatic discovery of model classes by registries.  Prevent
registration of the mockup class used for rendering the database manager
templates.

closes odoo/odoo#83626

X-original-commit: 3bce74b20f8c15befee453382e3ab4697bee6960
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-01-28 21:51:43 +00:00
Paul Morelle 0b22f4deee [FIX] base: keep cache when regenerating assets
When the assets are regenerated, the previous attachments are deleted.
This may happen during the execution of t-call-assets directives in a
qweb view.

However, some properties that have been accessed with a sudo() were
accessible in the cache. Clearing the cache during the view rendering
could lead to access errors, which wouldn't be present without this
directive.

This commit works around this problem by removing these attachments with
a SQL query, without relying on the classic unlink, so that the cache is
preserved in this case.

By the way, sanitize the filename when marking it for deletion.

closes odoo/odoo#83570

X-original-commit: 627d508edfb62449067a05b0e3c1a0004f0af32c
Signed-off-by: Raphael Collet <rco@odoo.com>
Signed-off-by: Olivier Dony <odo@odoo.com>
Signed-off-by: Paul Morelle <pmo@odoo.com>
2022-01-28 14:10:15 +00:00
Raphael Collet 75e6b645ac [IMP] core: install PG extension "pg_trgm" only if necessary
Task 2742526

closes odoo/odoo#83274

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-01-28 14:10:02 +00:00
Raphael Collet a1904aa6f6 [IMP] core: field index names
The possible index names have been renamed "btree", "btree_not_null"
(instead of "not null") and "trigram" (instead of "gin").

Task 2742526

Part-of: odoo/odoo#83274
2022-01-28 14:10:01 +00:00
Rémy Voet (ryv) 5a573c6f18 [IMP] base: don't prefetch translate field by default
Issue
-----
Via the field prefetch mechanism, when we need a value of one field
(not in cache of course), the ORM will prefetch all fields
(which has the attribute to `prefetch=True`, the default value of this
attribute is `True`) for all record ids in `_prefetch_ids`.
Then, for each translate fields (where translate is not a callable)
the ORM need to make a `LEFT JOIN` on the `ir_translation` to fetch the
translated value. For big model, it leads to a simple `SELECT` with
several `LEFT JOIN` on ir_translation but each LEFT JOIN have a cost
in the planner time (a small cost in the execution time) of PostgreSQL.

By example, for `product.template` (stock/sale/purchase installed),
there are 6 LEFT JOIN to get all translated fields (5 of this
fields are rarely used).

Proposed solution
-----------------
Deactivate the prefetch by default for all translate fields expect if
this field is the `_rec_name` of the model (which is more likely to
be used).

In the example on the `product.template`:
Without prefetching the translated fields, there is only one LEFT JOIN
(the name, which is translated but is the `_rec_name` of the model).
With the 6 translated fields to fetch, the
query takes 5 ms to plan and 2 ms to execute VS with 1 translate field,
it 1 ms to plan and 1.5 ms to execute.

Side change note
----------------
- All translate of fields of `website.seo.metadata` should be prefetch
to avoid lot of website errors (it is because, website put in cache data
in sudo before reading it without sudo)
- `description` (`mail.message.subtype`), `subject` (`mail.template`),
`body_html` (`mail.template`) should be prefetch to avoid lot of extra
query from mail module.
- `vat_label` (`res.country`) should be prefetch to avoid a extra query
for each website page.
- Increase some queryCount (when it is legit, due to `subtitle` of
`blog_post` or `description` of `event.type.ticket`, etc)

task-2738029

closes odoo/odoo#82896

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-01-28 14:09:56 +00:00
Rémy Voet (ryv) 1187bb798a [REM] base: remove unused method from ir_rule
Remove unused methods from ir_rule.py:
- unused _eval_context_for_combinations
- Depreciated and unused domain_get method

Depreciate duplicate method IrRule.clear_cache()

closes odoo/odoo#79073

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-01-28 14:09:50 +00:00
Rémy Voet (ryv) 27e194f86b [IMP] base: add company name for record rule error
In debug mode, when a company ir.rule raise a exception
for one or multiple records, a feedback message is
display with limited records information.
Add company name to these information to help the user to change
his current company to the correct one directly.

task-2628865

Part-of: odoo/odoo#79073
2022-01-28 14:09:49 +00:00
Xavier-Do 94bba79a2e [FIX] models: forbid model changes on xmlid
Before this commit, changing the model on an existing xml-id may lead to
strange results.

create any record in xml, ie: id=my_xid, model=new_model
=> Odoo will create a new external_id, pointing to (new_model, id=1)

change only the model in the xml, ie: id=my_xid, model=ir.cron
=> Odoo will use the id of the existing external_id with the new model
 and points now to (ir.cron, id=1)
AND REPLACE the ir.cron id=1 (autovacuum_job) with the data of the xml.

This commit simply prevent that by raising when trying to recycle the
same xmlid for another model. An explicit upgrade script to remove the
existing xmlid and corresponding records should be write.

closes odoo/odoo#83422

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-01-28 09:52:53 +00:00
baa 48749bfa0a [IMP] base: with arabic/english invoicing mandatory in UAE and KSA, a font that contains arabic characters is needed
closes odoo/odoo#79664

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-01-27 16:16:51 +00:00
Ivan Yelizariev d8262e9051 [IMP] core: commit each populating batch
This prevents memory issues on creating massive amount of records.
For example, on populating `account.move` table,
the process takes 10 time less memory, while execution time per batch is almost the same: ~1 minute.

closes odoo/odoo#82875

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-01-27 11:07:12 +00:00