don't attach dossiers to old commissions of same name (#6924)

This commit is contained in:
Frédéric Péters 2015-04-20 16:11:38 +02:00
parent 8784ac182e
commit e2c1aa7959
1 changed files with 8 additions and 2 deletions

View File

@ -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