Commit Graph
4165 Commits
Author SHA1 Message Date
Victor Feyens ab022ec12d [FIX] *: target v15.0 documentation with doc links
X-original-commit: acc95ec204baa1dddbe292c379a1768fe1deccbf
Part-of: odoo/odoo#77923
2021-10-07 17:59:52 +00:00
Martin Trigaux e132c36ee6 [I18N] *: export 15.0 source terms
closes odoo/odoo#77898

X-original-commit: ad5afb1d18661784bfcf51bca66e576de1f6c49b
Related: odoo/enterprise#21478
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-10-05 16:54:21 +00:00
qsm-odoo ea93bf26f6 [FIX] base: lazy load external files if part of a lazy loaded bundle
In the payment_adyen module, files of adyen are added as part of the
assets_frontend bundle. That bundle is lazy loaded on the website... but
those external files were not, as not added within the bundle itself.
This commit fixes that, properly lazy loading "remaining" files
out of a lazy loaded assets bundle.

closes odoo/odoo#77877

X-original-commit: 8dd71bdc42c8d4ab3373a2a0601c93d1687aabca
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-10-05 15:41:42 +00:00
Thibault Delavallée d6434fe846 [IMP] base: improve ir.mail_server form view readability
PURPOSE

Help people setuping their mail server with clear labels and form view.

SPECIFICATIONS

Rename Description to Name, as Description indicates a secondary text
field. Add a placeholder to indicate it is used as a functional name
and not a technical field.

Relabel the field for filtering to FROM Filtering. Current From Filter
could lead to think it filters incoming emails which is not the case.

Move button for testing in header as on all form views.

Use radio buttons for authentication and encryption to display available
settings directly to user. This is more user friendly than selection boxes.

Split connection information in two groups: authentication and security.
Each group comes with its options below main radio-based field.

Task-2628092

closes odoo/odoo#76301

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-10-05 15:40:36 +00:00
Moises Lopez - https://www.vauxoo.com/ ae7184eb21 [FIX] test_lint: Fix some false results
* [FIX] test_lint: Consider variables for sql-injection

Using the following code:

```python
var = 'SELECT name FROM account WHERE id IN {}'
values = (1, 2, 3)
self._cr.execute(var.format(values))
```

It has a risky sql injection ignored before of this change

And allow psycopg2.SQL way mapping the variables declaration

* [FIX] sql-injection: AttributeError: 'NoneType' object has no attribute 'parent'

Using the following code:

    queries = [
        "SELECT id FROM res_partner",
        "SELECT id FROM res_users",
    ]
    for query in queries:
        self.env.cr.execute(query)

The check sql-injection shows the following error:
 - AttributeError: 'NoneType' object has no attribute 'parent'

So, Now it is validating if it is not None

* [REF] sql-injection: Using better naming for node_ofc -> node_assign

* [FIX] sql-injection: Fix false positive using BinOp "+"

Considering the following valid case:

    cr.execute('SELECT ' + operator + ' FROM table' + 'WHERE')

The representation tree is:

    node.repr_tree()
    BinOp(
    op='+',
    left=BinOp(
        op='+',
        left=BinOp(
            op='+',
            left=Const(value='SELECT '),
            right=Name(name='operator')),
        right=Const(value=' FROM table')),
    right=Const(value='WHERE'))

Notice that left node is another BinOp node
So, it need to be considered recursively

closes odoo/odoo#77864

X-original-commit: ce1a0171f61d2808470c185a91e9f8299e4efd25
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-10-05 14:18:05 +00:00
Raphael Collet ea72b1ff32 [FIX] base: warnings with context key 'validation_views'
The context key 'validation_views' is used by ir.ui.view to determine
what parts of a view arch must be validated.  Its associated value is
either True or a recordset, and having those types leads to unexpected
warnings when creating environments.

