Goal:
* Simplified modifiers to only have one way to define modifiers;
* Remove states attributes on python field;
* Use python expression in view `required`, `readonly`, `invisible`;
* More accurate validation of xml views.
This commit change the syntax to python expression. The next commit
will update/convert all xml views.
Before this commit:
* the `required`, `readonly` and `invisible` attributes can only have
values of `True`, `False`, 1, 0 or a python expression to use the
context;
* the `attrs` attribute define a dict. The key of this dict was
`required`, `readonly` and `invisible` and the values are the domain or
a string representing a domain to be evaluate as python expression.
This python expressions was evaluate by the javascript with view fields
and other contextual values as: context, uid, parent, active_id,
active_ids, active_model, allowed_company_ids, current_company_id.
* the `states` attribute in the view was a comma separated list of the
state. This list was combined with the `invisible` attribute;
* the `invisible` attribute on python field is used as default value;
* the `states` attribute on python field was dictionnary with state as
key and list of tuple. This structure was combined with `readonly` view
attribute.
* After combining, the resulting domains of the different attributes
`required`, `readonly` and `invisible` are evaluated with the values of
the fields. The `invisible` attributes is splitted into two use:
`invisible` and `column_invisible`.
After this commit:
* The attributes `required`, `readonly`, `invisible` and
`column_invisible` define python expression. This python expressions
are evaluate by the javascript with view fields and other contextual
values as: context, uid, parent, active_id, active_ids, active_model,
allowed_company_ids, current_company_id.
The domains can contains contextual value and will be evaluate by the
javascript.
```xml
<field name="field_a" readonly="not context.get('show_a')" attrs="{'readonly': [('field_b', '!=', False), ('field_c', '=', parent.c)]}"/>
<field name="field_b" states="draft"/>
```
will be replaced by
```xml
<field name="field_a" readonly="not context.get('show_a') or field_b and field_c == parent.c"/>
<field name="field_b" invisible="state != 'draft'"/>
```
Some inherited views will be modified differently in order to maintain
the previous behavior:
```xml
<field name="field_a" readonly="not context.get('show_a')" attrs="{'invisible': [('field_b', '!=', False)]}">
```
```xml
<field name="field_a" position="attributes">
<attribute name="attrs">{'readonly': [('field_c', '=', False)], 'invisible': [('field_d', '!=', '3')]}<attribute>
</field>
```
will be replaced by
```xml
<field name="field_a" readonly="not context.get('show_a')" invisible="field_b">
```
```xml
<field name="field_a" position="attributes">
<attribute name="readonly" add="(not field_c)" separator=" or "/>
<attribute name="invisible">field_d != 3<attribute>
</field>
```
Validation:
A stricter control is made on the level of the attributes (modifiers)
and the fields necessary for these. The use of the previous attributes
'attr' and 'states' triggers an error (these no longer exist after the
application of the migration script)
task-2495504
Part-of: odoo/odoo#104741
3.8 KiB
3.8 KiB
| 1 | id | name | model_id:id | group_id:id | perm_read | perm_write | perm_create | perm_unlink |
|---|---|---|---|---|---|---|---|---|
| 2 | access_test_testing_utilities_a | access_test_testing_utilities_a | model_test_testing_utilities_a | base.group_user | 1 | 0 | 0 | 0 |
| 3 | access_test_testing_utilities_readonly | access_test_testing_utilities_readonly | model_test_testing_utilities_readonly | base.group_user | 1 | 0 | 0 | 0 |
| 4 | access_test_testing_utilities_c | access_test_testing_utilities_c | model_test_testing_utilities_c | base.group_user | 1 | 0 | 0 | 0 |
| 5 | access_test_testing_utilities_d | access_test_testing_utilities_d | model_test_testing_utilities_d | base.group_user | 1 | 0 | 0 | 0 |
| 6 | access_test_testing_utilities_e | access_test_testing_utilities_e | model_test_testing_utilities_e | base.group_user | 1 | 0 | 0 | 0 |
| 7 | access_test_testing_utilities_f | access_test_testing_utilities_f | model_test_testing_utilities_f | base.group_user | 1 | 0 | 0 | 0 |
| 8 | access_test_testing_utilities_g | access_test_testing_utilities_g | model_test_testing_utilities_g | base.group_user | 1 | 0 | 0 | 0 |
| 9 | access_test_testing_utilities_m2o | access_test_testing_utilities_m2o | model_test_testing_utilities_m2o | base.group_user | 1 | 0 | 0 | 0 |
| 10 | access_test_testing_utilities_default | access_test_testing_utilities_default | model_test_testing_utilities_default | base.group_user | 1 | 0 | 0 | 0 |
| 11 | access_test_testing_utilities_parent | access_test_testing_utilities_parent | model_test_testing_utilities_parent | base.group_user | 1 | 0 | 0 | 0 |
| 12 | access_test_testing_utilities_sub | access_test_testing_utilities_sub | model_test_testing_utilities_sub | base.group_user | 1 | 0 | 0 | 0 |
| 13 | access_test_testing_utilities_ref | access_test_testing_utilities_ref | model_test_testing_utilities_ref | base.group_user | 1 | 0 | 0 | 0 |
| 14 | access_test_testing_utilities_ref_sub | access_test_testing_utilities_ref_sub | model_test_testing_utilities_ref_sub | base.group_user | 1 | 0 | 0 | 0 |
| 15 | access_test_testing_utilities_sub2 | access_test_testing_utilities_sub2 | model_test_testing_utilities_sub2 | base.group_user | 1 | 0 | 0 | 0 |
| 16 | access_test_testing_utilities_sub3 | access_test_testing_utilities_sub3 | model_test_testing_utilities_sub3 | base.group_user | 1 | 0 | 0 | 0 |
| 17 | access_test_testing_utilities_recursive | access_test_testing_utilities_recursive | model_test_testing_utilities_recursive | base.group_user | 1 | 0 | 0 | 0 |
| 18 | access_test_testing_utilities_onchange_parent | access_test_testing_utilities_onchange_parent | model_test_testing_utilities_onchange_parent | base.group_user | 1 | 0 | 0 | 0 |
| 19 | access_test_testing_utilities_onchange_line | access_test_testing_utilities_onchange_line | model_test_testing_utilities_onchange_line | base.group_user | 1 | 0 | 0 | 0 |
| 20 | access_model_test_testing_utilities_onchange_count | access_model_test_testing_utilities_onchange_count | model_test_testing_utilities_onchange_count | base.group_user | 1 | 1 | 1 | 1 |
| 21 | access_test_testing_utilities_onchange_count_sub | access_test_testing_utilities_onchange_count_sub | model_test_testing_utilities_onchange_count_sub | base.group_user | 1 | 1 | 1 | 1 |
| 22 | access_o2m_readonly_subfield_parent | access_o2m_readonly_subfield_parent | model_o2m_readonly_subfield_parent | base.group_user | 1 | 1 | 1 | 1 |
| 23 | access_o2m_readonly_subfield_child | access_o2m_readonly_subfield_child | model_o2m_readonly_subfield_child | base.group_user | 1 | 1 | 1 | 1 |
| 24 | access_test_testing_utilities_req_bool | access_test_testing_utilities_req_bool | model_test_testing_utilities_req_bool | base.group_user | 1 | 0 | 0 | 0 |
| 25 | access_o2m_changes_parent | access_o2m_changes_parent | model_o2m_changes_parent | base.group_user | 1 | 0 | 0 | 0 |
| 26 | access_o2m_changes_children | access_o2m_changes_children | model_o2m_changes_children | base.group_user | 1 | 0 | 0 | 0 |
| 27 | access_o2m_changes_children_lines | access_o2m_changes_children_lines | model_o2m_changes_children_lines | base.group_user | 1 | 0 | 0 | 0 |
| 28 | access_ttu_product | access_ttu_product | model_ttu_product | base.group_user | 1 | 0 | 0 | 0 |
| 29 | access_ttu_root | access_ttu_root | model_ttu_root | base.group_user | 1 | 0 | 0 | 0 |
| 30 | access_ttu_child | access_ttu_child | model_ttu_child | base.group_user | 1 | 0 | 0 | 0 |
| 31 | access_ttu_grandchild | access_ttu_grandchild | model_ttu_grandchild | base.group_user | 1 | 0 | 0 | 0 |
| 32 | access_res_config_test | access_res_config_test | test_testing_utilities.model_res_config_test | base.group_user | 1 | 0 | 0 | 0 |