summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tabellio/pcfdb/sync.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tabellio/pcfdb/sync.py b/tabellio/pcfdb/sync.py
index 864b28c..f43da91 100644
--- a/tabellio/pcfdb/sync.py
+++ b/tabellio/pcfdb/sync.py
@@ -13,6 +13,7 @@ from Products.CMFCore.WorkflowCore import WorkflowException
from Products.Five.browser import BrowserView
from z3c.sqlalchemy import getSAWrapper, createSAWrapper
from Products.CMFCore.utils import getToolByName
+from zope.annotation.interfaces import IAnnotations
from zope.event import notify
from zope.lifecycleevent import ObjectAddedEvent, ObjectModifiedEvent
@@ -242,6 +243,9 @@ class SyncFromPcfDbView(BrowserView):
obj = getattr(folder, code_id)
except AttributeError:
return None
+ annotations = IAnnotations(obj)
+ if annotations['tabellio.com_id'] != com_id:
+ return None
self._commissions[com_id] = obj
return obj
@@ -726,6 +730,9 @@ class SyncFromPcfDbView(BrowserView):
object.active == (state == 'S_ACTIVE')
object.code = code
+ annotations = IAnnotations(object)
+ annotations['tabellio.com_id'] = com_id
+
pers_cursor = self.db_connection.cursor()
pers_cursor.execute('''SELECT t_pershistoline.type, nom, prenom
FROM t_pers JOIN t_pershistoline
@@ -1090,8 +1097,7 @@ class SyncFromPcfDbView(BrowserView):
try:
commission_ids = [self.get_commission_intid(x) for x in (curcom or []) if x not in ('001291649,')]
- commission_ids = [x for x in commission_ids if x]
- object.commissions = [RelationValue(x) for x in commission_ids]
+ object.commissions = [RelationValue(x) for x in commission_ids if x]
except AttributeError:
pass