Commit 426eb295 authored by Julien Muchembled's avatar Julien Muchembled

Fix building of invoice lines in some tests

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@37910 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 47fbbd53
......@@ -28,6 +28,7 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.Document.Predicate import Predicate
from Products.ERP5.mixin.rule import RuleMixin, MovementGeneratorMixin
......@@ -97,15 +98,20 @@ class TradeModelRuleMovementGenerator(MovementGeneratorMixin):
def _getInputMovementList(self, movement_list=None, rounding=False):
simulation_movement = self._applied_rule.getParentValue()
specialise_list = simulation_movement.getSpecialiseList()
rule = self._applied_rule.getSpecialiseValue()
input_movement = aq_base(simulation_movement).__of__(self._applied_rule)
for amount in simulation_movement.getAggregatedAmountList(
# XXX add a 'trade_amount_generator' group type
amount_generator_type_list=('Purchase Trade Condition',
'Sale Trade Condition',
'Trade Model Line')):
movement = self._applied_rule.newContent(
portal_type=RuleMixin.movement_type, temp_object=True,
**dict((k, v) for k, v in amount.__dict__.iteritems() if k[0] != '_'))
movement._setSpecialiseList(specialise_list)
movement = input_movement.asContext(**dict((k, v)
for k, v in amount.__dict__.iteritems()
if k[0] != '_' and k != 'categories'))
base_category_set = set(amount.getBaseCategoryList())
base_category_set.remove('price_currency') # XXX
# XXX 'causality' category should be added to Amount
base_category_set.add('causality')
movement._setCategoryMembership(base_category_set,
amount.getCategoryList(),
base=True)
yield movement
......@@ -187,7 +187,7 @@ class ExplanationCache:
def getParentSimulationMovementValueList(obj, movement_list, trade_phase):
parent = obj.getParentValue()
while parent.getPortalType() == "Simulation Movement":
if parent.getCausalityValue(
if parent.getCausalityValue(portal_type="Trade Model Path"
).isMemberOf(trade_phase, strict_membership=1):
movement_list.append(parent)
parent = parent.getParentValue().getParentValue()
......@@ -195,7 +195,7 @@ class ExplanationCache:
def getChildSimulationMovementValueList(obj, movement_list, trade_phase):
for child in obj.objectValues():
if (child.getPortalType() == "Simulation Movement" and
child.getCausalityValue(
child.getCausalityValue(portal_type="Trade Model Path"
).isMemberOf(trade_phase, strict_membership=1)):
movement_list.append(child)
getChildSimulationMovementValueList(child, movement_list, trade_phase)
......
......@@ -86,10 +86,10 @@ class TestBPMMixin(ERP5TypeTestCase):
trade_phase_value_list=('default/payment',
'default/discount',
'default/tax'),
trade_date='trade_phase/default/order')
trade_date='trade_phase/default/invoicing')
kw = dict(business_process=business_process,
trade_phase='default/accounting',
trade_date='trade_phase/default/order',
trade_date='trade_phase/default/invoicing',
membership_criterion_base_category='resource_use')
self.createTradeModelPath(reference='acounting_tax1',
efficiency=-1,
......
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