Aaron Bohy 7dc6958334 [FIX] web: can partially evaluate complex dynamic context
Have a form view with an x2many field, and a context on that field,
depending on other fields of the view. For instance:
 ```xml
   <form>
     <field name="a"/>
     <field name="b_ids" context="{'key1': a, 'key2': 4}"/>
   </form>
 ```

As we read records in a single rpc (unity read), we need to be able
to (at least partially) evaluate the context set on b_ids to build
the field specification for the web_read call. The problem is that
the evaluation context is incomplete when we want to evalute it, as
we don't know the value of `a`.

Before this commit, we evaluated that context by adding "sentinel"
values in the evaluation context (a sentinel being a Symbol), and
we removed all keys whose values had been evaluated to the sentinel
afterwards. This worked for the example above (we were able to
generate the context `{ key2: 4 }`).

However, this wasn't flawless. For instance, with
 ```xml
    <field name="b_ids" context="{'key1': a + b}"/>
 ```
our sentinel strategy didn't work, because you can't perform such
operations on a Symbol.

This commit comes with another strategy, which is actually easier,
and which handles the above case. We now parse the context, and
evaluate each value individually (if it needs to be evaluated). If
the evaluation crashes, we swallow the error and do not add that
particular key to the evaluated context.

Part of task~3179751

closes odoo/odoo#129925

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-07-28 14:54:02 +02:00
2023-07-27 11:58:34 +02:00
…
…
…
…
…

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%