Files
odoo_source/odoo/addons/test_impex
Xavier Morel 6b2dfcc8b0 [IMP] core: batching during import
By default importing is batched (or at least attempted to), however
because the import is functionally sequential it's possible for a
record to refer to a previously imported record of the same batch.

When records are referenced by xid this is easy, we can just keep
track of all the xids we *should* have created so far and when trying
to look up a xid if it's one of those flush all pending
creations (otherwise assume it's some other unrelated xid which
already exists in the system).

For "name_search" lookups however this is more complicated, so we'd
just flush the entire thing.

This, then, is an issue when importing records with an m2o which
is *generally* looked up by "name" rather than xid e.g. when importing
partners it's more likely the "state" will be specified by
name (e.g. AZ or Arizona) than xid (base.state_us_3 lol), because it
means more or less every line will be flushed, defeating all batching
and slowing down the import.

To fix this, allow passing *model names* to flush (not just xids), and
try to collate all the models we could be creating (or updating)
records for in the process of importing. If we see a name_search on
one of these models flush, otherwise don't because we couldn't have
impacted the search.

Task 1951307

While at it, f2a1618758 removed all
usage of model_load_save, but left the creation of the savepoint
itself.

The InternalError check should be left in place to catch things like
conversion issues which put the tnx in an invalid state (only invalid
states should trigger an InternalError according to psycopg's errors
documentation).

closes odoo/odoo#49289

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-05-28 11:40:35 +00:00
..
2020-05-28 11:40:35 +00:00