Before creating a new environment, the class Environment looks for an
existing environment with the given parameters: cr, uid, context, su.
The comparison of a context where 'validation_views' is a recordset with
another context where 'validation_views' is True, generates the warning
"unsupported operand type(s)"...

We avoid this situation by using ids instead of a recordset for the
value of the validation context key.

closes odoo/odoo#77747

X-original-commit: 210cd625a052a4d3c230a93bcba644c9a31e67ab
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-10-04 20:23:51 +00:00
Simon Genin (ges) e3cf794cc1 [IMP] test_lint: add no-dupe-class-members rule
closes odoo/odoo#77719

X-original-commit: 591a94f6278abf51b114fd43870874c6ea8364ab
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-10-04 14:12:42 +00:00
b63ee52552 [FIX] *: remove scss 'extend' from dropdown components
This commit removes all the 'extend' initially introduced to avoid code
repetition and ensure visual consistency across Bootstrap and Owl dropdowns.

Despite achieving the desired results, using 'extend' in this context
was seriously impacting the bundle generation time, probably due to an
underestimated amount of Apps' legacy-code applied on these elements.

In order to achieve the same results, the chosen strategy is to add
Bootstrap default classes directly into Owl dropdowns.
Also, it moves code related to bootstrap dropdown in 'webclient.scss',
leaving 'core/dropdown/dropdown.scss' for Owl code only.

Due to the discrepancies between Bootstrap and Owl html
structure, the '.dropdown-item' class could not have been added
directly to Owl's '.o_dropdown_item' itself, without refactoring
the Dropdown component structure.

// ==== Bootstrap 4.6 default Structure ================================
<div class="dropdown-menu">
  <button class="dropdown-item" type="button">Action</button>
  <a class="dropdown-item" href="#">Another action</a>
</div>

// ==== OWL default Structure before this commit =======================
<ul class="o_dropdown_menu">
  <li class="o_dropdown_item">
     <span>Action</span>
  </li>
  <li class="o_dropdown_item">
     <a href="#">Another action</a>
  </li>
</ul>

// ==== OWL Structure after this commit ================================
<div class="o-dropdown--menu dropdown-menu">
  <span class="dropdown-item">Action</span>
  <a class="dropdown-item" href="#">Another action</a>
</div>

// ==== web.assets_backend.css Bundle Generation Comparison ============
With all modules installed (enterprise edition over runbot):
Before this commit, bundle took ~2.5s and ~4s to generate and weighted ~322kB (~2.5MB uncompressed)
After this commit, it takes between ~1.2s and ~1.6s and weights ~257kB (~1.6MB uncompressed)

closes odoo/odoo#77649

X-original-commit: 84715436d87bb05b421bc9ccaacda67d07571690
Related: odoo/enterprise#21370
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Co-authored-by: Stefano Rigano <sri@odoo.com>
Co-authored-by: François Georis <fge@odoo.com>
Co-authored-by: Bruno Boi <boi@odoo.com>
2021-10-04 07:57:00 +00:00
Xavier Morel 70dabd5661 [IMP] core: add TestCursor warning when finding unclosed test cursor
Because test cursors are implemented using savepoints, they should *at
most* be nested (ideally they would be strictly sequenced).

If upon being closed a test cursor finds a *different* un-closed
cursor at the top of the stack, one of its followers / children /
descendants was not closed before it, which is a problem.

The initial version of this would look for the cursor being closed in
the stack but this could lead to incoherent cursor stacks and errors
related to the management of the cursors stack, even though it only
exists for reporting reasons.

closes odoo/odoo#76243

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-10-01 15:26:51 +00:00
Xavier Morel 11c17318be [IMP] core, test_impex: use Savepoint in load and import tests
The query count increases by one because the old code (with
hand-rolled savepoints) never released the `model_load` savepoint.

