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