[Erp5-report] r7146 - /erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed May 10 14:17:59 CEST 2006


Author: jerome
Date: Wed May 10 14:17:54 2006
New Revision: 7146

URL: http://svn.erp5.org?rev=7146&view=rev
Log:
use getProperty with default value instead of hasattr + getter, for readability

Modified:
    erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py

Modified: erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py?rev=7146&r1=7145&r2=7146&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py (original)
+++ erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py Wed May 10 14:17:54 2006
@@ -132,12 +132,8 @@
             invoice_line = my_invoice_line_simulation.getDeliveryValue()
             if invoice_line is not None :
               invoice = invoice_line.getExplanationValue()
-              if hasattr(invoice, 'getResource') and \
-                    invoice.getResource() is not None :
-                resource = invoice.getResource()
-              elif hasattr(invoice, 'getPriceCurrency') and \
-                    invoice.getPriceCurrency() is not None :
-                resource = invoice.getPriceCurrency()
+              resource = invoice.getProperty('resource',
+                         invoice.getProperty('price_currency', None))
             if resource is None :
               # search the resource on parents simulation movement's deliveries
               simulation_movement = applied_rule.getParentValue()
@@ -145,17 +141,13 @@
               while resource is None and \
                           simulation_movement != portal_simulation :
                 delivery = simulation_movement.getDeliveryValue()
-                if hasattr(delivery, 'getPriceCurrency') and \
-                      delivery.getPriceCurrency() is not None :
-                  resource = delivery.getPriceCurrency()
+                resource = delivery.getProperty('price_currency', None)
                 if simulation_movement.getParentValue().getParentValue() \
                                           == portal_simulation :
                   # we are on the first simulation movement, we'll try
                   # to get the resource from it's order price currency.
                   order = simulation_movement.getOrderValue()
-                  if hasattr(order, 'getPriceCurrency') and \
-                      order.getPriceCurrency() is not None :
-                    resource = order.getPriceCurrency()
+                  resource = order.getProperty('price_currency', None)
                 simulation_movement = simulation_movement\
                                             .getParentValue().getParentValue()
                 
@@ -185,8 +177,7 @@
       # Pass to base class
       Rule.expand(self, applied_rule, force=force, **kw)
     
-         # Matrix related
- 
+    # Matrix related
     security.declareProtected( Permissions.ModifyPortalContent,
                                 'newCellContent' )
     def newCellContent(self, id, **kw):




More information about the Erp5-report mailing list