Commit 8bc2adad authored by Julien Muchembled's avatar Julien Muchembled

Move conflicting classes from ERP5Legacy product to erp5_legacy BT

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@37616 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 73bce252
DeliveryRootSimulationRule
DeliverySimulationRule
InvoiceRootSimulationRule
InvoiceSimulationRule
InvoiceTransactionSimulationRule
OrderRootSimulationRule
PaymentSimulationRule
RootAppliedRuleCausalityMovementGroup
TradeModelSimulationRule
\ No newline at end of file
......@@ -35,6 +35,40 @@ from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.Predicate import Predicate
from Acquisition import aq_base
# resurrected from old AppliedRule class
def AppliedRule_getExplanationSpecialiseValue(self, portal_type_list):
"""Returns first found specialise value of delivery or order
In case if self is root Applied Rule uses causality
Otherwise uses delivery, than order of parent movements
Recurses to parents"""
def findSpecialiseValueBySimulation(movement):
specialise_value = None
if movement.getPortalType() != 'Simulation Movement':
return None
delivery, order = movement.getDeliveryValue(), movement.getOrderValue()
if delivery is not None:
specialise_value = delivery.getExplanationValue() \
.getRootSpecialiseValue(portal_type_list)
if specialise_value is not None:
return specialise_value
# 'order' category is deprecated. it is kept for compatibility.
if order is not None:
specialise_value = order.getExplanationValue() \
.getRootSpecialiseValue(portal_type_list)
if specialise_value is not None:
return specialise_value
return findSpecialiseValueBySimulation(movement.getParentValue() \
.getParentValue())
if self.getRootAppliedRule() == self:
return self.getCausalityValue() \
.getRootSpecialiseValue(portal_type_list)
movement = self.getParentValue()
return findSpecialiseValueBySimulation(movement)
class Rule(Predicate, XMLObject):
"""
Rule objects implement the simulation algorithm
......@@ -353,7 +387,8 @@ class Rule(Predicate, XMLObject):
def _getInputMovementAndPathTupleList(self, applied_rule):
"""Returns list of tuples (movement, business_path)"""
input_movement_list = self._getInputMovementList(applied_rule)
business_process = applied_rule.getBusinessProcessValue()
business_process = AppliedRule_getExplanationSpecialiseValue(applied_rule,
('Business Process',))
trade_phase_list = self.getTradePhaseList()
# In non-BPM case, we have no business path.
......
......@@ -30,7 +30,8 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5Legacy.Document.Rule import Rule
from Products.ERP5Legacy.Document.Rule import Rule, \
AppliedRule_getExplanationSpecialiseValue
class TradeModelRule(Rule):
"""
......@@ -59,9 +60,10 @@ class TradeModelRule(Rule):
"""Generates list of movements (as dicts), and let parent class to decide
which is to add, modify or delete"""
movement_list = []
trade_condition = applied_rule._getExplanationSpecialiseValue(
trade_condition = AppliedRule_getExplanationSpecialiseValue(applied_rule,
('Purchase Trade Condition', 'Sale Trade Condition'))
business_process = applied_rule.getBusinessProcessValue()
business_process = AppliedRule_getExplanationSpecialiseValue(applied_rule,
('Business Process',))
if trade_condition is None or business_process is None:
return movement_list
......
......@@ -42,7 +42,7 @@ class TestBPMMixin(ERP5TypeTestCase):
def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_accounting',
'erp5_invoicing', 'erp5_simplified_invoicing')
'erp5_invoicing', 'erp5_simplified_invoicing', 'erp5_legacy')
business_process_portal_type = 'Business Process'
business_path_portal_type = 'Business Path'
......
......@@ -168,8 +168,8 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase):
'erp5_accounting',
'erp5_accounting_ui_test',
'erp5_invoicing',
'erp5_simplified_invoicing'
)
'erp5_simplified_invoicing',
'erp5_legacy')
@UnrestrictedMethod
def createInvoiceTransactionRule(self, resource=None):
......
......@@ -84,7 +84,7 @@ class TestInvoiceMixin(TestPackingListMixin,
def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_accounting',
'erp5_invoicing', 'erp5_simplified_invoicing', 'erp5_apparel',
'erp5_project', 'erp5_administration')
'erp5_project', 'erp5_legacy', 'erp5_administration')
@UnrestrictedMethod
def createCategories(self):
......
......@@ -61,7 +61,7 @@ class TestOrderMixin:
"""
"""
return ('erp5_base','erp5_pdm', 'erp5_trade', 'erp5_apparel',
'erp5_project', 'erp5_administration')
'erp5_project', 'erp5_legacy', 'erp5_administration')
def login(self, quiet=0, run=1):
uf = self.getPortal().acl_users
......
......@@ -65,7 +65,7 @@ class TestProductionOrderMixin(TestOrderMixin):
def getBusinessTemplateList(self):
"""
"""
return ('erp5_base','erp5_pdm', 'erp5_trade', 'erp5_mrp',)
return ('erp5_base','erp5_pdm', 'erp5_trade', 'erp5_mrp', 'erp5_legacy')
def setUpPreferences(self):
portal = self.getPortal()
......
......@@ -83,7 +83,7 @@ class TestInvoiceMixin(TestPackingListMixin,
def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_accounting',
'erp5_invoicing', 'erp5_simplified_invoicing', 'erp5_apparel',
'erp5_project', 'erp5_administration')
'erp5_project', 'erp5_legacy', 'erp5_administration')
@UnrestrictedMethod
def createCategories(self):
......
......@@ -39,7 +39,8 @@ class TradeConditionTestCase(ERP5TypeTestCase):
def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_accounting',
'erp5_invoicing', 'erp5_tax_resource', 'erp5_discount_resource',
'erp5_legacy_tax_system', 'erp5_simplified_invoicing',)
'erp5_legacy_tax_system', 'erp5_simplified_invoicing',
'erp5_legacy')
def validateRules(self):
"""
......
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