[Erp5-report] r34265 jm - in /erp5/trunk/products/ERP5: mixin/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Apr 2 10:41:51 CEST 2010
Author: jm
Date: Fri Apr 2 10:41:42 2010
New Revision: 34265
URL: http://svn.erp5.org?rev=34265&view=rev
Log:
composition: small fixes
- For the call to _findPredicateList, explicitely check the length of objects
(instead of trying __nonzero__ first, which is wrong and slow).
- Do not allow to call asComposedDocument on a composed document for the moment.
- Make internal class private and fix __name__ of asComposedDocument method.
- Fix test_tradeModelLineWithTargetLevelSetting
Modified:
erp5/trunk/products/ERP5/mixin/composition.py
erp5/trunk/products/ERP5/tests/testTradeModelLine.py
Modified: erp5/trunk/products/ERP5/mixin/composition.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/mixin/composition.py?rev=34265&r1=34264&r2=34265&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/mixin/composition.py [utf8] (original)
+++ erp5/trunk/products/ERP5/mixin/composition.py [utf8] Fri Apr 2 10:41:42 2010
@@ -95,7 +95,7 @@
return predicate_list
-class _asComposedDocument(object):
+class asComposedDocument(object):
"""Return a temporary object which is the composition of all effective models
The returned value is a temporary copy of the given object. The list of all
@@ -106,6 +106,7 @@
def __new__(cls, orig_self):
if '_effective_model_list' in orig_self.__dict__:
+ assert False, "not used yet (remove this line if needed)"
return orig_self # if asComposedDocument is called on a composed
# document after any access to its subobjects
self = orig_self.asContext()
@@ -123,6 +124,7 @@
assert False
def asComposedDocument(self):
+ assert False, "not used yet (remove this line if needed)"
return self # if asComposedDocument is called on a composed
# document before any access to its subobjects
@@ -134,7 +136,7 @@
# we filter out objects without any subobject to make the cache of
# '_findPredicateList' useful. Otherwise, the key would be always different
# (starting with 'orig_self').
- for ob in _findPredicateList(*filter(None, self._effective_model_list)):
+ for ob in _findPredicateList(*filter(len, self._effective_model_list)):
self._setOb(ob.id, ob)
return self._folder_handler
@@ -149,7 +151,7 @@
security.declareProtected(Permissions.AccessContentsInformation,
'asComposedDocument')
- asComposedDocument = transactional_cached()(_asComposedDocument)
+ asComposedDocument = transactional_cached()(asComposedDocument)
# XXX add accessors to get properties from '_effective_model_list' ?
# (cf PaySheetModel)
@@ -187,3 +189,5 @@
for model in parent_asComposedDocument()._effective_model_list
if model not in model_set]
return model_list
+
+del asComposedDocument
Modified: erp5/trunk/products/ERP5/tests/testTradeModelLine.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testTradeModelLine.py?rev=34265&r1=34264&r2=34265&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testTradeModelLine.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testTradeModelLine.py [utf8] Fri Apr 2 10:41:42 2010
@@ -2476,6 +2476,8 @@
# change target level to `movement`.
tax.edit(target_level=TARGET_LEVEL_MOVEMENT)
+ transaction.commit() # flush transactional cache
+
amount_list = trade_condition.getAggregatedAmountList(order)
self.assertEqual(2, len(amount_list))
self.assertEqual(1,
@@ -2522,6 +2524,8 @@
reference='DISCOUNT_B',
base_contribution_list=['base_amount/total'],)
discount.edit(quantity=10, price=-1, target_level=TARGET_LEVEL_DELIVERY)
+
+ transaction.commit() # flush transactional cache
def getTotalAmount(amount_list):
result = 0
@@ -2574,6 +2578,7 @@
extra_fee_a.edit(target_level=TARGET_LEVEL_DELIVERY)
extra_fee_b.edit(target_level=TARGET_LEVEL_DELIVERY)
tax.edit(target_level=TARGET_LEVEL_DELIVERY)
+ transaction.commit() # flush transactional cache
amount_list = trade_condition.getAggregatedAmountList(order)
self.assertEqual(4, len(amount_list))
self.assertEqual(100 + 1 - 10 + 1500*0.05,
More information about the Erp5-report
mailing list