diff --git a/rero_ils/modules/entities/api.py b/rero_ils/modules/entities/api.py index 48f9f37185..cdd5557f40 100644 --- a/rero_ils/modules/entities/api.py +++ b/rero_ils/modules/entities/api.py @@ -112,11 +112,14 @@ def get_record_by_ref(cls, ref): pid=ref_pid )): raise Exception('NO DATA') - # Try to get the contribution from DB maybe it was not indexed. - if entity := Entity.get_record_by_pid(data['pid']): - entity = entity.replace(data) - else: - entity = cls.create(data) + # Try to get the contribution from DB. + entity = Entity.get_record_by_pid(data['pid']) + if entity: + # TODO: find a way to safely update the old entity + raise Exception( + f'OLD DATA: MEF({data["pid"]}) DB({entity.pid})' + ) + entity = cls.create(data) online = True nested.commit() # TODO: reindex in the document indexing diff --git a/rero_ils/modules/entities/replace.py b/rero_ils/modules/entities/replace.py index 9567db57f5..2d3f606b43 100644 --- a/rero_ils/modules/entities/replace.py +++ b/rero_ils/modules/entities/replace.py @@ -24,6 +24,7 @@ import requests from flask import current_app +from invenio_db import db from rero_ils.modules.documents.api import Document, DocumentsSearch from rero_ils.modules.entities.api import Entity @@ -202,7 +203,7 @@ def _do_entity(self, entity, doc_pid): source, {}).get('authorized_access_point') info = f'{doc_entity_type}: {authorized_access_point}' self.rero_only[identifier] = info - self.logger.warning( + self.logger.info( f'No other source found for document:{doc_pid} ' f'{self.field} - ({mef_type}) {identifier} "{info}"' ) @@ -211,7 +212,7 @@ def _do_entity(self, entity, doc_pid): 'entity']['authorized_access_point'] info = f'{doc_entity_type}: {authorized_access_point}' self.not_found[identifier] = info - self.logger.warning( + self.logger.info( f'No MEF found for document:{doc_pid} ' f'{self.parent} - ({mef_type}) {identifier} "{info}"' )