Files
odoo_source/odoo/addons/test_impex/ir.model.access.csv
T
Adrien Widart (awt) f41c3b1d9e [FIX] base: rollback if broken transaction while importing
Suppose a user who has CRM module and wants to import some leads
thanks to this CSV file:
```csv
name,recurring_plan
Coca-Cola,Plan01
SAP,Plan02
```
And, because the recurring plans are not yet created on his database,
he enables the option "Create new values" for that field. An error
will occur and here is the only info the user will have:
> current transaction is aborted, commands ignored until end of
> transaction block

When importing, we convert the data encoded by the user ([1]). To do
so, we convert the provided values, field by field ([2]). Since
`recurring_plan` is a `many2one` field, we go (through
`_str_to_many2one`) in `db_id_for`. In this method, we `name_search`
the record and then, if it does not exist and if the feature is
enabled, we `name_create` it ([3]).

Back to the above use case. We start with the first line and there is
not any recurring plan called "Plan01" so we try to create it. But
here is the issue: we only have a name to create the record although
there is another required field: `number_of_months`. Therefore, it
leads to a `NotNullViolation` error. This error is caught (see [3])
and, later in the same method, we will raise a `ValueError`. This
error will be caught by one of the except in [2]: we will save the
error and will then  continue with the convertion of next values.
However, because of the `NotNullViolation`, the current SQL
transaction is broken. As a result, while trying to convert the
second line of the file, we will `name_search` "Plan02" and it will
simply lead to a `InFailedSqlTransaction`

[1]
https://github.com/odoo/odoo/blob/f3d7fdce608f692ecb08498ee158edf9dfbced5e/odoo/models.py#L1170-L1182
[2]
https://github.com/odoo/odoo/blob/b80d4294a000e748677a3a0c1849140bf46ddbe8/odoo/addons/base/models/ir_fields.py#L117-L118
[3]
https://github.com/odoo/odoo/blob/b80d4294a000e748677a3a0c1849140bf46ddbe8/odoo/addons/base/models/ir_fields.py#L472-L475

sentry-3969379125

closes odoo/odoo#132897

X-original-commit: 28373b9d261a48154b233fbbd895880680b0aed0
Signed-off-by: Adrien Widart (awt) <awt@odoo.com>
2023-08-24 18:38:17 +02:00

3.3 KiB

1idnamemodel_id:idgroup_id:idperm_readperm_writeperm_createperm_unlink
2access_export_booleanaccess_export_booleanmodel_export_booleanbase.group_user1111
3access_export_integeraccess_export_integermodel_export_integerbase.group_user1111
4access_export_floataccess_export_floatmodel_export_floatbase.group_user1111
5access_export_decimalaccess_export_decimalmodel_export_decimalbase.group_user1111
6access_export_string_boundedaccess_export_string_boundedmodel_export_string_boundedbase.group_user1111
7access_export_string_requiredaccess_export_string_requiredmodel_export_string_requiredbase.group_user1111
8access_export_stringaccess_export_stringmodel_export_stringbase.group_user1111
9access_export_dateaccess_export_datemodel_export_datebase.group_user1111
10access_export_datetimeaccess_export_datetimemodel_export_datetimebase.group_user1111
11access_export_textaccess_export_textmodel_export_textbase.group_user1111
12access_export_selectionaccess_export_selectionmodel_export_selectionbase.group_user1111
13access_export_selection_functionaccess_export_selection_functionmodel_export_selection_functionbase.group_user1111
14access_export_many2oneaccess_export_many2onemodel_export_many2onebase.group_user1111
15access_export_one2manyaccess_export_one2manymodel_export_one2manybase.group_user1111
16access_export_many2manyaccess_export_many2manymodel_export_many2manybase.group_user1111
17access_export_functionaccess_export_functionmodel_export_functionbase.group_user1111
18access_export_one2many_childaccess_export_one2many_childmodel_export_one2many_childbase.group_user1111
19access_export_one2many_multipleaccess_export_one2many_multiplemodel_export_one2many_multiplebase.group_user1111
20access_export_one2many_multiple_childaccess_export_one2many_multiple_childmodel_export_one2many_multiple_childbase.group_user1111
21access_export_one2many_child_1access_export_one2many_child_1model_export_one2many_child_1base.group_user1111
22access_export_one2many_child_2access_export_one2many_child_2model_export_one2many_child_2base.group_user1111
23access_export_many2many_otheraccess_export_many2many_othermodel_export_many2many_otherbase.group_user1111
24access_export_selection_withdefaultaccess_export_selection_withdefaultmodel_export_selection_withdefaultbase.group_user1111
25access_export_one2many_recursiveaccess_export_one2many_recursivemodel_export_one2many_recursivebase.group_user1111
26access_export_uniqueaccess_export_uniquemodel_export_uniquebase.group_user1111
27access_export_inherits_parentaccess_export_inherits_parentmodel_export_inherits_parentbase.group_user1111
28access_export_inherits_childaccess_export_inherits_childmodel_export_inherits_childbase.group_user1111
29access_export_m2o_straccess_export_m2o_strmodel_export_m2o_strbase.group_user1111
30access_export_m2o_str_childaccess_export_m2o_str_childmodel_export_m2o_str_childbase.group_user1111
31access_export_with_required_fieldaccess_export_with_required_fieldmodel_export_with_required_fieldbase.group_user1111
32access_export_many2one_required_subfieldaccess_export_many2one_required_subfieldmodel_export_many2one_required_subfieldbase.group_user1111