Commit 5a8feed0 authored by Jérome Perrin's avatar Jérome Perrin

Use getParentValue insteand of getParent when accessing the parent object

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6517 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ae1c09f8
...@@ -160,13 +160,15 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement): ...@@ -160,13 +160,15 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement):
# Call a script on the context # Call a script on the context
if 'price' in self.getMappedValuePropertyList([]): if 'price' in self.getMappedValuePropertyList([]):
if getattr(aq_base(self), 'price', None) is not None: if getattr(aq_base(self), 'price', None) is not None:
return getattr(self, 'price') # default returns a price defined by the mapped value # default returns a price defined by the mapped value
return getattr(self, 'price')
else: else:
return self.aq_parent.getProperty('price') # Price is acquired return self.getParentValue().getProperty('price') # Price is acquired
else: else:
return None return None
security.declareProtected( Permissions.AccessContentsInformation, 'getQuantity' ) security.declareProtected( Permissions.AccessContentsInformation,
'getQuantity' )
def getQuantity(self): def getQuantity(self):
""" """
Returns the quantity if defined on the cell Returns the quantity if defined on the cell
...@@ -177,10 +179,10 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement): ...@@ -177,10 +179,10 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement):
if getattr(aq_base(self), 'quantity', None) is not None: if getattr(aq_base(self), 'quantity', None) is not None:
return getattr(self, 'quantity') return getattr(self, 'quantity')
else: else:
return self.aq_parent.getProperty('quantity') return self.getParentValue().getProperty('quantity')
else: else:
return self.getParent().getQuantity() # We have acquisition here which me should mimic # We have acquisition here which me should mimic
# return None return self.getParentValue().getQuantity()
def _setItemIdList(self, value): def _setItemIdList(self, value):
""" """
...@@ -191,7 +193,8 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement): ...@@ -191,7 +193,8 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement):
given_item_id_list = value given_item_id_list = value
item_object_list = [] item_object_list = []
for item in given_item_id_list : for item in given_item_id_list :
item_result_list = self.portal_catalog(id = item, portal_type="Piece Tissu") item_result_list = self.portal_catalog(id = item,
portal_type="Piece Tissu")
if len(item_result_list) == 1 : if len(item_result_list) == 1 :
try : try :
object = item_result_list[0].getObject() object = item_result_list[0].getObject()
...@@ -230,36 +233,35 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement): ...@@ -230,36 +233,35 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement):
self.setTargetQuantity(quantity) self.setTargetQuantity(quantity)
# security.declareProtected(Permissions.ModifyPortalContent, 'applyTargetSolver')
# def applyTargetSolver(self, solver):
# for my_simulation_movement in self.getDeliveryRelatedValueList(portal_type = 'Simulation Movement'):
# self.portal_simulation.applyTargetSolver(my_simulation_movement, solver)
# Required for indexing # Required for indexing
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoriatedQuantity') security.declareProtected(Permissions.AccessContentsInformation,
'getInventoriatedQuantity')
def getInventoriatedQuantity(self): def getInventoriatedQuantity(self):
""" """
""" """
return Movement.getInventoriatedQuantity(self) return Movement.getInventoriatedQuantity(self)
security.declareProtected(Permissions.AccessContentsInformation, 'getStartDate') security.declareProtected(Permissions.AccessContentsInformation,
'getStartDate')
def getStartDate(self): def getStartDate(self):
""" """
""" """
return self._baseGetStartDate() return self._baseGetStartDate()
security.declareProtected(Permissions.AccessContentsInformation, 'getStopDate') security.declareProtected(Permissions.AccessContentsInformation,
'getStopDate')
def getStopDate(self): def getStopDate(self):
""" """
""" """
return self._baseGetStopDate() return self._baseGetStopDate()
security.declareProtected(Permissions.AccessContentsInformation, 'getStopDate') security.declareProtected(Permissions.AccessContentsInformation,
'getRootDeliveryValue')
def getRootDeliveryValue(self): def getRootDeliveryValue(self):
""" """
Returns the root delivery responsible of this cell Returns the root delivery responsible of this cell
""" """
return self.getParent().getRootDeliveryValue() return self.getParentValue().getRootDeliveryValue()
# Simulation Consistency Check # Simulation Consistency Check
def getSimulationQuantity(self): def getSimulationQuantity(self):
...@@ -277,16 +279,20 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement): ...@@ -277,16 +279,20 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement):
return result[0].quantity return result[0].quantity
return None return None
security.declareProtected( Permissions.ModifyPortalContent, 'notifyAfterUpdateRelatedContent' ) security.declareProtected( Permissions.ModifyPortalContent,
def notifyAfterUpdateRelatedContent(self, previous_category_url, new_category_url): 'notifyAfterUpdateRelatedContent' )
def notifyAfterUpdateRelatedContent(self, previous_category_url,
new_category_url):
""" """
Membership Crirerions and Category List are same in DeliveryCell Membership Crirerions and Category List are same in DeliveryCell
Must update it (or change implementation to remove data duplication) Must update it (or change implementation to remove data duplication)
""" """
update_method = self.portal_categories.updateRelatedCategory update_method = self.portal_categories.updateRelatedCategory
predicate_value = self.getPredicateValueList() predicate_value = self.getPredicateValueList()
new_predicate_value = map(lambda c: update_method(c, previous_category_url, new_category_url), predicate_value) new_predicate_value = map(lambda c: update_method(c,
self._setPredicateValueList(new_predicate_value) # No reindex needed since uid stable previous_category_url, new_category_url), predicate_value)
self._setPredicateValueList(new_predicate_value)
# No reindex needed since uid stable
# XXX FIXME: option variation are today not well implemented # XXX FIXME: option variation are today not well implemented
# This little hack is needed to make the matrixbox working # This little hack is needed to make the matrixbox working
...@@ -309,14 +315,16 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement): ...@@ -309,14 +315,16 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement):
if kw.has_key('item_id_list'): if kw.has_key('item_id_list'):
self._setItemIdList(kw['item_id_list']) self._setItemIdList(kw['item_id_list'])
security.declareProtected(Permissions.ModifyPortalContent, 'updateSimulationDeliveryProperties') security.declareProtected(Permissions.ModifyPortalContent,
'updateSimulationDeliveryProperties')
def updateSimulationDeliveryProperties(self, movement_list = None): def updateSimulationDeliveryProperties(self, movement_list = None):
""" """
Set properties delivery_ratio and delivery_error for each simulation movement Set properties delivery_ratio and delivery_error for each
in movement_list (all movements by default), according to this delivery calculated quantity simulation movement in movement_list (all movements by default),
according to this delivery calculated quantity
""" """
parent = self.getParent() parent = self.getParentValue()
if parent is not None: if parent is not None:
parent = parent.getParent() parent = parent.getParentValue()
if parent is not None: if parent is not None:
parent.updateSimulationDeliveryProperties(movement_list, self) parent.updateSimulationDeliveryProperties(movement_list, self)
...@@ -78,15 +78,15 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated, ImmobilisationMovem ...@@ -78,15 +78,15 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated, ImmobilisationMovem
updateRelatedContent = XMLMatrix.updateRelatedContent updateRelatedContent = XMLMatrix.updateRelatedContent
# Explicit acquisition of aq_dynamic generated method # Explicit acquisition of aq_dynamic generated method
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getSimulationState') 'getSimulationState')
def getSimulationState(self): def getSimulationState(self):
""" """
Explicitly acquire simulation_state from parent Explicitly acquire simulation_state from parent
""" """
if hasattr(self.getParent(),'getSimulationState'): method = getattr(self.getParentValue(),'getSimulationState', None)
return self.getParent().getSimulationState() if method is not None:
return None return method()
# Force in _edit to modify variation_base_category_list first # Force in _edit to modify variation_base_category_list first
security.declarePrivate( '_edit' ) security.declarePrivate( '_edit' )
...@@ -383,19 +383,22 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated, ImmobilisationMovem ...@@ -383,19 +383,22 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated, ImmobilisationMovem
result = self.DeliveryLine_zGetRelatedDestinationSection(uid=self.getUid()) result = self.DeliveryLine_zGetRelatedDestinationSection(uid=self.getUid())
return map(lambda x: x.destination_section, result) return map(lambda x: x.destination_section, result)
security.declareProtected(Permissions.AccessContentsInformation, 'getStopDate') security.declareProtected(Permissions.AccessContentsInformation,
'getRootDeliveryValue')
def getRootDeliveryValue(self): def getRootDeliveryValue(self):
""" """
Returns the root delivery responsible of this line Returns the root delivery responsible of this line
""" """
return self.getParent().getRootDeliveryValue() return self.getParentValue().getRootDeliveryValue()
security.declareProtected(Permissions.ModifyPortalContent, 'updateSimulationDeliveryProperties') security.declareProtected(Permissions.ModifyPortalContent,
'updateSimulationDeliveryProperties')
def updateSimulationDeliveryProperties(self, movement_list = None): def updateSimulationDeliveryProperties(self, movement_list = None):
""" """
Set properties delivery_ratio and delivery_error for each simulation movement Set properties delivery_ratio and delivery_error for each
in movement_list (all movements by default), according to this delivery calculated quantity simulation movement in movement_list (all movements by default),
according to this delivery calculated quantity
""" """
parent = self.getParent() parent = self.getParentValue()
if parent is not None: if parent is not None:
parent.updateSimulationDeliveryProperties(movement_list, self) parent.updateSimulationDeliveryProperties(movement_list, self)
...@@ -214,7 +214,7 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -214,7 +214,7 @@ class ImmobilisableItem(XMLObject, Amount):
organisation.getFinancialYearStopDate() is None: organisation.getFinancialYearStopDate() is None:
if category is None: return None if category is None: return None
if category.getPortalType() != "Base Category": if category.getPortalType() != "Base Category":
return self._getFirstIndependantOrganisation(category.getParent()) return self._getFirstIndependantOrganisation(category.getParentValue())
else: else:
return None return None
return organisation return organisation
......
...@@ -137,7 +137,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -137,7 +137,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
resource = invoice.getPriceCurrency() resource = invoice.getPriceCurrency()
if resource is None : if resource is None :
# search the resource on parents simulation movement's deliveries # search the resource on parents simulation movement's deliveries
simulation_movement = applied_rule.getParent() simulation_movement = applied_rule.getParentValue()
portal_simulation = self.getPortalObject().portal_simulation portal_simulation = self.getPortalObject().portal_simulation
while resource is None and \ while resource is None and \
simulation_movement != portal_simulation : simulation_movement != portal_simulation :
...@@ -145,7 +145,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -145,7 +145,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
if hasattr(delivery, 'getPriceCurrency') and \ if hasattr(delivery, 'getPriceCurrency') and \
delivery.getPriceCurrency() is not None : delivery.getPriceCurrency() is not None :
resource = delivery.getPriceCurrency() resource = delivery.getPriceCurrency()
if simulation_movement.getParent().getParent() \ if simulation_movement.getParentValue().getParentValue() \
== portal_simulation : == portal_simulation :
# we are on the first simulation movement, we'll try # we are on the first simulation movement, we'll try
# to get the resource from it's order price currency. # to get the resource from it's order price currency.
...@@ -154,7 +154,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -154,7 +154,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
order.getPriceCurrency() is not None : order.getPriceCurrency() is not None :
resource = order.getPriceCurrency() resource = order.getPriceCurrency()
simulation_movement = simulation_movement\ simulation_movement = simulation_movement\
.getParent().getParent() .getParentValue().getParentValue()
if resource is None : if resource is None :
# last resort : get the resource from the rule # last resort : get the resource from the rule
......
...@@ -64,7 +64,7 @@ class InvoicingRule(Rule): ...@@ -64,7 +64,7 @@ class InvoicingRule(Rule):
""" """
Tests if the rule (still) applies Tests if the rule (still) applies
""" """
parent = movement.getParent() parent = movement.getParentValue()
result = 0 result = 0
if (parent.getPortalType() == 'Applied Rule') and \ if (parent.getPortalType() == 'Applied Rule') and \
(parent.getSpecialiseId() in ('default_order_rule', (parent.getSpecialiseId() in ('default_order_rule',
...@@ -78,9 +78,10 @@ class InvoicingRule(Rule): ...@@ -78,9 +78,10 @@ class InvoicingRule(Rule):
""" """
delivery_line_type = 'Simulation Movement' delivery_line_type = 'Simulation Movement'
# Source that movement from the next node / stock # Source that movement from the next node / stock
my_context_movement = applied_rule.getParent() my_context_movement = applied_rule.getParentValue()
# Do not invoice within the same entity or whenever entities are not all defined # Do not invoice within the same entity or whenever entities are
# not all defined
# It is OK to invoice within different entities of the same company # It is OK to invoice within different entities of the same company
# if we wish to get some internal analytical accounting # if we wish to get some internal analytical accounting
# but that requires some processing to produce a balance sheet # but that requires some processing to produce a balance sheet
......
...@@ -67,7 +67,7 @@ class PaymentRule(Rule): ...@@ -67,7 +67,7 @@ class PaymentRule(Rule):
Tests if the rule (still) applies Tests if the rule (still) applies
""" """
if 'receivable' in movement.getId() : ### TODO: expand 'payable' too if 'receivable' in movement.getId() : ### TODO: expand 'payable' too
parent = movement.getParent() parent = movement.getParentValue()
if parent.getPortalType()=='Applied Rule' \ if parent.getPortalType()=='Applied Rule' \
and parent.getSpecialiseId()=='default_invoice_transaction_rule': and parent.getSpecialiseId()=='default_invoice_transaction_rule':
#LOG('PaymentRule.test :', 0, repr(( 'applies with', movement, parent ))) #LOG('PaymentRule.test :', 0, repr(( 'applies with', movement, parent )))
...@@ -86,7 +86,7 @@ class PaymentRule(Rule): ...@@ -86,7 +86,7 @@ class PaymentRule(Rule):
""" """
payment_line_type = 'Simulation Movement' payment_line_type = 'Simulation Movement'
my_parent_movement = applied_rule.getParent() my_parent_movement = applied_rule.getParentValue()
if my_parent_movement.getQuantity() is not None: if my_parent_movement.getQuantity() is not None:
bank_id = 'bank' bank_id = 'bank'
......
...@@ -222,7 +222,7 @@ class SimulationMovement(Movement): ...@@ -222,7 +222,7 @@ class SimulationMovement(Movement):
# we know that invoicing rule acts like this, and that it comes after # we know that invoicing rule acts like this, and that it comes after
# invoice or invoicing_rule, so we if we come from invoince rule or # invoice or invoicing_rule, so we if we come from invoince rule or
# invoicing rule, we always expand regardless of the causality state. # invoicing rule, we always expand regardless of the causality state.
if ((self.getParent().getSpecialiseId() not in if ((self.getParentValue().getSpecialiseId() not in
('default_invoicing_rule', 'default_invoice_rule') ('default_invoicing_rule', 'default_invoice_rule')
and self.getCausalityState() == 'expanded' ) or \ and self.getCausalityState() == 'expanded' ) or \
len(self.objectIds()) != 0): len(self.objectIds()) != 0):
...@@ -336,7 +336,7 @@ class SimulationMovement(Movement): ...@@ -336,7 +336,7 @@ class SimulationMovement(Movement):
while explanation_value.getPortalType() not in \ while explanation_value.getPortalType() not in \
self.getPortalDeliveryTypeList() and \ self.getPortalDeliveryTypeList() and \
explanation_value != self.getPortalObject(): explanation_value != self.getPortalObject():
explanation_value = explanation_value.getParent() explanation_value = explanation_value.getParentValue()
if explanation_value != self.getPortalObject(): if explanation_value != self.getPortalObject():
return explanation_value return explanation_value
...@@ -523,7 +523,7 @@ class SimulationMovement(Movement): ...@@ -523,7 +523,7 @@ class SimulationMovement(Movement):
Return the root simulation movement in the simulation tree. Return the root simulation movement in the simulation tree.
FIXME : this method should be called getRootSimulationMovementValue FIXME : this method should be called getRootSimulationMovementValue
""" """
parent_applied_rule = self.getParent() parent_applied_rule = self.getParentValue()
if parent_applied_rule.getRootAppliedRule() == parent_applied_rule: if parent_applied_rule.getRootAppliedRule() == parent_applied_rule:
return self return self
else: else:
......
...@@ -122,7 +122,7 @@ class SupplyLink(Path, XMLObject): ...@@ -122,7 +122,7 @@ class SupplyLink(Path, XMLObject):
ind_phase_list = movement.getIndustrialPhaseValueList() ind_phase_list = movement.getIndustrialPhaseValueList()
if ind_phase_list != []: if ind_phase_list != []:
# Is this SupplyLink in the route to the previous production node ? # Is this SupplyLink in the route to the previous production node ?
supply_chain = self.getParent() supply_chain = self.getParentValue()
previous_ind_phase_list =\ previous_ind_phase_list =\
supply_chain.getPreviousProductionIndustrialPhaseList(self) supply_chain.getPreviousProductionIndustrialPhaseList(self)
for ind_phase in ind_phase_list: for ind_phase in ind_phase_list:
...@@ -139,24 +139,24 @@ class SupplyLink(Path, XMLObject): ...@@ -139,24 +139,24 @@ class SupplyLink(Path, XMLObject):
else: else:
# Check if raw material is create by a production link or a packing # Check if raw material is create by a production link or a packing
# list link. # list link.
supply_chain = self.getParent() supply_chain = self.getParentValue()
next_industrial_phase_list = \ next_industrial_phase_list = \
supply_chain.getNextProductionIndustrialPhaseList(self) supply_chain.getNextProductionIndustrialPhaseList(self)
ind_phase_id_list = [x.getId() for x in next_industrial_phase_list] ind_phase_id_list = [x.getId() for x in next_industrial_phase_list]
# Get the transformation to use # Get the transformation to use
applied_rule = movement.getParent() applied_rule = movement.getParentValue()
rule = applied_rule.getSpecialiseValue() rule = applied_rule.getSpecialiseValue()
transformation = rule.getTransformation(movement) transformation = rule.getTransformation(movement)
# Call getAggregatedAmountList # Call getAggregatedAmountList
amount_list = transformation.getAggregatedAmountList( amount_list = transformation.getAggregatedAmountList(
movement.getParent().getParent(), movement.getParentValue().getParentValue(),
ind_phase_id_list=ind_phase_id_list) ind_phase_id_list=ind_phase_id_list)
resource_list = [x.getResourceValue() for x in amount_list] resource_list = [x.getResourceValue() for x in amount_list]
current_resource = movement.getResourceValue() current_resource = movement.getResourceValue()
if current_resource not in resource_list: if current_resource not in resource_list:
# We can delivered this resource # We can delivered this resource
supply_chain = self.getParent() supply_chain = self.getParentValue()
previous_ind_phase_list =\ previous_ind_phase_list =\
supply_chain.getPreviousProductionIndustrialPhaseList(self) supply_chain.getPreviousProductionIndustrialPhaseList(self)
if len(previous_ind_phase_list) == 0: if len(previous_ind_phase_list) == 0:
......
...@@ -84,7 +84,7 @@ class TransformationRule(Rule): ...@@ -84,7 +84,7 @@ class TransformationRule(Rule):
# We only produced what is asked on the Production Order # We only produced what is asked on the Production Order
result = 0 result = 0
else: else:
supply_chain = self.getSupplyChain(movement.getParent()) supply_chain = self.getSupplyChain(movement.getParentValue())
parent_supply_link = self.getCurrentSupplyLink(movement) parent_supply_link = self.getCurrentSupplyLink(movement)
current_tranfo_link_list = supply_chain.\ current_tranfo_link_list = supply_chain.\
getPreviousProductionSupplyLinkList(parent_supply_link) getPreviousProductionSupplyLinkList(parent_supply_link)
...@@ -107,13 +107,13 @@ class TransformationRule(Rule): ...@@ -107,13 +107,13 @@ class TransformationRule(Rule):
An applied rule can be expanded only if its parent movement An applied rule can be expanded only if its parent movement
is expanded. is expanded.
""" """
parent_movement = applied_rule.getParent() parent_movement = applied_rule.getParentValue()
# Get production node and production section # Get production node and production section
production = parent_movement.getSource() production = parent_movement.getSource()
production_section = parent_movement.getSourceSection() production_section = parent_movement.getSourceSection()
# Get the current supply link used to calculate consumed resource # Get the current supply link used to calculate consumed resource
# The current supply link is calculated from the parent AppliedRule. # The current supply link is calculated from the parent AppliedRule.
supply_chain = self.getSupplyChain(parent_movement.getParent()) supply_chain = self.getSupplyChain(parent_movement.getParentValue())
parent_supply_link = self.getCurrentSupplyLink(parent_movement) parent_supply_link = self.getCurrentSupplyLink(parent_movement)
current_supply_link_list = supply_chain.\ current_supply_link_list = supply_chain.\
getPreviousProductionSupplyLinkList(parent_supply_link) getPreviousProductionSupplyLinkList(parent_supply_link)
...@@ -126,12 +126,12 @@ class TransformationRule(Rule): ...@@ -126,12 +126,12 @@ class TransformationRule(Rule):
else: else:
current_supply_link = current_supply_link_list[0] current_supply_link = current_supply_link_list[0]
# Generate produced movement # Generate produced movement
movement_dict = self._expandProducedResource(applied_rule, movement_dict = self._expandProducedResource(applied_rule,
production, production,
production_section, production_section,
current_supply_link) current_supply_link)
# Generate consumed movement # Generate consumed movement
consumed_mvt_dict = self._expandConsumedResource(applied_rule, consumed_mvt_dict = self._expandConsumedResource(applied_rule,
production, production,
production_section, production_section,
current_supply_link) current_supply_link)
...@@ -148,7 +148,7 @@ class TransformationRule(Rule): ...@@ -148,7 +148,7 @@ class TransformationRule(Rule):
Create a movement for the resource produced by the transformation. Create a movement for the resource produced by the transformation.
Only one produced movement can be created. Only one produced movement can be created.
""" """
parent_movement = applied_rule.getParent() parent_movement = applied_rule.getParentValue()
stop_date = parent_movement.getStartDate() stop_date = parent_movement.getStartDate()
produced_movement_dict = { produced_movement_dict = {
'pr': { 'pr': {
...@@ -183,8 +183,8 @@ class TransformationRule(Rule): ...@@ -183,8 +183,8 @@ class TransformationRule(Rule):
# Store each value in a dictionnary before created them. # Store each value in a dictionnary before created them.
# { movement_id: {property_name: property_value,} ,} # { movement_id: {property_name: property_value,} ,}
consumed_movement_dict = {} consumed_movement_dict = {}
parent_movement = applied_rule.getParent() parent_movement = applied_rule.getParentValue()
supply_chain = self.getSupplyChain(parent_movement.getParent()) supply_chain = self.getSupplyChain(parent_movement.getParentValue())
# Consumed previous variation # Consumed previous variation
previous_variation_dict = self._expandConsumedPreviousVariation( previous_variation_dict = self._expandConsumedPreviousVariation(
applied_rule, applied_rule,
...@@ -211,7 +211,7 @@ class TransformationRule(Rule): ...@@ -211,7 +211,7 @@ class TransformationRule(Rule):
""" """
id_count = 1 id_count = 1
consumed_movement_dict = {} consumed_movement_dict = {}
parent_movement = applied_rule.getParent() parent_movement = applied_rule.getParentValue()
# Calculate the variation category list of parent movement # Calculate the variation category list of parent movement
base_category_list = parent_movement.getVariationBaseCategoryList() base_category_list = parent_movement.getVariationBaseCategoryList()
if "industrial_phase" in base_category_list: if "industrial_phase" in base_category_list:
...@@ -257,7 +257,7 @@ class TransformationRule(Rule): ...@@ -257,7 +257,7 @@ class TransformationRule(Rule):
""" """
Create a movement for each resource consumed by the transformation, Create a movement for each resource consumed by the transformation,
""" """
parent_movement = applied_rule.getParent() parent_movement = applied_rule.getParentValue()
# Calculate the context for getAggregatedAmountList # Calculate the context for getAggregatedAmountList
base_category_list = parent_movement.getVariationBaseCategoryList() base_category_list = parent_movement.getVariationBaseCategoryList()
if "industrial_phase" in base_category_list: if "industrial_phase" in base_category_list:
......
...@@ -104,12 +104,12 @@ class TransformationSourcingRuleMixin(ExtensionClass.Base): ...@@ -104,12 +104,12 @@ class TransformationSourcingRuleMixin(ExtensionClass.Base):
production_order_movement = movement.getRootSimulationMovement().\ production_order_movement = movement.getRootSimulationMovement().\
getOrderValue() getOrderValue()
# XXX Acquisition can be use instead # XXX Acquisition can be use instead
parent_uid = production_order_movement.getParent().getUid() parent_uid = production_order_movement.getParentUid()
explanation_uid = production_order_movement.getExplanationUid() explanation_uid = production_order_movement.getExplanationUid()
if parent_uid == explanation_uid: if parent_uid == explanation_uid:
production_order_line = production_order_movement production_order_line = production_order_movement
else: else:
production_order_line = production_order_movement.getParent() production_order_line = production_order_movement.getParentValue()
script = production_order_line._getTypeBasedMethod('_getTransformation') script = production_order_line._getTypeBasedMethod('_getTransformation')
if script is not None: if script is not None:
transformation = script() transformation = script()
...@@ -165,7 +165,7 @@ class TransformationSourcingRule(Rule): ...@@ -165,7 +165,7 @@ class TransformationSourcingRule(Rule):
(movement.getSourceValue() is None): (movement.getSourceValue() is None):
result = 0 result = 0
else: else:
supply_chain = self.getSupplyChain(movement.getParent()) supply_chain = self.getSupplyChain(movement.getParentValue())
parent_supply_link = self.getCurrentSupplyLink(movement) parent_supply_link = self.getCurrentSupplyLink(movement)
if not supply_chain.test(parent_supply_link, movement): if not supply_chain.test(parent_supply_link, movement):
result = 0 result = 0
...@@ -191,9 +191,9 @@ class TransformationSourcingRule(Rule): ...@@ -191,9 +191,9 @@ class TransformationSourcingRule(Rule):
An applied rule can be expanded only if its parent movement An applied rule can be expanded only if its parent movement
is expanded. is expanded.
""" """
parent_movement = applied_rule.getParent() parent_movement = applied_rule.getParentValue()
# Calculate the previous supply link # Calculate the previous supply link
supply_chain = self.getSupplyChain(parent_movement.getParent()) supply_chain = self.getSupplyChain(parent_movement.getParentValue())
parent_supply_link = self.getCurrentSupplyLink(parent_movement) parent_supply_link = self.getCurrentSupplyLink(parent_movement)
previous_supply_link_list = supply_chain.\ previous_supply_link_list = supply_chain.\
getPreviousPackingListSupplyLinkList( getPreviousPackingListSupplyLinkList(
......
...@@ -279,12 +279,12 @@ class CausalityMovementGroup(RootMovementGroup): ...@@ -279,12 +279,12 @@ class CausalityMovementGroup(RootMovementGroup):
def _getExplanationRelativeUrl(self, movement): def _getExplanationRelativeUrl(self, movement):
""" Get the order value for a movement """ """ Get the order value for a movement """
if hasattr(movement, 'getParent'): if hasattr(movement, 'getParentValue'):
# This is a simulation movement # This is a simulation movement
if movement.getParent() != movement.getRootAppliedRule() : if movement.getParentValue() != movement.getRootAppliedRule() :
# get the explanation of parent movement if we have not been # get the explanation of parent movement if we have not been
# created by the root applied rule. # created by the root applied rule.
movement = movement.getParent().getParent() movement = movement.getParentValue().getParentValue()
explanation_value = movement.getExplanationValue() explanation_value = movement.getExplanationValue()
if explanation_value is None: if explanation_value is None:
raise ValueError, 'No explanation for movement %s' % movement.getPath() raise ValueError, 'No explanation for movement %s' % movement.getPath()
...@@ -1024,7 +1024,7 @@ class TransformationAppliedRuleCausalityMovementGroup(RootMovementGroup): ...@@ -1024,7 +1024,7 @@ class TransformationAppliedRuleCausalityMovementGroup(RootMovementGroup):
def _getExplanationRelativeUrl(self, movement): def _getExplanationRelativeUrl(self, movement):
""" Get the order value for a movement """ """ Get the order value for a movement """
transformation_applied_rule = movement.getParent() transformation_applied_rule = movement.getParentValue()
transformation_rule = transformation_applied_rule.getSpecialiseValue() transformation_rule = transformation_applied_rule.getSpecialiseValue()
if transformation_rule.getPortalType() != 'Transformation Rule': if transformation_rule.getPortalType() != 'Transformation Rule':
raise MovementGroupError, 'movement! %s' % movement.getPath() raise MovementGroupError, 'movement! %s' % movement.getPath()
......
...@@ -93,8 +93,8 @@ class CopyToTarget(TargetSolver): ...@@ -93,8 +93,8 @@ class CopyToTarget(TargetSolver):
""" """
Get parent movement, and its value delta dict. Get parent movement, and its value delta dict.
""" """
applied_rule = movement.getParent() applied_rule = movement.getParentValue()
parent_movement = applied_rule.getParent() parent_movement = applied_rule.getParentValue()
if parent_movement.getPortalType() != "Simulation Movement": if parent_movement.getPortalType() != "Simulation Movement":
parent_movement = None parent_movement = None
return parent_movement, value_delta_dict return parent_movement, value_delta_dict
......
...@@ -60,7 +60,7 @@ class TransformationSourcingCopyToTarget(CopyToTarget): ...@@ -60,7 +60,7 @@ class TransformationSourcingCopyToTarget(CopyToTarget):
""" """
Get parent movement, and its value delta dict. Get parent movement, and its value delta dict.
""" """
applied_rule = movement.getParent() applied_rule = movement.getParentValue()
rule = applied_rule.getSpecialiseValue() rule = applied_rule.getSpecialiseValue()
if rule.getPortalType() != "Transformation Sourcing Rule": if rule.getPortalType() != "Transformation Sourcing Rule":
value_delta_dict.pop('aggregate_list', None) value_delta_dict.pop('aggregate_list', None)
......
...@@ -773,7 +773,7 @@ class TestAccountingRules(TestAccountingRulesMixin,ERP5TypeTestCase): ...@@ -773,7 +773,7 @@ class TestAccountingRules(TestAccountingRulesMixin,ERP5TypeTestCase):
# getTotalPrice uses mysql, so we must make sure the invoice is cataloged # getTotalPrice uses mysql, so we must make sure the invoice is cataloged
# to have correct results # to have correct results
invoice_line.getParent().recursiveImmediateReindexObject() invoice_line.getParentValue().recursiveImmediateReindexObject()
self.assertEqual(invoice_line.getTotalPrice(), 100) self.assertEqual(invoice_line.getTotalPrice(), 100)
self.assertEqual(invoice_line.getTotalQuantity(), 10) self.assertEqual(invoice_line.getTotalQuantity(), 10)
......
...@@ -719,7 +719,7 @@ be a problem).""" ...@@ -719,7 +719,7 @@ be a problem)."""
object.immediateReindexObject() object.immediateReindexObject()
if delete: if delete:
if len(from_object.portal_categories.getRelatedValueList(from_object))==0: if len(from_object.portal_categories.getRelatedValueList(from_object))==0:
parent = from_object.getParent() parent = from_object.getParentValue()
parent.manage_delObjects(from_object.getId()) parent.manage_delObjects(from_object.getId())
return corrected_list return corrected_list
......
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