Commit 24ecca64 authored by Romain Courteaud's avatar Romain Courteaud

Remove method updateTargetQuantityFromContainerQuantity.

Add method isPacked.
Remove flushActivity in _createDeliveryRule.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3142 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c423adbe
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002, 2005 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com> # Jean-Paul Smets-Solanes <jp@nexedi.com>
# Romain Courteaud <romain@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsability of assessing all potential
...@@ -32,6 +33,7 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface ...@@ -32,6 +33,7 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5.Document.Delivery import Delivery from Products.ERP5.Document.Delivery import Delivery
from zLOG import LOG
class PackingList(Delivery): class PackingList(Delivery):
""" """
...@@ -75,6 +77,7 @@ class PackingList(Delivery): ...@@ -75,6 +77,7 @@ class PackingList(Delivery):
, PropertySheet.DublinCore , PropertySheet.DublinCore
, PropertySheet.Task , PropertySheet.Task
, PropertySheet.Arrow , PropertySheet.Arrow
, PropertySheet.Comment
, PropertySheet.Movement , PropertySheet.Movement
) )
...@@ -94,48 +97,62 @@ class PackingList(Delivery): ...@@ -94,48 +97,62 @@ class PackingList(Delivery):
# Nothing to do if we are already simulated # Nothing to do if we are already simulated
self._createDeliveryRule() self._createDeliveryRule()
security.declareProtected(Permissions.ModifyPortalContent, '_createDeliveryRule') security.declareProtected(Permissions.ModifyPortalContent,\
'_createDeliveryRule')
def _createDeliveryRule(self): def _createDeliveryRule(self):
# Return if draft or cancelled simulation_state # Return if draft or cancelled simulation_state
if self.getSimulationState() in ('cancelled',): if self.getSimulationState() in ('cancelled',):
# The applied rule should be cleaned up ie. empty all movements which have # The applied rule should be cleaned up
# no confirmed children # ie. empty all movements which have no confirmed children
return return
# Otherwise, expand # Otherwise, expand
# Look up if existing applied rule # Look up if existing applied rule
my_applied_rule_list = self.getCausalityRelatedValueList(portal_type='Applied Rule') my_applied_rule_list = self.getCausalityRelatedValueList(\
portal_type='Applied Rule')
if len(my_applied_rule_list) == 0: if len(my_applied_rule_list) == 0:
if self.isSimulated(): return # No need to create a DeliveryRule if we are already in the simulation process if self.isSimulated():
# No need to create a DeliveryRule
# if we are already in the simulation process
return
# Create a new applied order rule (portal_rules.order_rule) # Create a new applied order rule (portal_rules.order_rule)
portal_rules = getToolByName(self, 'portal_rules') portal_rules = getToolByName(self, 'portal_rules')
portal_simulation = getToolByName(self, 'portal_simulation') portal_simulation = getToolByName(self, 'portal_simulation')
my_applied_rule = portal_rules.default_delivery_rule.constructNewAppliedRule(portal_simulation) my_applied_rule = portal_rules.default_delivery_rule.\
constructNewAppliedRule(portal_simulation)
# Set causality # Set causality
my_applied_rule.setCausalityValue(self) my_applied_rule.setCausalityValue(self)
my_applied_rule.flushActivity(invoke = 1) # We must make sure this rule is indexed # We must make sure this rule is indexed
# now in order not to create another one later # now in order not to create another one later
# XXX do not use flushActivity anymore !
# my_applied_rule.flushActivity(invoke = 1)
elif len(my_applied_rule_list) == 1: elif len(my_applied_rule_list) == 1:
# Re expand the rule if possible # Re expand the rule if possible
my_applied_rule = my_applied_rule_list[0] my_applied_rule = my_applied_rule_list[0]
else: else:
# Delete first rules and re expand if possible raise SimulationError, 'Packing list %s has more than one applied\
for my_applied_rule in my_applied_rule_list[0:-1]: rule.' % self.getRelativeUrl()
my_applied_rule.flushActivity(invoke=0)
my_applied_rule.aq_parent._delObject(my_applied_rule.getId())
my_applied_rule = my_applied_rule_list[-1]
# We are now certain we have a single applied rule # We are now certain we have a single applied rule
# It is time to expand it # It is time to expand it
self.activate().expand(my_applied_rule.getId()) self.activate().expand(my_applied_rule.getId())
def updateTargetQuantityFromContainerQuantity(self): #######################################################
# Container computation
security.declareProtected(Permissions.View, 'isPacked')
def isPacked(self):
""" """
Update quantities in all lines from the container quantities Returns 0 if all quantity resource on packing list line
are not in container.
It works only if a Resource is not on 2 PackingListLine.
""" """
movement_list = self.getMovementList() explanation_uid = self.getUid()
for movement in movement_list : for movement in self.getMovementList():
# this is script dependent
movement.setTargetQuantity(movement.DeliveryCell_getContainedTargetQuantity()) quantity = movement.getQuantity()
movement.flushActivity(invoke=1) # XXX FIXME: script name hardcoded
# finally edit in order to make automatic transition work in delivery_causality_workflow packed_quantity = movement.Movement_getPackedQuantity()
self.edit()
if quantity != packed_quantity:
return 0
return 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