Browse Source

Revert "[IMP] disable recomputation during import"

This reverts commit efce253d54.
10.0
Holger Brunn 7 years ago
committed by OCA-git-bot
parent
commit
25b4bbcdcc
  1. 1
      base_import_odoo/README.rst
  2. 22
      base_import_odoo/models/import_odoo_database.py

1
base_import_odoo/README.rst

@ -56,6 +56,7 @@ Known issues / Roadmap
* Yes of course this duplicates a lot of connector functionality. Rewrite this with the connector framework, probably collaborate with https://github.com/OCA/connector-odoo2odoo * Yes of course this duplicates a lot of connector functionality. Rewrite this with the connector framework, probably collaborate with https://github.com/OCA/connector-odoo2odoo
* Do something with workflows * Do something with workflows
* Support reference fields, while being at it refactor _run_import_map_values to call a function per field type * Support reference fields, while being at it refactor _run_import_map_values to call a function per field type
* Probably it's safer and faster to disable recomputation during import, and recompute all fields afterwards
Bug Tracker Bug Tracker
=========== ===========

22
base_import_odoo/models/import_odoo_database.py

@ -160,7 +160,6 @@ class ImportOdooDatabase(models.Model):
"""Import records of a configured model""" """Import records of a configured model"""
model = self.env[context.model_line.model_id.model] model = self.env[context.model_line.model_id.model]
fields = self._run_import_model_get_fields(context) fields = self._run_import_model_get_fields(context)
recompute_ids = []
for data in context.remote.execute( for data in context.remote.execute(
model._name, 'read', context.ids, fields.keys() model._name, 'read', context.ids, fields.keys()
): ):
@ -171,16 +170,9 @@ class ImportOdooDatabase(models.Model):
data = self._run_import_map_values(context, data) data = self._run_import_map_values(context, data)
_id = data['id'] _id = data['id']
record = self._create_record(context, model, data) record = self._create_record(context, model, data)
recompute_ids.append(record.id)
self._run_import_model_cleanup_dummies( self._run_import_model_cleanup_dummies(
context, model, _id, record.id, context, model, _id, record.id,
) )
to_recompute = model.browse(recompute_ids)
for field in model._fields.values():
if not field.compute:
continue
to_recompute._recompute_todo(field)
to_recompute.recompute()
@api.multi @api.multi
def _create_record(self, context, model, record): def _create_record(self, context, model, record):
@ -191,15 +183,13 @@ class ImportOdooDatabase(models.Model):
) )
if self.env.ref('base_import_odoo.%s' % xmlid, False): if self.env.ref('base_import_odoo.%s' % xmlid, False):
new = self.env.ref('base_import_odoo.%s' % xmlid) new = self.env.ref('base_import_odoo.%s' % xmlid)
with self.env.norecompute():
new.with_context(
**self._create_record_context(model, record)
).write(record)
new.with_context(
**self._create_record_context(model, record)
).write(record)
else: else:
with self.env.norecompute():
new = model.with_context(
**self._create_record_context(model, record)
).create(record)
new = model.with_context(
**self._create_record_context(model, record)
).create(record)
self.env['ir.model.data'].create({ self.env['ir.model.data'].create({
'name': xmlid, 'name': xmlid,
'model': model._name, 'model': model._name,

Loading…
Cancel
Save