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
Pipeline #11027 failed with stage
in 0 seconds
...@@ -30,7 +30,7 @@ mail_message = portal.Base_createMailMessageAsString( ...@@ -30,7 +30,7 @@ mail_message = portal.Base_createMailMessageAsString(
extra_header_dict=extra_header_dict) extra_header_dict=extra_header_dict)
create_post_message_method = event.getTypeBasedMethod('createPostMessage') 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) create_post_message_method(mail_message)
else: else:
# We do not want to retry those activities, as sending email is not transactional safe # We do not want to retry those activities, as sending email is not transactional safe
......
...@@ -7,5 +7,5 @@ event = sci['object'] ...@@ -7,5 +7,5 @@ event = sci['object']
ticket = event.getFollowUpValue() ticket = event.getFollowUpValue()
if ticket is not None: if ticket is not None:
afterNewEvent = ticket.getTypeBasedMethod('afterNewEvent') afterNewEvent = ticket.getTypeBasedMethod('afterNewEvent')
if afterNewEvent: if afterNewEvent is not None:
afterNewEvent(event) afterNewEvent(event)
...@@ -167,7 +167,7 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement): ...@@ -167,7 +167,7 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement):
'isMovingItem') 'isMovingItem')
def isMovingItem(self, item): def isMovingItem(self, item):
type_based_script = self._getTypeBasedMethod('isMovingItem') type_based_script = self._getTypeBasedMethod('isMovingItem')
if type_based_script: if type_based_script is not None:
return type_based_script(item) return type_based_script(item)
return self.isAccountable() return self.isAccountable()
......
...@@ -111,7 +111,7 @@ class DeliveryLine(Movement, XMLMatrix, ImmobilisationMovement): ...@@ -111,7 +111,7 @@ class DeliveryLine(Movement, XMLMatrix, ImmobilisationMovement):
'isMovingItem') 'isMovingItem')
def isMovingItem(self, item): def isMovingItem(self, item):
type_based_script = self._getTypeBasedMethod('isMovingItem') type_based_script = self._getTypeBasedMethod('isMovingItem')
if type_based_script: if type_based_script is not None:
return type_based_script(item) return type_based_script(item)
return self.isAccountable() return self.isAccountable()
......
...@@ -236,7 +236,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin): ...@@ -236,7 +236,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
'isMovingItem') 'isMovingItem')
def isMovingItem(self, item): def isMovingItem(self, item):
type_based_script = self._getTypeBasedMethod('isMovingItem') type_based_script = self._getTypeBasedMethod('isMovingItem')
if type_based_script: if type_based_script is not None:
return type_based_script(item) return type_based_script(item)
return False return False
...@@ -500,7 +500,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin): ...@@ -500,7 +500,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
This will be implemeted by calling currency conversion on currency resources This will be implemeted by calling currency conversion on currency resources
""" """
type_based_script = self._getTypeBasedMethod('getSourceAssetPrice') type_based_script = self._getTypeBasedMethod('getSourceAssetPrice')
if type_based_script: if type_based_script is not None:
return type_based_script() return type_based_script()
return self._getAssetPrice(section = self.getSourceSectionValue(), date = self.getStartDate()) return self._getAssetPrice(section = self.getSourceSectionValue(), date = self.getStartDate())
...@@ -511,7 +511,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin): ...@@ -511,7 +511,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
Returns the price converted to the currency of the destination section Returns the price converted to the currency of the destination section
""" """
type_based_script = self._getTypeBasedMethod('getDestinationAssetPrice') type_based_script = self._getTypeBasedMethod('getDestinationAssetPrice')
if type_based_script: if type_based_script is not None:
return type_based_script() return type_based_script()
return self._getAssetPrice(section = self.getDestinationSectionValue(), date = self.getStopDate()) 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