Commit 285ef436 authored by Jérome Perrin's avatar Jérome Perrin

use getProperty with default value instead of hasattr + getter, for readability

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7146 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f8131185
...@@ -132,12 +132,8 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -132,12 +132,8 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
invoice_line = my_invoice_line_simulation.getDeliveryValue() invoice_line = my_invoice_line_simulation.getDeliveryValue()
if invoice_line is not None : if invoice_line is not None :
invoice = invoice_line.getExplanationValue() invoice = invoice_line.getExplanationValue()
if hasattr(invoice, 'getResource') and \ resource = invoice.getProperty('resource',
invoice.getResource() is not None : invoice.getProperty('price_currency', None))
resource = invoice.getResource()
elif hasattr(invoice, 'getPriceCurrency') and \
invoice.getPriceCurrency() is not None :
resource = invoice.getPriceCurrency()
if resource is None : if resource is None :
# search the resource on parents simulation movement's deliveries # search the resource on parents simulation movement's deliveries
simulation_movement = applied_rule.getParentValue() simulation_movement = applied_rule.getParentValue()
...@@ -145,17 +141,13 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -145,17 +141,13 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
while resource is None and \ while resource is None and \
simulation_movement != portal_simulation : simulation_movement != portal_simulation :
delivery = simulation_movement.getDeliveryValue() delivery = simulation_movement.getDeliveryValue()
if hasattr(delivery, 'getPriceCurrency') and \ resource = delivery.getProperty('price_currency', None)
delivery.getPriceCurrency() is not None :
resource = delivery.getPriceCurrency()
if simulation_movement.getParentValue().getParentValue() \ if simulation_movement.getParentValue().getParentValue() \
== portal_simulation : == portal_simulation :
# we are on the first simulation movement, we'll try # we are on the first simulation movement, we'll try
# to get the resource from it's order price currency. # to get the resource from it's order price currency.
order = simulation_movement.getOrderValue() order = simulation_movement.getOrderValue()
if hasattr(order, 'getPriceCurrency') and \ resource = order.getProperty('price_currency', None)
order.getPriceCurrency() is not None :
resource = order.getPriceCurrency()
simulation_movement = simulation_movement\ simulation_movement = simulation_movement\
.getParentValue().getParentValue() .getParentValue().getParentValue()
...@@ -186,7 +178,6 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -186,7 +178,6 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
Rule.expand(self, applied_rule, force=force, **kw) Rule.expand(self, applied_rule, force=force, **kw)
# Matrix related # Matrix related
security.declareProtected( Permissions.ModifyPortalContent, security.declareProtected( Permissions.ModifyPortalContent,
'newCellContent' ) 'newCellContent' )
def newCellContent(self, id, **kw): def newCellContent(self, id, **kw):
......
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