Part-of: odoo/odoo#76243
2021-10-01 15:26:51 +00:00
Victor Feyens de7e0c6b06 [IMP] base: allow archiving menus through the interface
For the "Archive"/"Unarchive" button to appear in the contextual "Actions" dropdown,
the field must be present in the view (which wasn't the case until now).

This commit also fixes the indentation of the concerned view.

closes odoo/odoo#77596

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2021-10-01 12:41:03 +00:00
Xavier Morel 400b897cca [IMP] base: add some typing information to the report action
Though it can't really be typechecked it makes clearer what the
expectations are.

closes odoo/odoo#77577

X-original-commit: b28d2f5b9f7ca0656afe8020c1fa4b3c4eb5594b
Related: odoo/enterprise#21336
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-10-01 08:50:35 +00:00
Nicolas Bayet 4813f42997 [IMP] mail,*: replace jinja with qweb
Jinja as a templating engine was problematic in differents respect:
- introduce external dependency to Odoo (less controll)
- add another templating mechanism in the stack
- specific feature in qweb cannot be reused
- difficulty in rendering easily editable templates
- more knowledge required with no betterment

By replacing jinja with qweb we can now build tools to edit a qweb
that will work with the previously jinja encoded document
(essentially `mail.template` records).

There is a catch however. Some email fields (eg. email_to) used jinja
syntax for rendering dynamic variables (ie. ${object.something} and
${object.something_that_should_not_be_escaped | safe}).

We still want user to use dynamic variables for some char fields (eg.
subject, from, to, ...). We made a new rendering engine called
"inline_template" that will render an expression enclosed by `{{` and
`}}`.

To be able to edit the templates from the backend interface, a
plugin to the Odoo editor has been made for seamlessly edit the
document.

This qweb plugin includes:
- make dynamic variables (eg. `<t t-out="variable"/>`) not editable
  (for preventing the user to shoot himself in the foot)
- group and hide related logical branching (ie. t-if, t-elif, and t-else)
  in order to see only one at once
- a floating select input to switch visibility of a particular logical
  branching

Task-27033

X-original-commit: odoo/odoo@68182baff4
Part-of: odoo/odoo#77377
2021-09-28 23:42:54 +00:00
Raphael ColletandStanislas Sobieski (sts@odoo.com) 31c3f75396 [FIX] expression: avoid ORDER BY clause in subqueries
This fixes a performance issue: ORDER BY clauses in subqueries can make
the query unexpectedly slow.  We should avoid this situation, since
ORM-generated queries have an ORDER BY clause which is not relevant in
the context of a subquery.

The following example was found:

    SELECT "pos_payment"."id" AS "id"
      FROM "pos_payment"
     WHERE ("pos_payment"."pos_order_id" in
              (SELECT "pos_order".id
                 FROM "pos_order"
                WHERE ("pos_order"."company_id" in (1))
             ORDER BY "pos_order"."id"))
       AND "pos_payment".id IN (1285508)

Here are the query plans made by PostgreSQL on this query with and
without the ORDER BY clause.  The query time went from 1240ms to
0.402ms, which is 3000 times faster!

EXPLAIN ANALYZE SELECT "pos_payment"."id" as "id" FROM "pos_payment" WHERE ("pos_payment"."pos_order_id" in (SELECT "pos_order".id FROM "pos_order" WHERE ("pos_order"."company_id" in (1)) ORDER BY  "pos_order"."id"  )) AND "pos_payment".id IN (1285508);
                                                                    QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------
 Merge Semi Join  (cost=2.88..82726.85 rows=1 width=4) (actual time=1239.361..1239.364 rows=1 loops=1)
   Merge Cond: (pos_payment.pos_order_id = pos_order.id)
   ->  Sort  (cost=2.46..2.46 rows=1 width=8) (actual time=0.021..0.022 rows=1 loops=1)
         Sort Key: pos_payment.pos_order_id
         Sort Method: quicksort  Memory: 25kB
         ->  Index Scan using pos_payment_pkey on pos_payment  (cost=0.43..2.45 rows=1 width=8) (actual time=0.014..0.015 rows=1 loops=1)
               Index Cond: (id = 1285508)
   ->  Index Scan using pos_order_pkey on pos_order  (cost=0.43..66770.53 rows=1282120 width=4) (actual time=0.013..1148.194 rows=1182463 loops=1)
         Filter: (company_id = 1)
 Planning time: 0.272 ms
 Execution time: 1239.396 ms
(11 rows)

EXPLAIN ANALYZE SELECT "pos_payment"."id" as "id" FROM "pos_payment" WHERE ("pos_payment"."pos_order_id" in (SELECT "pos_order".id FROM "pos_order" WHERE ("pos_order
"."company_id" in (1)) )) AND "pos_payment".id IN (1285508);
                                                             QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------
 Nested Loop  (cost=0.85..4.89 rows=1 width=4) (actual time=0.047..0.049 rows=1 loops=1)
   ->  Index Scan using pos_payment_pkey on pos_payment  (cost=0.43..2.45 rows=1 width=8) (actual time=0.027..0.028 rows=1 loops=1)
         Index Cond: (id = 1285508)
   ->  Index Scan using pos_order_pkey on pos_order  (cost=0.43..2.45 rows=1 width=4) (actual time=0.018..0.018 rows=1 loops=1)
         Index Cond: (id = pos_payment.pos_order_id)
         Filter: (company_id = 1)
 Planning time: 0.322 ms
 Execution time: 0.080 ms
(8 rows)

closes odoo/odoo#77357

X-original-commit: 947c3bd72ee84c3a298e0c9c365340ddf16b307d
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Co-authored-by: Stanislas Sobieski (sts@odoo.com)
2021-09-28 19:51:05 +00:00
Rémy Voet (ryv) d2f4cad653 [IMP] stock: improve the populate
- Add the `stock.quant` populate script
- Create more valid default location for picking type populate
- Fix currency populate

Part-of: odoo/odoo#77092
2021-09-24 14:00:20 +00:00
Raf VenandThibault Delavallee be8aa967f0 [IMP] base: merge activities of merged partners
When merging partners through the ``base.partner.merge.automatic.wizard``
wizard, messages and followers are merged. However activities are not
probably because its underlying model is "newer" then messages and followers.

This commits fixes that behavior.

Task-2641572
PR odoo#76159
Closes #71654

X-original-commit: 7e17678ec6ebbbe37b807a5d264cc5afd46bae1a
Part-of: odoo/odoo#77005
Co-authored-by: Thibault Delavallee <tde@odoo.com>
2021-09-22 19:25:56 +00:00
Adrien Widart 252ae7f4be [FIX] base: use context_today as default rate name
Suppose the TZ is UTC+12 and a user creates a new rate in the morning:
the date will be the day before

The default date should consider the user's timezone.

OPW-2590972

closes odoo/odoo#76914

X-original-commit: 94eb684d83c3afb717f1a548ef02b4449e0db959
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-09-22 06:50:48 +00:00
Xavier MorelandRaphael Collet 97a1568db3 [FIX] base: completely wipe context in res.partner's display_name
Because the field is stored it doesn't make much sense to have a
context dependency and that can cause significant issues. However
`name_get` looks pretty innocent and it's not necessarily insane to
have a context dependency *there* (or even in the average
`display_name` as they're normally non-stored computed fields).

`_compute_display_name` previously blanked (blacklisted) just a few
context values, but doing the opposite is probably the better idea.

See also: odoo/odoo#68946

OPW-2453956
Task 2500978

closes odoo/odoo#76469

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
2021-09-20 19:03:53 +00:00
Xavier Morel 5e81361f80 [FIX] *: opt parent_path fields out of unaccent
closes odoo/odoo#76436

Related: odoo/enterprise#20822
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-09-20 12:53:01 +00:00
Xavier Morel b8da632e6e [IMP] core, base: allow disabling unaccent on a per-field basis
For searches, Odoo uses `unaccent` if it's available. On some
technical fields this is completely unnecessary and precludes the use
of indexes.

This PR provides:

* an opt-out (`unaccent = False`) on `String` and `Text` fields
* a warning if `unaccent` is enabled on *parent_path* fields as their
  performance can be rather critical and not using the index is quite
  an issue (note: the check that `parent_path` fields have been moved
  outside of the check for their existence as we want to check that
  the field is declared and correctly configured in all cases,
  probably)

Task 2627454

Part-of: odoo/odoo#76436
2021-09-20 12:53:01 +00:00
Manuel Fombuena 31fda28b95 [FIX] base: en_GB, week_start: Monday
Monday is commonly accepted as the first day of the week in the UK.

Listed as first option on https://www.unicode.org/cldr/cldr-aux/charts/29/supplemental/territory_information.html#GB with Sunday as an alternative.
All mayor OS (Windows, Mac, iOS) use Monday as the first day of the week when the locale en_GB is used.

closes odoo/odoo#76780

X-original-commit: d7dfa09a2bd649cc3370b3e918469c2a3cdddc95
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-09-20 10:54:15 +00:00
Adrian Torres bbee0b3081 [FIX] base: allow setting group_expand for ir.model.fields
PR #75856 introduced a default implementation of group_expand for
Selection fields that set the value of group_expand to True.

However the PR lacked the necessary bits that allow the same behavior
for fields created on the fly instead of through code.

This commit allows the propagation of the group_expand attribute for
fields of type Selection, this commit also exposes the checkbox in the
UI to enable/disable the setting.

closes odoo/odoo#76775

X-original-commit: 1cacc3e53cf722a31bedff7a76f8e5cc6ed45ce0
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-09-18 17:00:52 +00:00
Philémon van Helden 85cb19b294 [IMP] web_editor, base: allow parameters in image URLs
When adding an image to the library from an URL, if the URL contains
parameters (e.g. ?width=200&height=200), the link will not be accepted.

In this commit, we remove these parameters from the URL before checking
the image, so that the URL is considered valid.
We also remove these parameters before computing the mimetype of the
image, since it is computed based on the end part of the URL.

task-2618494

Part-of: odoo/odoo#75205
2021-09-16 18:14:54 +00:00
Martin Trigaux ef8ad324b0 [I18N] *: export 15.0 source terms
closes odoo/odoo#76542

X-original-commit: 63e6807437295519a0f4705fb88644d6d557ca3a
Related: odoo/enterprise#20882
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-09-16 07:17:40 +00:00
Xavier Morel 499b1621ba [FIX] *: non-accessible buttons
closes odoo/odoo#76581

Related: odoo/enterprise#20897
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-09-15 15:22:58 +00:00
Xavier Morel 5408eeda24 [FIX] base: correctly check for validity of button icons
The icon would only be checked for buttons with neither `@special` nor
`@type` which is... pretty much none of them?

Part-of: odoo/odoo#76581
2021-09-15 15:22:58 +00:00
Xavier Morel 78d1b9591c [IMP] core: _validate_fa_class_accessibility cleanups
* add t-out to set of text-generation attributes
* fix comment location
* don't handroll `iterancestors()`
* only check the `@string` on the toplevel button, doesn't really make
  sense that a button would contain a button in the first place (in
  fact it's not allowed per the HTML spec, a button can only contain
  *non-interactive phrasing content* cf 4.10.6)

Part-of: odoo/odoo#76581
2021-09-15 15:22:57 +00:00
svs-odoo d885488ac8 [FIX] base: infos for act_window_close
Clientside, the only key got from an `ir.actions.act_window_close` type
action is 'infos'. But this key isn't a part of the  whitelisted
readable fields server side, which means you will get a warning if you
use it.

closes odoo/odoo#76109

Signed-off-by: Steve Van Essche <svs-odoo@users.noreply.github.com>
2021-09-09 15:53:34 +00:00
Gorash 4d0e111733 [IMP] profiling: Add profile qweb execution into the performance tools.
By activating the profiler debugger, the two qweb options is added. The
qweb templates that need to be rendered are compiled into a new function
to add instructions for saving data.

`Add qweb directive context`
It's a sub-option of "Record sql" or "Record traces", add some context on
thread at current call stack level.  This context stored by collector
beside stack and is used by  Speedscope to add a level to the stack with
this qweb directive information.
```
    directive=t-call='website.layout', xpath=/t/t
    t_call_content
    directive=t-foreach='5' t-as="'a', xpath=/t/t/div/div
    directive=t-esc='website.search([])', xpath=/t/t/div/div/t
    execute
```

`Record qweb`
Add profiling data used by ProfilingQwebView widget. In the `ir.profile`
form view, the widget display the duration and number of sql of every qweb
directives with the xml of templates. Every xml is recorded to be
consulted even if the user change the xml templates.
```xml
    <t t-call="website.layout">
       <div>
          <div t-foreach="5" t-as="a">
             <t t-esc="website.search([])"/> <!-- will display 5 separate requests -->
          </div>
       </div>
    </t>
```

closes odoo/odoo#74712

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2021-09-08 10:21:42 +00:00
Gorash 8936c0b25a [IMP] qweb: cleanup, remove useless code, add doc
Part-of: odoo/odoo#74712
2021-09-08 10:21:42 +00:00
wan fa034b2a64 [IMP] *: product back2basics 15.0
Rework the whole view, generally.

task-2605931

Part-of: odoo/odoo#75862
2021-09-07 15:50:00 +00:00
wan a0f38c6d97 [IMP] *: partner back2basics 15.0
Review the whole view generally

task-2605931

Part-of: odoo/odoo#75862
2021-09-07 15:50:00 +00:00
Csaba Tóth d8af84b929 [FIX] base: update Hungarian time format
The official time format is %H:%M:%S (with colons not with dots)

closes odoo/odoo#75715

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-09-07 13:12:48 +00:00
Aaron Bohy 65d15b40f6 [FIX] test_main_flows: adapt tour to groupby menu changes
Part-of: odoo/odoo#73311
2021-09-07 10:04:39 +00:00
Raphael Collet 33788fd2de [FIX] base: _compute_avatar() does not work with new records
closes odoo/odoo#76042

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-09-06 18:29:04 +00:00
Raphael ColletandWilliam André 71fc2e55f9 [FIX] core: inherited computed fields in onchange
Assume that model A has a computed field G that depends on both fields
F1 and F2.  Assume that model B inherits from A (_inherits).  When G is
computed during an onchange, it must use the form values for all its
dependencies F1 and F2.  Before this commit, only the field triggering
the onchange was assigned on the parent record (see (*) below.)

                      record        parent
    --- ------------+-------------+------------
     initial state  | F1=0, F2=0  | F1=0, F2=0
     assign F1=1    | F1=1, F2=0  | F1=1, F2=0
     assign F2=2    | F1=1, F2=1  | F1=0, F2=1 (*)

The commit also includes another patch: when assigning the parent
record, the ORM determines the dependent records (in this case, the main
record in the onchange).  If the delegate field (many2one from B to A)
has an inverse one2many field, the ORM uses that field to determine
dependent records.  However, in the case of a new record, that field is
not in cache, and its value is determined to be... empty!  The patch
consists in "fixing" the value of that field when we determine the
parent record (when the delegate field is accessed.)

Part-of: odoo/odoo#76042
Co-authored-by: William André <wan@odoo.com>
2021-09-06 18:29:03 +00:00
Raphael Collet 0d1908e644 [IMP] base: do partial validation of views
Here is the idea: when creating a view V that inherits another view, and
V only adds elements in the parent view, only the elements added by V
must be validated.  The other elements are not modified, and thus do not
need to be validated again.  However partial validation cannot be done
when modifying an existing view, or when the view replaces elements in
the parent view.  In such cases, the method _check_xml() validates the
whole combined architecture.

The time spent in method _check_xml() to install a database from scratch
with module sale_management went from 2.730s to 2.243s (-18%), and the
number of queries made in the method went from 2283 to 1614 (-29%).

closes odoo/odoo#75796

Related: odoo/enterprise#20633
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-09-06 15:47:03 +00:00
Raphael Collet c70c97b127 [IMP] base: refactor NameManager in views
Also speed up view validation by not calling fields_get when possible.
This avoids a call that is usually not necessary for validating a view.
Most of the time, fields can be found on the model itself.  Only
overridden fields_get() with fake fields are actually useful, like the
one of model 'res.users'.

The time spent in method _check_xml() to install a database from scratch with
module sale_management went from 3.510s to 2.730s (-22%), and the number
of queries made in the method went from 2995 to 2283 (-24%).

Part-of: odoo/odoo#75796
2021-09-06 15:47:03 +00:00
Raphael Collet eda3352cdd [IMP] base: refactor domain methods in view validation
The goal is to avoid calls to obscure methods, and make the code more
understandable.

Part-of: odoo/odoo#75796
2021-09-06 15:47:02 +00:00
Raphael Collet 5fad7a55dc [IMP] base: simplify view validation
Besides simple code improvements, remove node_info['attr_model'], and
check domain on specific elements.  Also refactor _validate_attrs.  The
changes have no impact on performance.

Part-of: odoo/odoo#75796
2021-09-06 15:47:02 +00:00
Raphael Collet 46f1912c9b [REF] base: split view validation from postprocessing
This makes it easier to optimize the algorithms for both cases:
postprocessing without validation, and validation without
postprocessing.  Also factor out some common bits like the editability
of nodes.

The net result is a speedup in performance.  The time spent in method
_check_xml() to install a database from scratch with module
sale_management went from 4.955s to 3.578s (-28%), and the number of
queries made in the method went from 3779 to 2995 (-21%).

Part-of: odoo/odoo#75796
2021-09-06 15:47:02 +00:00
Raphael Collet 331b54770e [REF] base: merge view methods _postprocess_view and postprocess, and simplify
This replaces recursive calls by a stack, which makes profiling
flamegraphs much simpler to analyze.

Part-of: odoo/odoo#75796
2021-09-06 15:47:01 +00:00
Raphael Collet 9ae8c1a7c9 [REF] base: split method handle_view_error() into _raise_view_error() and _log_view_warning()
This improves code readability but does not impact performance.

Part-of: odoo/odoo#75796
2021-09-06 15:47:01 +00:00
Raphael Collet 1de6c4e55a [IMP] base: extra optimization for safe_eval() in views
This generalizes an existing optimization and saves a few time to
validate a view.  The time spent in method _check_xml() to install a
database from scratch with module sale_management went from 5.145s to
5.044s (-2%).

Part-of: odoo/odoo#75796
2021-09-06 15:47:00 +00:00
Odoo's Mergebot 7cc67aecec [MERGE] project: remove project overview and improve analytic account
The project overview is a significant technical debt
as it is a custom qweb view. It is quite limited:
- It is not possible to group the data, to filter on dates,
SOs or Field Service projects.
- Improving this is very difficult and would require weeks
of development that are not worth it.
In any case, all the information provided by the project overview
can be found elsewhere. The stat buttons of the report are basically
duplicates of the ones from the project form view.
Therefore, we are removing this report and its twin,
the Project Costs and Revenues.

In addition, analytic items lack context for the user to understand
what generated a certain cost or revenue:
- there is no link to the source document;
- the entries are not categorized (e.g. it is not easy to understand
if a cost comes from a timesheet cost, a purchase order or an expense);
- the billable type group by works fine for timesheets but then all
the other entries are flagged as Undefined, which is not very helpful;
- there is no option to easily isolate costs from revenues.

task-2545084
See odoo/enterprise#19250
See odoo/upgrade#2706

closes odoo/odoo#72736

Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
2021-09-06 16:35:49 +02:00
Arnaud GonyandMartin Trigaux 2dee29a7dc [IMP] auth_totp: 2FA Trusted Devices
+ Added the 'Trusted Devices' feature
+ Added 'Remember this Device' checkbox on /web/login/totp
+ Added trusted device's OS / browser on Profile > Account Security

Added '2FA Trusted Devices' feature to allow users to remember their
device to bypass the 2FA for the next connections. The trusted devices
are displayed in a 'Trusted Devices' One2Many under the 'Developer API
Keys'. It is possible to revoke all the trusted devices at once with a
special button. It is also possible to revoke one at a time on the
desired one.

Task-id 2523092

closes odoo/odoo#75535

Related: odoo/upgrade#2800
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Co-authored-by: Martin Trigaux <mat@odoo.com>
2021-09-06 13:17:48 +00:00
Raphael Collet 3a4d518303 [FIX] core: missing cursor commit in module installation
Right after some module operation (install, uninstall), the framework
looks for some ir.actions.todo to execute.  Currently those actions
cannot be found, because the cursor seems to see the database in the
state it was just before the operation.  Simply add the commit() which
was removed by revision 1595c0ee27.

closes odoo/odoo#75980

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-09-06 12:03:42 +00:00
Xavier Morel 759e2c5829 [FIX] core: avoid feeding client invalid XML-RPC documents
The XML-RPC interface has a compatibility shim for binaries as
historically Odoo has returned "binary" data as base64 strings. To
avoid breakages during the Python 3 transition, the shim was
introduced to decode the output binary data (under the assumption that
it'd be ASCII-compatible).

In the case where the data is *not* ascii-compatible, however, it can
generate invalid XML documents: "C0" control codes (with the exception
of tab, LF, and CR) are not valid in XML 1.0 (which XML-RPC is an
application of), however they're perfectly valid string characters and
the standard library's marshaller does not check for them, embedding
them directly in the output document and breaking the client's
decoding.

Work around the issue by replacing such binary data with an empty
string.

While at it, move the bytes shim to the customized marshaller, this
way everything's at the same place and it's not necessary to waste
time trying to understand why the marshaller is just not calling what
it's supposed to call.

Fixes #61919

closes odoo/odoo#75973

Forward-port-of: #75952
Forward-port-of: #74699
X-original-commit: 1a0b3f7
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-09-06 12:03:31 +00:00
Xavier-Do 68ea460f3f [IMP] profiling, base: add enable profiling wizard
When using profiling on a fresh test database, it can be tedious to
access settings to enable the feature. This commit adds a wizard to help
enabling profiling without accessing the settings when trying to
activate profiling on a administrator session.

closes odoo/odoo#75967

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2021-09-06 12:03:27 +00:00
Thomas Beckers 50c8eb1f8b [FIX] base: manifest cache is empty using cron
When generating some sale order/invoices pdf automatically (via cron for example), the format of the
invoice is not correct (missing style, background image, etc). The html used to generate these pdf's
misses the asset lines (link to css and js files).

The asset lines are not generated because the manifest cache (http.addons_manifest) is empty if we
render a pdf from a cron.

This commit will generate http.addons_manifest if it's not yet done before.

opw-2581621
opw-2597990
opw-2542242

closes odoo/odoo#75092

X-original-commit: 3ae4db7fc8dbc404984e34ac532426d6bf2c6a0f
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
Signed-off-by: ThomasBeckers <ThomasBeckers@users.noreply.github.com>
2021-09-06 10:42:44 +00:00