Commit 1917a412 authored by Julien Muchembled's avatar Julien Muchembled

expand: fix movement compensation

This reverts partially commit 2b92f990
("expand: optimize creation of new movements by not using propertyMap+_edit").
parent 5c3f9264
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
import zope.interface import zope.interface
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, interfaces from Products.ERP5Type import Permissions, interfaces
from Products.ERP5.MovementCollectionDiff import MovementCollectionDiff from Products.ERP5.MovementCollectionDiff import (
MovementCollectionDiff, _getPropertyAndCategoryList)
from Products.ERP5.mixin.rule import _compare from Products.ERP5.mixin.rule import _compare
class MovementCollectionUpdaterMixin: class MovementCollectionUpdaterMixin:
...@@ -170,8 +171,14 @@ class MovementCollectionUpdaterMixin: ...@@ -170,8 +171,14 @@ class MovementCollectionUpdaterMixin:
movement.clearRecordedProperty(property_id) movement.clearRecordedProperty(property_id)
for movement in movement_diff.getNewMovementList(): for movement in movement_diff.getNewMovementList():
d = movement.__dict__ d = movement.__dict__
# make sure our optimization does not touch existing persistent data assert movement.isTempObject()
assert movement.isTempObject() and '_original' not in d if '_original' in d:
# slow but safe way (required for compensated movements)
context.newContent(portal_type=self.movement_type,
**_getPropertyAndCategoryList(movement))
continue
# fast way (we had to make sure such optimization
# does not touch existing persistent data)
del movement.__dict__ del movement.__dict__
movement = context.newContent(portal_type=self.movement_type) movement = context.newContent(portal_type=self.movement_type)
d.update(movement.__dict__) d.update(movement.__dict__)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment