Commit 05fe5e19 authored by Jérome Perrin's avatar Jérome Perrin

*: check type based methods are not None

should be same for cases where type based method is a python script, but
is a bit more explicit/safe and consistent with other usages.
parent c9d1489c
......@@ -30,7 +30,7 @@ mail_message = portal.Base_createMailMessageAsString(
extra_header_dict=extra_header_dict)
create_post_message_method = event.getTypeBasedMethod('createPostMessage')
if create_post_message_method:
if create_post_message_method is not None:
create_post_message_method(mail_message)
else:
# We do not want to retry those activities, as sending email is not transactional safe
......
......@@ -7,5 +7,5 @@ event = sci['object']
ticket = event.getFollowUpValue()
if ticket is not None:
afterNewEvent = ticket.getTypeBasedMethod('afterNewEvent')
if afterNewEvent:
if afterNewEvent is not None:
afterNewEvent(event)
......@@ -167,7 +167,7 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement):
'isMovingItem')
def isMovingItem(self, item):
type_based_script = self._getTypeBasedMethod('isMovingItem')
if type_based_script:
if type_based_script is not None:
return type_based_script(item)
return self.isAccountable()
......
......@@ -111,7 +111,7 @@ class DeliveryLine(Movement, XMLMatrix, ImmobilisationMovement):
'isMovingItem')
def isMovingItem(self, item):
type_based_script = self._getTypeBasedMethod('isMovingItem')
if type_based_script:
if type_based_script is not None:
return type_based_script(item)
return self.isAccountable()
......
......@@ -236,7 +236,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
'isMovingItem')
def isMovingItem(self, item):
type_based_script = self._getTypeBasedMethod('isMovingItem')
if type_based_script:
if type_based_script is not None:
return type_based_script(item)
return False
......@@ -500,7 +500,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
This will be implemeted by calling currency conversion on currency resources
"""
type_based_script = self._getTypeBasedMethod('getSourceAssetPrice')
if type_based_script:
if type_based_script is not None:
return type_based_script()
return self._getAssetPrice(section = self.getSourceSectionValue(), date = self.getStartDate())
......@@ -511,7 +511,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
Returns the price converted to the currency of the destination section
"""
type_based_script = self._getTypeBasedMethod('getDestinationAssetPrice')
if type_based_script:
if type_based_script is not None:
return type_based_script()
return self._getAssetPrice(section = self.getDestinationSectionValue(), date = self.getStopDate())
......
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