Commit 85f79bb7 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Set destination to None, if it is a Balance Transaction.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1048 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0b16904e
......@@ -32,6 +32,7 @@ from AccessControl import ClassSecurityInfo
from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.DeliveryLine import DeliveryLine
from Products.ERP5.ERP5Globals import balance_transaction_line_type_list
from zLOG import LOG
......@@ -200,12 +201,16 @@ Une ligne tarifaire."""
security.declarePrivate('_setSource')
def _setSource(self, value):
self._setCategoryMembership('source', value, base=0)
if self.getPortalType() not in balance_transaction_line_type_list:
source = self.restrictedTraverse(value)
destination = self.getDestination()
mirror_list = source.getDestinationList()
#LOG('_setSource', 0, 'value = %s, mirror_list = %s, destination = %s' % (str(value), str(mirror_list), str(destination)))
if len(mirror_list) > 0 and destination not in mirror_list:
self._setCategoryMembership('destination', mirror_list[0], base=0)
else:
# Force to set the destination to None.
self._setCategoryMembership('destination', None, base=0)
security.declareProtected(Permissions.ModifyPortalContent, 'setSource')
def setSource(self, value):
......@@ -214,6 +219,7 @@ Une ligne tarifaire."""
security.declarePrivate('_setDestination')
def _setDestination(self, value):
if self.getPortalType() not in balance_transaction_line_type_list:
self._setCategoryMembership('destination', value, base=0)
destination = self.restrictedTraverse(value)
source = self.getSource()
......@@ -221,6 +227,9 @@ Une ligne tarifaire."""
#LOG('_setDestination', 0, 'value = %s, mirror_list = %s, source = %s' % (str(value), str(mirror_list), str(source)))
if len(mirror_list) > 0 and source not in mirror_list:
self._setCategoryMembership('source', mirror_list[0], base=0)
else:
# Force to set the destination to None.
self._setCategoryMembership('destination', None, base=0)
security.declareProtected(Permissions.ModifyPortalContent, 'setDestination')
def setDestination(self, value):
......
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