Commit c208a638 authored by Aurel's avatar Aurel

add support for getBaobabSource/DestinationVariationText and remove

some hardcoded stuff


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7186 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ad3f7675
...@@ -112,7 +112,8 @@ for category in ('source', 'destination', ...@@ -112,7 +112,8 @@ for category in ('source', 'destination',
'source_section', 'destination_section', 'source_section', 'destination_section',
'source_payment', 'destination_payment', 'source_payment', 'destination_payment',
'source_function', 'destination_function', 'source_function', 'destination_function',
'source_project', 'destination_project'): 'source_project', 'destination_project',
'source_variation_text', 'destination_variation_text',):
getter_id = 'getBaobab%s' % (convertToUpperCase(category)) getter_id = 'getBaobab%s' % (convertToUpperCase(category))
original_getter_id = 'get%s' % (convertToUpperCase(category)) original_getter_id = 'get%s' % (convertToUpperCase(category))
method = BaobabGetter(getter_id, original_getter_id) method = BaobabGetter(getter_id, original_getter_id)
...@@ -130,4 +131,4 @@ for category in ('source', 'destination', ...@@ -130,4 +131,4 @@ for category in ('source', 'destination',
setattr(BaobabMixin, prop_getter_id, method) setattr(BaobabMixin, prop_getter_id, method)
BaobabMixin.security.declareProtected(Permissions.View, prop_getter_id) BaobabMixin.security.declareProtected(Permissions.View, prop_getter_id)
InitializeClass(BaobabMixin) InitializeClass(BaobabMixin)
\ No newline at end of file
...@@ -130,3 +130,21 @@ class CashDeliveryCell(BaobabMixin, DeliveryCell): ...@@ -130,3 +130,21 @@ class CashDeliveryCell(BaobabMixin, DeliveryCell):
""" """
""" """
return self.aq_parent.getBaobabDestinationProject(**kw) return self.aq_parent.getBaobabDestinationProject(**kw)
security.declareProtected(Permissions.View, 'getBaobabSourceVariationText')
def getBaobabSourceVariationText(self, **kw):
"""
"""
script = self._getTypeBasedMethod('getBaobabSourceVariationText')
if script is not None:
return script(self)
return self.aq_parent.getBaobabSourceVariationText(**kw)
security.declareProtected(Permissions.View, 'getBaobabDestinationVariationText')
def getBaobabDestinationVariationText(self, **kw):
"""
"""
script = self._getTypeBasedMethod('getBaobabDestinationVariationText')
if script is not None:
return script(self)
return self.aq_parent.getBaobabDestinationVariationText(**kw)
...@@ -31,10 +31,6 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface ...@@ -31,10 +31,6 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.DeliveryLine import DeliveryLine from Products.ERP5.Document.DeliveryLine import DeliveryLine
from Products.ERP5Banking.BaobabMixin import BaobabMixin from Products.ERP5Banking.BaobabMixin import BaobabMixin
in_portal_type_list = ('Cash Exchange Line In', 'Cash To Currency Sale Line In','Cash To Currency Purchase Line In', 'Cash Incident Line In')
out_portal_type_list = ('Cash Exchange Line Out', 'Cash To Currency Sale Line Out','Cash To Currency Purchase Line Out','Cash Incident Line Out')
class CashDeliveryLine(BaobabMixin, DeliveryLine): class CashDeliveryLine(BaobabMixin, DeliveryLine):
""" """
A Cash DeliveryLine object allows to implement lines A Cash DeliveryLine object allows to implement lines
...@@ -79,10 +75,6 @@ class CashDeliveryLine(BaobabMixin, DeliveryLine): ...@@ -79,10 +75,6 @@ class CashDeliveryLine(BaobabMixin, DeliveryLine):
script = self._getTypeBasedMethod('getBaobabSource') script = self._getTypeBasedMethod('getBaobabSource')
if script is not None: if script is not None:
return script(self) return script(self)
if self.portal_type in out_portal_type_list:
return self.portal_categories.resolveCategory(self.getSource()).unrestrictedTraverse('sortante').getRelativeUrl()
elif self.portal_type in in_portal_type_list:
return None
return self.getSource() return self.getSource()
security.declareProtected(Permissions.View, 'getBaobabDestination') security.declareProtected(Permissions.View, 'getBaobabDestination')
...@@ -93,9 +85,24 @@ class CashDeliveryLine(BaobabMixin, DeliveryLine): ...@@ -93,9 +85,24 @@ class CashDeliveryLine(BaobabMixin, DeliveryLine):
script = self._getTypeBasedMethod('getBaobabDestination') script = self._getTypeBasedMethod('getBaobabDestination')
if script is not None: if script is not None:
return script(self) return script(self)
if self.portal_type in in_portal_type_list:
return self.portal_categories.resolveCategory(self.getSource()).unrestrictedTraverse('entrante').getUid()
elif self.portal_type in out_portal_type_list :
return None
return self.getDestination() return self.getDestination()
security.declareProtected(Permissions.View, 'getBaobabSourceVariationText')
def getBaobabSourceVariationText(self):
"""
Returns a calculated source variation text
"""
script = self._getTypeBasedMethod('getBaobabSourceVariationText')
if script is not None:
return script(self)
return self.getVariationText()
security.declareProtected(Permissions.View, 'getBaobabDestinationVariationText')
def getBaobabDestinationVariationText(self):
"""
Returns a calculated destination variation text
"""
script = self._getTypeBasedMethod('getBaobabDestinationVariationText')
if script is not None:
return script(self)
return self.getVariationText()
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