From 52fdb64d60a2fc01d99ee94949b34406fc937571 Mon Sep 17 00:00:00 2001 From: Yoshinori Okuji <yo@nexedi.com> Date: Mon, 19 Apr 2004 09:27:34 +0000 Subject: [PATCH] New methods, _setSource, setSource, _setDestination, setDestination and _edit. These are for setting a mirror account. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@692 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../Document/AccountingTransactionLine.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/product/ERP5/Document/AccountingTransactionLine.py b/product/ERP5/Document/AccountingTransactionLine.py index 00faa12ec2..6d68eb3080 100755 --- a/product/ERP5/Document/AccountingTransactionLine.py +++ b/product/ERP5/Document/AccountingTransactionLine.py @@ -33,6 +33,8 @@ from Products.CMFCore.WorkflowCore import WorkflowAction from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5.Document.DeliveryLine import DeliveryLine +from zLOG import LOG + class AccountingTransactionLine(DeliveryLine): """ Accounting Transaction Lines allow to move some quantity of money from a source to a destination @@ -194,3 +196,41 @@ Une ligne tarifaire.""" Temp """ return + + security.declarePrivate('_setSource') + def _setSource(self, value): + self._setCategoryMembership('source', value, base=0) + 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) + + security.declareProtected(Permissions.ModifyPortalContent, 'setSource') + def setSource(self, value): + self._setSource(value) + self.reindexObject() + + security.declarePrivate('_setDestination') + def _setDestination(self, value): + self._setCategoryMembership('destination', value, base=0) + destination = self.restrictedTraverse(value) + source = self.getSource() + mirror_list = destination.getDestinationList() + #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) + + security.declareProtected(Permissions.ModifyPortalContent, 'setDestination') + def setDestination(self, value): + self._setDestination(value) + self.reindexObject() + + security.declarePrivate('_edit') + def _edit(self, REQUEST = None, force_update = 0, **kw): + if kw.has_key('source'): + self._setSource(kw['source']) + if kw.has_key('destination'): + self._setDestination(kw['destination']) + DeliveryLine._edit(self, REQUEST=REQUEST, force_update = force_update, **kw) -- 2.30.9