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 ...@@ -32,6 +32,7 @@ from AccessControl import ClassSecurityInfo
from Products.CMFCore.WorkflowCore import WorkflowAction from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.DeliveryLine import DeliveryLine from Products.ERP5.Document.DeliveryLine import DeliveryLine
from Products.ERP5.ERP5Globals import balance_transaction_line_type_list
from zLOG import LOG from zLOG import LOG
...@@ -121,9 +122,9 @@ Une ligne tarifaire.""" ...@@ -121,9 +122,9 @@ Une ligne tarifaire."""
def getSourceDebit(self): def getSourceDebit(self):
""" """
Return the quantity Return the quantity
""" """
quantity = self.getQuantity() quantity = self.getQuantity()
try: try:
quantity = float(quantity) quantity = float(quantity)
except: except:
...@@ -200,12 +201,16 @@ Une ligne tarifaire.""" ...@@ -200,12 +201,16 @@ Une ligne tarifaire."""
security.declarePrivate('_setSource') security.declarePrivate('_setSource')
def _setSource(self, value): def _setSource(self, value):
self._setCategoryMembership('source', value, base=0) self._setCategoryMembership('source', value, base=0)
source = self.restrictedTraverse(value) if self.getPortalType() not in balance_transaction_line_type_list:
destination = self.getDestination() source = self.restrictedTraverse(value)
mirror_list = source.getDestinationList() destination = self.getDestination()
#LOG('_setSource', 0, 'value = %s, mirror_list = %s, destination = %s' % (str(value), str(mirror_list), str(destination))) mirror_list = source.getDestinationList()
if len(mirror_list) > 0 and destination not in mirror_list: #LOG('_setSource', 0, 'value = %s, mirror_list = %s, destination = %s' % (str(value), str(mirror_list), str(destination)))
self._setCategoryMembership('destination', mirror_list[0], base=0) 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') security.declareProtected(Permissions.ModifyPortalContent, 'setSource')
def setSource(self, value): def setSource(self, value):
...@@ -214,13 +219,17 @@ Une ligne tarifaire.""" ...@@ -214,13 +219,17 @@ Une ligne tarifaire."""
security.declarePrivate('_setDestination') security.declarePrivate('_setDestination')
def _setDestination(self, value): def _setDestination(self, value):
self._setCategoryMembership('destination', value, base=0) if self.getPortalType() not in balance_transaction_line_type_list:
destination = self.restrictedTraverse(value) self._setCategoryMembership('destination', value, base=0)
source = self.getSource() destination = self.restrictedTraverse(value)
mirror_list = destination.getDestinationList() source = self.getSource()
#LOG('_setDestination', 0, 'value = %s, mirror_list = %s, source = %s' % (str(value), str(mirror_list), str(source))) mirror_list = destination.getDestinationList()
if len(mirror_list) > 0 and source not in mirror_list: #LOG('_setDestination', 0, 'value = %s, mirror_list = %s, source = %s' % (str(value), str(mirror_list), str(source)))
self._setCategoryMembership('source', mirror_list[0], base=0) 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') security.declareProtected(Permissions.ModifyPortalContent, 'setDestination')
def setDestination(self, value): 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