Commit 2b76f25e authored by Yoshinori Okuji's avatar Yoshinori Okuji

Use portal methods instead of global variables.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1836 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 184792eb
...@@ -32,7 +32,6 @@ from AccessControl import ClassSecurityInfo ...@@ -32,7 +32,6 @@ from AccessControl import ClassSecurityInfo
from Products.CMFCore.WorkflowCore import WorkflowAction from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.DeliveryLine import DeliveryLine from Products.ERP5.Document.DeliveryLine import DeliveryLine
from Products.ERP5.ERP5Globals import balance_transaction_line_type_list
from Products.ERP5.Document.Amount import Amount from Products.ERP5.Document.Amount import Amount
from zLOG import LOG from zLOG import LOG
...@@ -202,7 +201,7 @@ Une ligne tarifaire.""" ...@@ -202,7 +201,7 @@ Une ligne tarifaire."""
security.declarePrivate('_setSource') security.declarePrivate('_setSource')
def _setSource(self, value): def _setSource(self, value):
self._setCategoryMembership('source', value, base=0) self._setCategoryMembership('source', value, base=0)
if self.getPortalType() not in balance_transaction_line_type_list: if self.getPortalType() not in self.getPortalBalanceTransactionLineTypeList():
source = self.restrictedTraverse(value) source = self.restrictedTraverse(value)
destination = self.getDestination() destination = self.getDestination()
mirror_list = source.getDestinationList() mirror_list = source.getDestinationList()
...@@ -220,7 +219,7 @@ Une ligne tarifaire.""" ...@@ -220,7 +219,7 @@ Une ligne tarifaire."""
security.declarePrivate('_setDestination') security.declarePrivate('_setDestination')
def _setDestination(self, value): def _setDestination(self, value):
if self.getPortalType() not in balance_transaction_line_type_list: if self.getPortalType() not in self.getPortalBalanceTransactionLineTypeList():
self._setCategoryMembership('destination', value, base=0) self._setCategoryMembership('destination', value, base=0)
destination = self.restrictedTraverse(value) destination = self.restrictedTraverse(value)
source = self.getSource() source = self.getSource()
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.Rule import Rule from Products.ERP5.Document.Rule import Rule
from Products.ERP5.ERP5Globals import movement_type_list, order_movement_type_list, reserved_inventory_state_list, current_inventory_state_list, draft_order_state
from DateTime import DateTime from DateTime import DateTime
from copy import deepcopy from copy import deepcopy
from string import lower from string import lower
...@@ -120,7 +119,7 @@ An ERP5 Rule...""" ...@@ -120,7 +119,7 @@ An ERP5 Rule..."""
# An order rule never applies since it is always explicitely instanciated # An order rule never applies since it is always explicitely instanciated
# XXX And if it is an amortisation rule ? # XXX And if it is an amortisation rule ?
return 0 return 0
# Simulation workflow # Simulation workflow
security.declareProtected(Permissions.ModifyPortalContent, 'expand') security.declareProtected(Permissions.ModifyPortalContent, 'expand')
...@@ -134,18 +133,18 @@ An ERP5 Rule...""" ...@@ -134,18 +133,18 @@ An ERP5 Rule..."""
is expanded. is expanded.
""" """
delivery_line_type = 'Simulation Movement' delivery_line_type = 'Simulation Movement'
# Get the item we come from # Get the item we come from
my_item = applied_rule.getDefaultCausalityValue() my_item = applied_rule.getDefaultCausalityValue()
# Only expand if my_item is not None # Only expand if my_item is not None
if my_item is not None: if my_item is not None:
### First, plan the theorical accounting movements ### First, plan the theorical accounting movements
accounting_movement_list = [] accounting_movement_list = []
immobilisation_movement_list = my_item.getImmobilisationMovementValueList() immobilisation_movement_list = my_item.getImmobilisationMovementValueList()
current_immo_movement = None current_immo_movement = None
for mvt_number in range(len(immobilisation_movement_list)): for mvt_number in range(len(immobilisation_movement_list)):
# Get processed immobilisation movements # Get processed immobilisation movements
...@@ -155,15 +154,15 @@ An ERP5 Rule...""" ...@@ -155,15 +154,15 @@ An ERP5 Rule..."""
next_immo_movement = immobilisation_movement_list[mvt_number + 1] next_immo_movement = immobilisation_movement_list[mvt_number + 1]
else: else:
next_immo_movement = None next_immo_movement = None
# Calculate the accounting movements # Calculate the accounting movements
accounting_movements = self._getAccountingMovement(current_immo_movement=current_immo_movement, accounting_movements = self._getAccountingMovement(current_immo_movement=current_immo_movement,
next_immo_movement=next_immo_movement, next_immo_movement=next_immo_movement,
previous_immo_movement=prev_immo_movement) previous_immo_movement=prev_immo_movement)
accounting_movement_list.extend(accounting_movements) accounting_movement_list.extend(accounting_movements)
### The next step is to create the simulation movements ### The next step is to create the simulation movements
# First, we delete all of the simulation movements which are children # First, we delete all of the simulation movements which are children
# of the applied rule : the entire simulation for this item has been # of the applied rule : the entire simulation for this item has been
...@@ -181,8 +180,8 @@ An ERP5 Rule...""" ...@@ -181,8 +180,8 @@ An ERP5 Rule..."""
else: else:
if movement_last_id_list.get( movement_id_name, None) is None or movement_id_number > movement_last_id_list[movement_id_name]: if movement_last_id_list.get( movement_id_name, None) is None or movement_id_number > movement_last_id_list[movement_id_name]:
movement_last_id_list[movement_id_name] = movement_id_number movement_last_id_list[movement_id_name] = movement_id_number
applied_rule.deleteContent(movement_id_list) applied_rule.deleteContent(movement_id_list)
ids = {} ids = {}
for accounting_movement in accounting_movement_list: for accounting_movement in accounting_movement_list:
...@@ -192,17 +191,17 @@ An ERP5 Rule...""" ...@@ -192,17 +191,17 @@ An ERP5 Rule..."""
ids[my_type] = movement_last_id_list.get(my_type, None) ids[my_type] = movement_last_id_list.get(my_type, None)
if ids[my_type] is None: if ids[my_type] is None:
ids[my_type] = -1 ids[my_type] = -1
ids[my_type] = ids[my_type] + 1 ids[my_type] = ids[my_type] + 1
new_id = my_type + '_' + str(ids[my_type]) new_id = my_type + '_' + str(ids[my_type])
# Round date # Round date
stop_date = accounting_movement['stop_date'] stop_date = accounting_movement['stop_date']
if stop_date.latestTime() - stop_date < 1/24.: if stop_date.latestTime() - stop_date < 1/24.:
stop_date = stop_date + 1 stop_date = stop_date + 1
stop_date = DateTime('%s/%s/%s' % (repr(stop_date.year()), repr(stop_date.month()), repr(stop_date.day()))) stop_date = DateTime('%s/%s/%s' % (repr(stop_date.year()), repr(stop_date.month()), repr(stop_date.day())))
accounting_movement['stop_date'] = stop_date accounting_movement['stop_date'] = stop_date
simulation_movement = applied_rule.newContent(portal_type=delivery_line_type, id=new_id ) simulation_movement = applied_rule.newContent(portal_type=delivery_line_type, id=new_id )
simulation_movement.setStartDate(stop_date) simulation_movement.setStartDate(stop_date)
simulation_movement.setTargetStartDate(stop_date) simulation_movement.setTargetStartDate(stop_date)
...@@ -215,35 +214,35 @@ An ERP5 Rule...""" ...@@ -215,35 +214,35 @@ An ERP5 Rule..."""
setter_name += tokens[i].capitalize() setter_name += tokens[i].capitalize()
setter = getattr(simulation_movement, setter_name) setter = getattr(simulation_movement, setter_name)
setter(value) setter(value)
security.declareProtected(Permissions.View, '_getAccountingMovement') security.declareProtected(Permissions.View, '_getAccountingMovement')
def _getAccountingMovement(self,current_immo_movement,next_immo_movement=None, previous_immo_movement=None): def _getAccountingMovement(self,current_immo_movement,next_immo_movement=None, previous_immo_movement=None):
""" """
Calculates the value of accounting movements during the period Calculates the value of accounting movements during the period
between the two given immobilisation movements. between the two given immobilisation movements.
If next_immo_movement is None, accounting movements are made at infinite. If next_immo_movement is None, accounting movements are made at infinite.
""" """
item = current_immo_movement.getParent() item = current_immo_movement.getParent()
if item is not None: if item is not None:
# First we need to calculate the item value at the first immobilisation movement date # First we need to calculate the item value at the first immobilisation movement date
begin_value = current_immo_movement.getAmortisationOrDefaultAmortisationPrice() begin_value = current_immo_movement.getAmortisationOrDefaultAmortisationPrice()
begin_remaining = current_immo_movement.getAmortisationOrDefaultAmortisationDuration() begin_remaining = current_immo_movement.getAmortisationOrDefaultAmortisationDuration()
# To find financial end date, we need to know the company # To find financial end date, we need to know the company
section = current_immo_movement.getSectionValue() section = current_immo_movement.getSectionValue()
currency = current_immo_movement.getPriceCurrency() currency = current_immo_movement.getPriceCurrency()
if currency is not None: if currency is not None:
currency = self.currency[currency.split('/')[-1]] currency = self.currency[currency.split('/')[-1]]
start_date = current_immo_movement.getStopDate() start_date = current_immo_movement.getStopDate()
if next_immo_movement is not None: if next_immo_movement is not None:
stop_date = next_immo_movement.getStopDate() stop_date = next_immo_movement.getStopDate()
else: else:
stop_date = None stop_date = None
returned_list = [] returned_list = []
# Calculate particular accounting movements (immobilisation beginning, end, ownership change...) # Calculate particular accounting movements (immobilisation beginning, end, ownership change...)
LOG('_getAccountingMovement start_date',0,start_date) LOG('_getAccountingMovement start_date',0,start_date)
...@@ -251,7 +250,7 @@ An ERP5 Rule...""" ...@@ -251,7 +250,7 @@ An ERP5 Rule..."""
immobilised_before = item.isImmobilised(at_date = start_date - centis) immobilised_before = item.isImmobilised(at_date = start_date - centis)
immobilised_after = current_immo_movement.getImmobilisation() immobilised_after = current_immo_movement.getImmobilisation()
replace = 0 replace = 0
if immobilised_before and previous_immo_movement is not None: if immobilised_before and previous_immo_movement is not None:
immo_begin_value = previous_immo_movement.getAmortisationOrDefaultAmortisationPrice() immo_begin_value = previous_immo_movement.getAmortisationOrDefaultAmortisationPrice()
immo_end_value = current_immo_movement.getDefaultAmortisationPrice() # We use this method in order to get the calculated value immo_end_value = current_immo_movement.getDefaultAmortisationPrice() # We use this method in order to get the calculated value
...@@ -293,8 +292,8 @@ An ERP5 Rule...""" ...@@ -293,8 +292,8 @@ An ERP5 Rule..."""
'destination_section_value' : previous_immo_movement.getSectionValue(), 'destination_section_value' : previous_immo_movement.getSectionValue(),
'resource_value' : currency } ] ) 'resource_value' : currency } ] )
replace = 1 replace = 1
if immobilised_after: if immobilised_after:
immo_begin_value = begin_value immo_begin_value = begin_value
begin_vat = current_immo_movement.getVat() begin_vat = current_immo_movement.getVat()
...@@ -340,8 +339,8 @@ An ERP5 Rule...""" ...@@ -340,8 +339,8 @@ An ERP5 Rule..."""
'source_section_value' : section, 'source_section_value' : section,
'destination_section_value' : None, 'destination_section_value' : None,
'resource_value' : currency } ] ) 'resource_value' : currency } ] )
if replace: if replace:
# Replace destination by source on the immobilisation-ending writings # Replace destination by source on the immobilisation-ending writings
for i in range(4): for i in range(4):
...@@ -350,15 +349,15 @@ An ERP5 Rule...""" ...@@ -350,15 +349,15 @@ An ERP5 Rule..."""
returned_list[i]['destination'] = None returned_list[i]['destination'] = None
returned_list[i]['destination_section_value'] = None returned_list[i]['destination_section_value'] = None
returned_list[i]['quantity'] = - returned_list[i]['quantity'] returned_list[i]['quantity'] = - returned_list[i]['quantity']
# Calculate the annuities # Calculate the annuities
current_value = begin_value current_value = begin_value
if immobilised_after: if immobilised_after:
# Search for the first financial end date after the first immobilisation movement # Search for the first financial end date after the first immobilisation movement
end_date = getClosestDate(target_date=start_date, date=section.getFinancialYearStopDate(), precision='year', before=0) end_date = getClosestDate(target_date=start_date, date=section.getFinancialYearStopDate(), precision='year', before=0)
while (stop_date is None and current_value > 0) or (stop_date is not None and end_date - stop_date < 0): while (stop_date is None and current_value > 0) or (stop_date is not None and end_date - stop_date < 0):
annuity_end_value = item.getAmortisationPrice(at_date=end_date) annuity_end_value = item.getAmortisationPrice(at_date=end_date)
if annuity_end_value is not None: if annuity_end_value is not None:
...@@ -380,10 +379,10 @@ An ERP5 Rule...""" ...@@ -380,10 +379,10 @@ An ERP5 Rule..."""
'source_section_value' : section, 'source_section_value' : section,
'destination_section_value': None, 'destination_section_value': None,
'resource_value' : currency } ] ) 'resource_value' : currency } ] )
current_value -= annuity_value current_value -= annuity_value
end_date = addToDate(end_date, {'year':1}) end_date = addToDate(end_date, {'year':1})
# Get the last period until the next immobilisation movement # Get the last period until the next immobilisation movement
if stop_date is not None: if stop_date is not None:
# We use getDefaultAmortisationPrice in order to get the calculated value of the item, # We use getDefaultAmortisationPrice in order to get the calculated value of the item,
...@@ -408,11 +407,11 @@ An ERP5 Rule...""" ...@@ -408,11 +407,11 @@ An ERP5 Rule..."""
'source_section_value' : section, 'source_section_value' : section,
'destination_section_value': None, 'destination_section_value': None,
'resource_value' : currency } ] ) 'resource_value' : currency } ] )
return returned_list return returned_list
security.declareProtected(Permissions.ModifyPortalContent, 'solve') security.declareProtected(Permissions.ModifyPortalContent, 'solve')
def solve(self, applied_rule, solution_list): def solve(self, applied_rule, solution_list):
""" """
...@@ -462,6 +461,6 @@ An ERP5 Rule...""" ...@@ -462,6 +461,6 @@ An ERP5 Rule..."""
def isDeliverable(self, m): def isDeliverable(self, m):
return 1 return 1
# XXX ? # XXX ?
if m.getSimulationState() in draft_order_state: if m.getSimulationState() in self.getPortalDraftOrderStateList():
return 0 return 0
return 1 return 1
...@@ -38,8 +38,7 @@ from Products.ERP5Type.Base import TempBase ...@@ -38,8 +38,7 @@ from Products.ERP5Type.Base import TempBase
from Products.ERP5.Document.Amount import Amount from Products.ERP5.Document.Amount import Amount
from Products.ERP5.ERP5Globals import resource_type_list, variation_type_list, \ from Products.CMFCore.Expression import Expression
column_base_category_list, line_base_category_list, tab_base_category_list
from zLOG import LOG from zLOG import LOG
...@@ -141,7 +140,7 @@ class AssortedResource(TransformedResource): ...@@ -141,7 +140,7 @@ class AssortedResource(TransformedResource):
'description' : "", 'description' : "",
'type' : 'tokens', 'type' : 'tokens',
'acquisition_base_category' : ('resource',), 'acquisition_base_category' : ('resource',),
'acquisition_portal_type' : resource_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalResourceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
...@@ -252,14 +251,14 @@ identify a bank account.""" ...@@ -252,14 +251,14 @@ identify a bank account."""
column = None column = None
line = None line = None
sorted_list = [None, None] sorted_list = [None, None]
for category in column_base_category_list: for category in self.getPortalColumnBaseCategoryList():
if category in base_category_list: if category in base_category_list:
if column is None: if column is None:
column = category column = category
else: else:
sorted_list.append(category) sorted_list.append(category)
base_category_list.remove(category) base_category_list.remove(category)
for category in line_base_category_list: for category in self.getPortalLineBaseCategoryList():
if category in base_category_list: if category in base_category_list:
if line is None: if line is None:
line = category line = category
...@@ -640,7 +639,7 @@ identify a bank account.""" ...@@ -640,7 +639,7 @@ identify a bank account."""
variation_base_category_list, variation, base=1) variation_base_category_list, variation, base=1)
# and update the price with the variation price if necessary # and update the price with the variation price if necessary
for resource_variation in self.getValueList( for resource_variation in self.getValueList(
variation_base_category_list, portal_type=variation_type_list): variation_base_category_list, portal_type=self.getPortalVariationTypeList()):
if resource_variation.hasDefaultBasePrice(): if resource_variation.hasDefaultBasePrice():
new_base_price = resource_variation.getBasePrice() new_base_price = resource_variation.getBasePrice()
try: try:
...@@ -713,7 +712,7 @@ identify a bank account.""" ...@@ -713,7 +712,7 @@ identify a bank account."""
self.portal_categories.setCategoryMembership(line_item, base_category_list, self.portal_categories.setCategoryMembership(line_item, base_category_list,
mapped_value.getCategoryMembershipList(base_category_list, base=1), base=1) mapped_value.getCategoryMembershipList(base_category_list, base=1), base=1)
for resource_variation in mapped_value.getValueList(base_category_list, for resource_variation in mapped_value.getValueList(base_category_list,
portal_type=variation_type_list): portal_type=self.getPortalVariationTypeList()):
if resource_variation.hasDefaultBasePrice(): if resource_variation.hasDefaultBasePrice():
new_base_price = resource_variation.getBasePrice() new_base_price = resource_variation.getBasePrice()
try: try:
......
...@@ -32,15 +32,11 @@ from Products.CMFCore.WorkflowCore import WorkflowMethod ...@@ -32,15 +32,11 @@ from Products.CMFCore.WorkflowCore import WorkflowMethod
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.ERP5Globals import movement_type_list, default_section_category
from Products.ERP5.ERP5Globals import current_inventory_state_list, delivery_movement_type_list
from Products.ERP5.ERP5Globals import future_inventory_state_list, reserved_inventory_state_list
from Products.ERP5Type.XMLMatrix import TempXMLMatrix from Products.ERP5Type.XMLMatrix import TempXMLMatrix
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.ERP5.Document.DeliveryCell import DeliveryCell from Products.ERP5.Document.DeliveryCell import DeliveryCell
from Acquisition import Explicit, Implicit from Acquisition import Explicit, Implicit
from Products.PythonScripts.Utility import allow_class from Products.PythonScripts.Utility import allow_class
from Products.ERP5.ERP5Globals import movement_type_list, simulated_movement_type_list, invoice_movement_type_list, container_type_list, draft_order_state
from DateTime import DateTime from DateTime import DateTime
from zLOG import LOG from zLOG import LOG
...@@ -99,7 +95,7 @@ class Group(Implicit): ...@@ -99,7 +95,7 @@ class Group(Implicit):
security.declareProtected(Permissions.AccessContentsInformation, 'getVariationBaseCategoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getVariationBaseCategoryList')
def getVariationBaseCategoryList(self): def getVariationBaseCategoryList(self):
return list(self.variation_base_category_list) return list(self.variation_base_category_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getTotalPrice') security.declareProtected(Permissions.AccessContentsInformation, 'getTotalPrice')
def getTotalPrice(self): def getTotalPrice(self):
...@@ -399,9 +395,9 @@ une liste de mouvements...""" ...@@ -399,9 +395,9 @@ une liste de mouvements..."""
""" """
# we create an invoice for this delivery # we create an invoice for this delivery
self.activate(priority=4).buildInvoiceList() self.activate(priority=4).buildInvoiceList()
invoice = WorkflowMethod(_invoice, 'invoice') invoice = WorkflowMethod(_invoice, 'invoice')
security.declareProtected(Permissions.ModifyPortalContent, 'buildInvoiceList') security.declareProtected(Permissions.ModifyPortalContent, 'buildInvoiceList')
def buildInvoiceList(self): def buildInvoiceList(self):
invoice = self.facture_vente.newContent(portal_type='Sale Invoice Transaction', invoice = self.facture_vente.newContent(portal_type='Sale Invoice Transaction',
...@@ -414,7 +410,7 @@ une liste de mouvements...""" ...@@ -414,7 +410,7 @@ une liste de mouvements..."""
description = 'Vente' description = 'Vente'
) )
invoice.setCausalityValue(self) # create causality relation invoice.setCausalityValue(self) # create causality relation
# Copy specific trade conditions (discount, payment) # Copy specific trade conditions (discount, payment)
order = self.getDefaultCausalityValue() # we only copy a single set of trade conditions order = self.getDefaultCausalityValue() # we only copy a single set of trade conditions
if order is not None : if order is not None :
...@@ -422,11 +418,11 @@ une liste de mouvements...""" ...@@ -422,11 +418,11 @@ une liste de mouvements..."""
to_copy=order.contentIds(filter={'portal_type':'Remise'}) to_copy=order.contentIds(filter={'portal_type':'Remise'})
if len(to_copy)>0 : if len(to_copy)>0 :
copy_data = order.manage_copyObjects(ids=to_copy) copy_data = order.manage_copyObjects(ids=to_copy)
new_id_list = invoice.manage_pasteObjects(copy_data) new_id_list = invoice.manage_pasteObjects(copy_data)
# copy some properties from order # copy some properties from order
for key in ('payment_amount', 'payment_ratio', 'payment_term', 'payment_end_of_month', 'payment_additional_term', 'payment_mode', 'trade_date', 'price_currency', 'destination_administration', 'destination_decision', 'destination_payment', 'source_payment'): for key in ('payment_amount', 'payment_ratio', 'payment_term', 'payment_end_of_month', 'payment_additional_term', 'payment_mode', 'trade_date', 'price_currency', 'destination_administration', 'destination_decision', 'destination_payment', 'source_payment'):
invoice.setProperty(key, order.getProperty(key)) invoice.setProperty(key, order.getProperty(key))
# Define VAT recoverability # Define VAT recoverability
if invoice.getDestinationSectionValue().getDefaultAddress() is not None : if invoice.getDestinationSectionValue().getDefaultAddress() is not None :
if invoice.getDestinationSectionValue().getDefaultAddress().getRegion() in ('Europe/Nord/France',None,'') : if invoice.getDestinationSectionValue().getDefaultAddress().getRegion() in ('Europe/Nord/France',None,'') :
...@@ -445,7 +441,7 @@ une liste de mouvements...""" ...@@ -445,7 +441,7 @@ une liste de mouvements..."""
movement_list = self.getMovementList() movement_list = self.getMovementList()
movement_group = invoice.collectMovement(movement_list) movement_group = invoice.collectMovement(movement_list)
invoice_line_list = invoice.buildInvoiceLineList(movement_group) # This method should be able to calculate price for each line invoice_line_list = invoice.buildInvoiceLineList(movement_group) # This method should be able to calculate price for each line
# Set local_roles # Set local_roles
# what's the gestionaire of this order # what's the gestionaire of this order
user_name = '' user_name = ''
...@@ -564,10 +560,12 @@ une liste de mouvements...""" ...@@ -564,10 +560,12 @@ une liste de mouvements..."""
return self.getRelativeUrl() return self.getRelativeUrl()
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementList') security.declareProtected(Permissions.AccessContentsInformation, 'getMovementList')
def getMovementList(self, portal_type=movement_type_list): def getMovementList(self, portal_type=None):
""" """
Return a list of movements. Return a list of movements.
""" """
if portal_type is None:
portal_type = self.getPortalMovementTypeList()
movement_list = [] movement_list = []
for m in self.contentValues(filter={'portal_type': portal_type}): for m in self.contentValues(filter={'portal_type': portal_type}):
if m.hasCellContent(): if m.hasCellContent():
...@@ -583,7 +581,7 @@ une liste de mouvements...""" ...@@ -583,7 +581,7 @@ une liste de mouvements..."""
Return a list of simulated movements. Return a list of simulated movements.
This does not contain Container Line or Container Cell. This does not contain Container Line or Container Cell.
""" """
return self.getMovementList(portal_type=simulated_movement_type_list) return self.getMovementList(portal_type=self.getPortalSimulatedMovementTypeList())
security.declareProtected(Permissions.AccessContentsInformation, 'getInvoiceMovementList') security.declareProtected(Permissions.AccessContentsInformation, 'getInvoiceMovementList')
def getInvoiceMovementList(self): def getInvoiceMovementList(self):
...@@ -591,7 +589,7 @@ une liste de mouvements...""" ...@@ -591,7 +589,7 @@ une liste de mouvements..."""
Return a list of simulated movements. Return a list of simulated movements.
This does not contain Container Line or Container Cell. This does not contain Container Line or Container Cell.
""" """
return self.getMovementList(portal_type=invoice_movement_type_list) return self.getMovementList(portal_type=self.getPortalInvoiceMovementTypeList())
security.declareProtected(Permissions.AccessContentsInformation, 'getContainerList') security.declareProtected(Permissions.AccessContentsInformation, 'getContainerList')
def getContainerList(self): def getContainerList(self):
...@@ -600,7 +598,7 @@ une liste de mouvements...""" ...@@ -600,7 +598,7 @@ une liste de mouvements..."""
This does not contain sub-containers. This does not contain sub-containers.
""" """
container_list = [] container_list = []
for m in self.contentValues(filter={'portal_type': container_type_list}): for m in self.contentValues(filter={'portal_type': self.getPortalContainerTypeList()}):
container_list.append(m) container_list.append(m)
return container_list return container_list
...@@ -609,7 +607,7 @@ une liste de mouvements...""" ...@@ -609,7 +607,7 @@ une liste de mouvements..."""
portal_type = 'Simulation Movement'): portal_type = 'Simulation Movement'):
# And apply # And apply
getattr(my_simulation_movement.getObject(), method_id)() getattr(my_simulation_movement.getObject(), method_id)()
for m in self.contentValues(filter={'portal_type': movement_type_list}): for m in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
# Find related in simulation # Find related in simulation
for my_simulation_movement in m.getDeliveryRelatedValueList( for my_simulation_movement in m.getDeliveryRelatedValueList(
portal_type = 'Simulation Movement'): portal_type = 'Simulation Movement'):
...@@ -655,7 +653,7 @@ une liste de mouvements...""" ...@@ -655,7 +653,7 @@ une liste de mouvements..."""
if self.isSourceSectionDivergent(): return 1 if self.isSourceSectionDivergent(): return 1
if self.isDestinationSectionDivergent(): return 1 if self.isDestinationSectionDivergent(): return 1
return 0 return 0
security.declareProtected(Permissions.View, 'isSourceDivergent') security.declareProtected(Permissions.View, 'isSourceDivergent')
def isSourceDivergent(self): def isSourceDivergent(self):
""" """
...@@ -667,7 +665,7 @@ une liste de mouvements...""" ...@@ -667,7 +665,7 @@ une liste de mouvements..."""
or len(self.getTargetSourceList()) > 1: or len(self.getTargetSourceList()) > 1:
return 1 return 1
return 0 return 0
security.declareProtected(Permissions.View, 'isDestinationDivergent') security.declareProtected(Permissions.View, 'isDestinationDivergent')
def isDestinationDivergent(self): def isDestinationDivergent(self):
""" """
...@@ -701,7 +699,7 @@ une liste de mouvements...""" ...@@ -701,7 +699,7 @@ une liste de mouvements..."""
or len(self.getTargetDestinationSectionList()) > 1: or len(self.getTargetDestinationSectionList()) > 1:
return 1 return 1
return 0 return 0
security.declareProtected(Permissions.View, 'isDateDivergent') security.declareProtected(Permissions.View, 'isDateDivergent')
def isDateDivergent(self): def isDateDivergent(self):
""" """
...@@ -717,7 +715,7 @@ une liste de mouvements...""" ...@@ -717,7 +715,7 @@ une liste de mouvements..."""
# LOG("isDivergent getTargetStartDate", 0, repr(self.getTargetStartDate())) # LOG("isDivergent getTargetStartDate", 0, repr(self.getTargetStartDate()))
# LOG("isDivergent getStopDate", 0, repr(self.getStopDate())) # LOG("isDivergent getStopDate", 0, repr(self.getStopDate()))
# LOG("isDivergent getTargetStopDate", 0, repr(self.getTargetStopDate())) # LOG("isDivergent getTargetStopDate", 0, repr(self.getTargetStopDate()))
# #
# LOG("isDivergent getStartDate", 0, repr(self.getStartDate())) # LOG("isDivergent getStartDate", 0, repr(self.getStartDate()))
# LOG("isDivergent getTargetStartDate", 0, repr(self.getTargetStartDate())) # LOG("isDivergent getTargetStartDate", 0, repr(self.getTargetStartDate()))
# LOG("isDivergent getStopDate", 0, repr(self.getStopDate())) # LOG("isDivergent getStopDate", 0, repr(self.getStopDate()))
...@@ -736,15 +734,15 @@ une liste de mouvements...""" ...@@ -736,15 +734,15 @@ une liste de mouvements..."""
# LOG("isDivergent !=", 0, str(self.getStartDate() != self.getTargetStartDate())) # LOG("isDivergent !=", 0, str(self.getStartDate() != self.getTargetStartDate()))
# LOG("isDivergent", 0, str(self.getStopDate() != self.getTargetStopDate())) # LOG("isDivergent", 0, str(self.getStopDate() != self.getTargetStopDate()))
return 1 return 1
security.declareProtected(Permissions.View, 'isQuantityDivergent') security.declareProtected(Permissions.View, 'isQuantityDivergent')
def isQuantityDivergent(self): def isQuantityDivergent(self):
""" """
""" """
for line in self.contentValues(filter={'portal_type': movement_type_list}): for line in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
if line.isDivergent(): if line.isDivergent():
return 1 return 1
security.declareProtected(Permissions.View, 'isQuantityDivergent') security.declareProtected(Permissions.View, 'isQuantityDivergent')
def isResourceDivergent(self): def isResourceDivergent(self):
""" """
...@@ -754,13 +752,13 @@ une liste de mouvements...""" ...@@ -754,13 +752,13 @@ une liste de mouvements..."""
LOG('Delivery.isResourceDivergent, self.getPath()',0,self.getPath()) LOG('Delivery.isResourceDivergent, self.getPath()',0,self.getPath())
if self.isSimulated(): if self.isSimulated():
LOG('Delivery.isResourceDivergent, self.isSimulated()',0,self.isSimulated()) LOG('Delivery.isResourceDivergent, self.isSimulated()',0,self.isSimulated())
for l in self.contentValues(filter={'portal_type':delivery_movement_type_list}): for l in self.contentValues(filter={'portal_type':self.getPortalDeliveryMovementTypeList()}):
LOG('Delivery.isResourceDivergent, l.getPath()',0,l.getPath()) LOG('Delivery.isResourceDivergent, l.getPath()',0,l.getPath())
resource = l.getResource() resource = l.getResource()
LOG('Delivery.isResourceDivergent, line_resource',0,l.getResource()) LOG('Delivery.isResourceDivergent, line_resource',0,l.getResource())
simulation_resource_list = l.getDeliveryRelatedValueList() simulation_resource_list = l.getDeliveryRelatedValueList()
simulation_resource_list += l.getOrderRelatedValueList() simulation_resource_list += l.getOrderRelatedValueList()
for simulation_resource in simulation_resource_list: for simulation_resource in simulation_resource_list:
LOG('Delivery.isResourceDivergent, sim_resource',0,simulation_resource.getResource()) LOG('Delivery.isResourceDivergent, sim_resource',0,simulation_resource.getResource())
if simulation_resource.getResource()!= resource: if simulation_resource.getResource()!= resource:
return 1 return 1
...@@ -770,7 +768,7 @@ une liste de mouvements...""" ...@@ -770,7 +768,7 @@ une liste de mouvements..."""
resource = m.getResource() resource = m.getResource()
LOG('Delivery.isResourceDivergent, resource',0,resource) LOG('Delivery.isResourceDivergent, resource',0,resource)
simulation_resource_list = m.getDeliveryRelatedValueList() simulation_resource_list = m.getDeliveryRelatedValueList()
for simulation_resource in simulation_resource_list: for simulation_resource in simulation_resource_list:
LOG('Delivery.isResourceDivergent, sim_resource',0,simulation_resource.getResource()) LOG('Delivery.isResourceDivergent, sim_resource',0,simulation_resource.getResource())
if simulation_resource.getResource()!= resource: if simulation_resource.getResource()!= resource:
return 1 return 1
...@@ -796,7 +794,7 @@ une liste de mouvements...""" ...@@ -796,7 +794,7 @@ une liste de mouvements..."""
if self.isDateDivergent(): return 1 if self.isDateDivergent(): return 1
if self.isQuantityDivergent(): return 1 if self.isQuantityDivergent(): return 1
if self.isResourceDivergent(): return 1 if self.isResourceDivergent(): return 1
return 0 return 0
security.declareProtected(Permissions.ModifyPortalContent, 'solve') security.declareProtected(Permissions.ModifyPortalContent, 'solve')
...@@ -825,7 +823,7 @@ une liste de mouvements...""" ...@@ -825,7 +823,7 @@ une liste de mouvements..."""
# Stock Management # Stock Management
def _getMovementResourceList(self): def _getMovementResourceList(self):
resource_dict = {} resource_dict = {}
for m in self.contentValues(filter={'portal_type': movement_type_list}): for m in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
r = m.getResource() r = m.getResource()
if r is not None: if r is not None:
resource_dict[r] = 1 resource_dict[r] = 1
...@@ -833,12 +831,14 @@ une liste de mouvements...""" ...@@ -833,12 +831,14 @@ une liste de mouvements..."""
security.declareProtected(Permissions.AccessContentsInformation, 'getInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getInventory')
def getInventory(self, at_date = None, section = None, node = None, def getInventory(self, at_date = None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'): if type(simulation_state) is type('a'):
simulation_state = [simulation_state] simulation_state = [simulation_state]
resource_dict = {} resource_dict = {}
for m in self.contentValues(filter={'portal_type': movement_type_list}): for m in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
resource_dict[m.getResource()] = 1 resource_dict[m.getResource()] = 1
result = self.Resource_zGetInventory( resource = self._getMovementResourceList(), result = self.Resource_zGetInventory( resource = self._getMovementResourceList(),
to_date=at_date, to_date=at_date,
...@@ -852,51 +852,59 @@ une liste de mouvements...""" ...@@ -852,51 +852,59 @@ une liste de mouvements..."""
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventory')
def getFutureInventory(self, section = None, node = None, def getFutureInventory(self, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns inventory at infinite Returns inventory at infinite
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventory(at_date=None, section=section, node=node, return self.getInventory(at_date=None, section=section, node=node,
node_category=node_category, section_category=section_category, node_category=node_category, section_category=section_category,
simulation_state=list(future_inventory_state_list)+\ simulation_state=list(self.getPortalFutureInventoryStateList())+\
list(reserved_inventory_state_list)+\ list(self.getPortalReservedInventoryStateList())+\
list(current_inventory_state_list), **kw) list(self.getPortalCurrentInventoryStateList()), **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory')
def getCurrentInventory(self, section = None, node = None, def getCurrentInventory(self, section = None, node = None,
node_category=None, section_category=default_section_category, ignore_variation=0, **kw): node_category=None, section_category=None, ignore_variation=0, **kw):
""" """
Returns current inventory Returns current inventory
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventory(section=section, node=node, return self.getInventory(section=section, node=node,
node_category=node_category, section_category=section_category, node_category=node_category, section_category=section_category,
simulation_state=current_inventory_state_list, **kw) simulation_state=self.getPortalCurrentInventoryStateList(), **kw)
#return self.getInventory(section=section, node=node, #return self.getInventory(section=section, node=node,
# node_category=node_category, section_category=section_category, # node_category=node_category, section_category=section_category,
# simulation_state='delivered', **kw) # simulation_state='delivered', **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventory')
def getAvailableInventory(self, section = None, node = None, def getAvailableInventory(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns available inventory, ie. current inventory - deliverable Returns available inventory, ie. current inventory - deliverable
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventory(at_date=DateTime(), section=section, node=node, return self.getInventory(at_date=DateTime(), section=section, node=node,
node_category=node_category, section_category=section_category, **kw) node_category=node_category, section_category=section_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryList')
def getInventoryList(self, at_date = None, section = None, node = None, def getInventoryList(self, at_date = None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'): if type(simulation_state) is type('a'):
simulation_state = [simulation_state] simulation_state = [simulation_state]
resource_dict = {} resource_dict = {}
for m in self.contentValues(filter={'portal_type': movement_type_list}): for m in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
resource_dict[m.getResource()] = 1 resource_dict[m.getResource()] = 1
result = self.Resource_zGetInventoryList(resource = resource_dict.keys(), result = self.Resource_zGetInventoryList(resource = resource_dict.keys(),
to_date=at_date, to_date=at_date,
...@@ -904,45 +912,51 @@ une liste de mouvements...""" ...@@ -904,45 +912,51 @@ une liste de mouvements..."""
node_category=node_category, node_category=node_category,
section_category=section_category, section_category=section_category,
simulation_state=simulation_state, **kw) simulation_state=simulation_state, **kw)
return result return result
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryList')
def getFutureInventoryList(self, section = None, node = None, def getFutureInventoryList(self, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of future inventory grouped by section or site Returns list of future inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryList(at_date=None, section=section, node=node, return self.getInventoryList(at_date=None, section=section, node=node,
node_category=node_category, section_category=section_category, node_category=node_category, section_category=section_category,
simulation_state=list(future_inventory_state_list)+\ simulation_state=list(self.getPortalFutureInventoryStateList())+\
list(reserved_inventory_state_list)+\ list(self.getPortalReservedInventoryStateList())+\
list(current_inventory_state_list), **kw) list(self.getPortalCurrentInventoryStateList()), **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryList')
def getCurrentInventoryList(self, section = None, node = None, def getCurrentInventoryList(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of current inventory grouped by section or site Returns list of current inventory grouped by section or site
""" """
return self.getInventoryList(simulation_state=current_inventory_state_list, section=section, node=node, if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryList(simulation_state=self.getPortalCurrentInventoryStateList(), section=section, node=node,
node_category=node_category, section_category=section_category, **kw) node_category=node_category, section_category=section_category, **kw)
#return self.getInventoryList(at_date=DateTime(), section=section, node=node, #return self.getInventoryList(at_date=DateTime(), section=section, node=node,
# node_category=node_category, section_category=section_category, **kw) # node_category=node_category, section_category=section_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryStat')
def getInventoryStat(self, at_date = None, section = None, node = None, def getInventoryStat(self, at_date = None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns statistics of inventory list grouped by section or site Returns statistics of inventory list grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
resource_dict = {} resource_dict = {}
if type(simulation_state) is type('a'): if type(simulation_state) is type('a'):
simulation_state = [simulation_state] simulation_state = [simulation_state]
for m in self.contentValues(filter={'portal_type': movement_type_list}): for m in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
resource_dict[m.getResource()] = 1 resource_dict[m.getResource()] = 1
result = self.Resource_zGetInventory(resource = resource_dict.keys(), result = self.Resource_zGetInventory(resource = resource_dict.keys(),
to_date=at_date, to_date=at_date,
...@@ -953,21 +967,25 @@ une liste de mouvements...""" ...@@ -953,21 +967,25 @@ une liste de mouvements..."""
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryStat')
def getFutureInventoryStat(self, section = None, node = None, def getFutureInventoryStat(self, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns statistics of future inventory list grouped by section or site Returns statistics of future inventory list grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryStat(at_date=None, section=section, node=node, return self.getInventoryStat(at_date=None, section=section, node=node,
node_category=node_category, section_category=section_category, **kw) node_category=node_category, section_category=section_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryStat')
def getCurrentInventoryStat(self, section = None, node = None, def getCurrentInventoryStat(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns statistics of current inventory list grouped by section or site Returns statistics of current inventory list grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryStat(simulation_state='delivered', section=section, node=node, return self.getInventoryStat(simulation_state='delivered', section=section, node=node,
node_category=node_category, section_category=section_category, **kw) node_category=node_category, section_category=section_category, **kw)
#return self.getInventoryStat(at_date=DateTime(), section=section, node=node, #return self.getInventoryStat(at_date=DateTime(), section=section, node=node,
...@@ -975,11 +993,13 @@ une liste de mouvements...""" ...@@ -975,11 +993,13 @@ une liste de mouvements..."""
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryChart')
def getInventoryChart(self, at_date = None, section = None, node = None, def getInventoryChart(self, at_date = None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'): if type(simulation_state) is type('a'):
simulation_state = [simulation_state] simulation_state = [simulation_state]
result = self.getInventoryList(at_date=at_date, section=section, node=node, result = self.getInventoryList(at_date=at_date, section=section, node=node,
...@@ -989,22 +1009,26 @@ une liste de mouvements...""" ...@@ -989,22 +1009,26 @@ une liste de mouvements..."""
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryChart')
def getFutureInventoryChart(self, section = None, node = None, def getFutureInventoryChart(self, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of future inventory grouped by section or site Returns list of future inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryChart(at_date=None, section=section, node=node, return self.getInventoryChart(at_date=None, section=section, node=node,
node_category=node_category, section_category=section_category, **kw) node_category=node_category, section_category=section_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryChart')
def getCurrentInventoryChart(self, section = None, node = None, def getCurrentInventoryChart(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of current inventory grouped by section or site Returns list of current inventory grouped by section or site
""" """
return self.getInventoryChart(simulation_state=current_inventory_state_list, section=section, node=node, if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryChart(simulation_state=self.getPortalCurrentInventoryStateList(), section=section, node=node,
node_category=node_category, section_category=section_category, **kw) node_category=node_category, section_category=section_category, **kw)
# return self.getInventoryChart(at_date=DateTime(), section=section, node=node, # return self.getInventoryChart(at_date=DateTime(), section=section, node=node,
# node_category=node_category, section_category=section_category, **kw) # node_category=node_category, section_category=section_category, **kw)
...@@ -1012,11 +1036,13 @@ une liste de mouvements...""" ...@@ -1012,11 +1036,13 @@ une liste de mouvements..."""
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryList')
def getMovementHistoryList(self, from_date = None, to_date=None, section = None, node = None, def getMovementHistoryList(self, from_date = None, to_date=None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_zGetMovementHistoryList(resource = self._getMovementResourceList(), result = self.Resource_zGetMovementHistoryList(resource = self._getMovementResourceList(),
from_date=from_date, from_date=from_date,
to_date=to_date, to_date=to_date,
...@@ -1028,11 +1054,13 @@ une liste de mouvements...""" ...@@ -1028,11 +1054,13 @@ une liste de mouvements..."""
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryStat')
def getMovementHistoryStat(self, from_date = None, to_date=None, section = None, node = None, def getMovementHistoryStat(self, from_date = None, to_date=None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_zGetInventory(resource = self._getMovementResourceList(), result = self.Resource_zGetInventory(resource = self._getMovementResourceList(),
from_date=from_date, from_date=from_date,
to_date=to_date, to_date=to_date,
...@@ -1044,12 +1072,14 @@ une liste de mouvements...""" ...@@ -1044,12 +1072,14 @@ une liste de mouvements..."""
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryList')
def getInventoryHistoryList(self, from_date = None, to_date=None, section = None, node = None, def getInventoryHistoryList(self, from_date = None, to_date=None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
# Get Movement List # Get Movement List
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_getInventoryHistoryList( resource = self._getMovementResourceList(), result = self.Resource_getInventoryHistoryList( resource = self._getMovementResourceList(),
from_date=from_date, from_date=from_date,
to_date=to_date, to_date=to_date,
...@@ -1064,12 +1094,14 @@ une liste de mouvements...""" ...@@ -1064,12 +1094,14 @@ une liste de mouvements..."""
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryChart')
def getInventoryHistoryChart(self, from_date = None, to_date=None, section = None, node = None, def getInventoryHistoryChart(self, from_date = None, to_date=None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
# Get Movement List # Get Movement List
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_getInventoryHistoryChart( resource = self._getMovementResourceList(), result = self.Resource_getInventoryHistoryChart( resource = self._getMovementResourceList(),
from_date=from_date, from_date=from_date,
to_date=to_date, to_date=to_date,
...@@ -1170,18 +1202,18 @@ une liste de mouvements...""" ...@@ -1170,18 +1202,18 @@ une liste de mouvements..."""
security.declareProtected(Permissions.ModifyPortalContent, 'updateFromSimulation') security.declareProtected(Permissions.ModifyPortalContent, 'updateFromSimulation')
def updateFromSimulation(self, update_target = 0): def updateFromSimulation(self, update_target = 0):
""" """
Updates all lines and cells of this delivery based on movements Updates all lines and cells of this delivery based on movements
in the simulation related to this delivery through the delivery relation in the simulation related to this delivery through the delivery relation
Error: resource in sim could change - we should disconnect in this case Error: resource in sim could change - we should disconnect in this case
""" """
source_list = [] source_list = []
destination_list = [] destination_list = []
target_source_list = [] target_source_list = []
target_destination_list = [] target_destination_list = []
for l in self.contentValues(filter={'portal_type':delivery_movement_type_list}): for l in self.contentValues(filter={'portal_type':self.getPortalDeliveryMovementTypeList()}):
if l.hasCellContent(): if l.hasCellContent():
for c in l.contentValues(filter={'portal_type':delivery_movement_type_list}): for c in l.contentValues(filter={'portal_type':self.getPortalDeliveryMovementTypeList()}):
#source_list.extend(c.getSimulationSourceList()) #source_list.extend(c.getSimulationSourceList())
delivery_cell_related_list = c.getDeliveryRelatedValueList() delivery_cell_related_list = c.getDeliveryRelatedValueList()
source_list.extend(map(lambda x: x.getSource(),delivery_cell_related_list)) source_list.extend(map(lambda x: x.getSource(),delivery_cell_related_list))
...@@ -1209,31 +1241,31 @@ une liste de mouvements...""" ...@@ -1209,31 +1241,31 @@ une liste de mouvements..."""
c._setTargetQuantity(simulation_target_quantity) c._setTargetQuantity(simulation_target_quantity)
# Update source list # Update source list
self._setSourceSet(source_list) # Set should make sure each item is only once self._setSourceSet(source_list) # Set should make sure each item is only once
self._setDestinationSet(destination_list) self._setDestinationSet(destination_list)
if update_target: if update_target:
self._setTargetSourceSet(target_source_list) # Set should make sure each item is only once self._setTargetSourceSet(target_source_list) # Set should make sure each item is only once
self._setTargetDestinationSet(target_destination_list) self._setTargetDestinationSet(target_destination_list)
security.declareProtected(Permissions.ModifyPortalContent, 'propagateResourceToSimulation') security.declareProtected(Permissions.ModifyPortalContent, 'propagateResourceToSimulation')
def propagateResourceToSimulation(self): def propagateResourceToSimulation(self):
""" """
Propagates any changes on resources or variations to the simulation Propagates any changes on resources or variations to the simulation
by disconnecting simulation movements refering to another resource/variation, by disconnecting simulation movements refering to another resource/variation,
creating DeliveryRules for new resources and setting target_quantity to 0 for resources creating DeliveryRules for new resources and setting target_quantity to 0 for resources
which are no longer delivered which are no longer delivered
propagateResourceToSimulation has priority (ie. must be executed before) over updateFromSimulation propagateResourceToSimulation has priority (ie. must be executed before) over updateFromSimulation
""" """
unmatched_simulation_movement = [] unmatched_simulation_movement = []
unmatched_delivery_movement = [] unmatched_delivery_movement = []
LOG('propagateResourceToSimulation, ',0,'starting') LOG('propagateResourceToSimulation, ',0,'starting')
for l in self.contentValues(filter={'portal_type':delivery_movement_type_list}): for l in self.contentValues(filter={'portal_type':self.getPortalDeliveryMovementTypeList()}):
LOG('propagateResourceToSimulation, l.getPhysicalPath()',0,l.getPhysicalPath()) LOG('propagateResourceToSimulation, l.getPhysicalPath()',0,l.getPhysicalPath())
LOG('propagateResourceToSimulation, l.objectValues()',0,l.objectValues()) LOG('propagateResourceToSimulation, l.objectValues()',0,l.objectValues())
LOG('propagateResourceToSimulation, l.hasCellContent()',0,l.hasCellContent()) LOG('propagateResourceToSimulation, l.hasCellContent()',0,l.hasCellContent())
LOG('propagateResourceToSimulation, l.showDict()',0,l.showDict()) LOG('propagateResourceToSimulation, l.showDict()',0,l.showDict())
if l.hasCellContent(): if l.hasCellContent():
for c in l.contentValues(filter={'portal_type':delivery_movement_type_list}): for c in l.contentValues(filter={'portal_type':self.getPortalDeliveryMovementTypeList()}):
LOG('propagateResourceToSimulation, c.getPhysicalPath()',0,c.getPhysicalPath()) LOG('propagateResourceToSimulation, c.getPhysicalPath()',0,c.getPhysicalPath())
for s in c.getDeliveryRelatedValueList(): for s in c.getDeliveryRelatedValueList():
LOG('propagateResourceToSimulation, s.getPhysicalPath()',0,s.getPhysicalPath()) LOG('propagateResourceToSimulation, s.getPhysicalPath()',0,s.getPhysicalPath())
...@@ -1243,18 +1275,18 @@ une liste de mouvements...""" ...@@ -1243,18 +1275,18 @@ une liste de mouvements..."""
unmatched_delivery_movement.append(c) unmatched_delivery_movement.append(c)
unmatched_simulation_movement.append(s) unmatched_simulation_movement.append(s)
s.setDelivery(None) # Disconnect s.setDelivery(None) # Disconnect
l._setQuantity(0.0) l._setQuantity(0.0)
else: else:
for s in l.getDeliveryRelatedValueList(): for s in l.getDeliveryRelatedValueList():
if s.getResource() != l.getResource() or s.getVariationText() != l.getVariationText(): if s.getResource() != l.getResource() or s.getVariationText() != l.getVariationText():
unmatched_delivery_movement.append(l) unmatched_delivery_movement.append(l)
unmatched_simulation_movement.append(s) unmatched_simulation_movement.append(s)
s.setDelivery(None) # Disconnect s.setDelivery(None) # Disconnect
l._setQuantity(0.0) l._setQuantity(0.0)
LOG('propagateResourceToSimulation, unmatched_simulation_movement',0,unmatched_simulation_movement) LOG('propagateResourceToSimulation, unmatched_simulation_movement',0,unmatched_simulation_movement)
# Build delivery list with unmatched_simulation_movement # Build delivery list with unmatched_simulation_movement
root_group = self.portal_simulation.collectMovement(unmatched_simulation_movement) root_group = self.portal_simulation.collectMovement(unmatched_simulation_movement)
new_delivery_list = self.portal_simulation.buildDeliveryList(root_group) new_delivery_list = self.portal_simulation.buildDeliveryList(root_group)
simulation_state = self.getSimulationState() simulation_state = self.getSimulationState()
if simulation_state == 'confirmed': if simulation_state == 'confirmed':
for new_delivery in new_delivery_list: for new_delivery in new_delivery_list:
......
...@@ -34,7 +34,6 @@ from Products.CMFCore.WorkflowCore import WorkflowAction ...@@ -34,7 +34,6 @@ from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.ERP5.ERP5Globals import current_inventory_state_list, target_inventory_state_list
from Products.ERP5.Document.OrderLine import OrderLine from Products.ERP5.Document.OrderLine import OrderLine
from Products.ERP5.Document.Movement import Movement from Products.ERP5.Document.Movement import Movement
from Products.ERP5.Document.SetMappedValue import SetMappedValue from Products.ERP5.Document.SetMappedValue import SetMappedValue
...@@ -305,7 +304,7 @@ Une ligne tarifaire.""" ...@@ -305,7 +304,7 @@ Une ligne tarifaire."""
""" """
Take into account efficiency in converted target quantity Take into account efficiency in converted target quantity
""" """
if self.getSimulationState() in target_inventory_state_list: if self.getSimulationState() in self.getPortalTargetInventoryStateList():
# When an order is delivered, the target quantity should be considered # When an order is delivered, the target quantity should be considered
# rather than the quantity # rather than the quantity
return Movement.getNetConvertedTargetQuantity(self) return Movement.getNetConvertedTargetQuantity(self)
...@@ -317,7 +316,7 @@ Une ligne tarifaire.""" ...@@ -317,7 +316,7 @@ Une ligne tarifaire."""
""" """
Take into account efficiency in converted target quantity Take into account efficiency in converted target quantity
""" """
if self.getSimulationState() in current_inventory_state_list: if self.getSimulationState() in self.getPortalCurrentInventoryStateList():
# When an order is delivered, the target quantity should be considered # When an order is delivered, the target quantity should be considered
# rather than the quantity # rather than the quantity
return Movement.getTargetStartDate(self) return Movement.getTargetStartDate(self)
...@@ -329,7 +328,7 @@ Une ligne tarifaire.""" ...@@ -329,7 +328,7 @@ Une ligne tarifaire."""
""" """
Take into account efficiency in converted target quantity Take into account efficiency in converted target quantity
""" """
if self.getSimulationState() in current_inventory_state_list: if self.getSimulationState() in self.getPortalCurrentInventoryStateList():
# When an order is delivered, the target quantity should be considered # When an order is delivered, the target quantity should be considered
# rather than the quantity # rather than the quantity
return Movement.getTargetStopDate(self) return Movement.getTargetStopDate(self)
...@@ -389,7 +388,7 @@ Une ligne tarifaire.""" ...@@ -389,7 +388,7 @@ Une ligne tarifaire."""
def _edit(self, REQUEST=None, force_update = 0, reindex_object = 0, **kw): def _edit(self, REQUEST=None, force_update = 0, reindex_object = 0, **kw):
""" """
""" """
SetMappedValue._edit(self, REQUEST=REQUEST, force_update = force_update, SetMappedValue._edit(self, REQUEST=REQUEST, force_update = force_update,
reindex_object=reindex_object, **kw) reindex_object=reindex_object, **kw)
if self.isSimulated(): if self.isSimulated():
self.getRootDeliveryValue().activate().propagateResourceToSimulation() self.getRootDeliveryValue().activate().propagateResourceToSimulation()
...@@ -397,4 +396,4 @@ Une ligne tarifaire.""" ...@@ -397,4 +396,4 @@ Une ligne tarifaire."""
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'] )
...@@ -36,7 +36,6 @@ from Products.ERP5Type.XMLMatrix import XMLMatrix ...@@ -36,7 +36,6 @@ from Products.ERP5Type.XMLMatrix import XMLMatrix
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.ERP5.ERP5Globals import current_inventory_state_list, target_inventory_state_list
from Products.ERP5.Document.Movement import Movement from Products.ERP5.Document.Movement import Movement
from Products.ERP5.Variated import Variated from Products.ERP5.Variated import Variated
...@@ -378,7 +377,7 @@ Une ligne tarifaire.""" ...@@ -378,7 +377,7 @@ Une ligne tarifaire."""
Take into account efficiency in converted target quantity Take into account efficiency in converted target quantity
Maybe we should only use target if isDivergent Maybe we should only use target if isDivergent
""" """
if self.getSimulationState() in target_inventory_state_list: if self.getSimulationState() in self.getPortalTargetInventoryStateList():
# When an order is delivered, the target quantity should be considered # When an order is delivered, the target quantity should be considered
# rather than the quantity # rather than the quantity
return Movement.getNetConvertedTargetQuantity(self) return Movement.getNetConvertedTargetQuantity(self)
...@@ -390,7 +389,7 @@ Une ligne tarifaire.""" ...@@ -390,7 +389,7 @@ Une ligne tarifaire."""
""" """
Take into account efficiency in converted target quantity Take into account efficiency in converted target quantity
""" """
if self.getSimulationState() in current_inventory_state_list: if self.getSimulationState() in self.getPortalCurrentInventoryStateList():
# When an order is delivered, the target quantity should be considered # When an order is delivered, the target quantity should be considered
# rather than the quantity # rather than the quantity
return Movement.getTargetStartDate(self) return Movement.getTargetStartDate(self)
...@@ -402,7 +401,7 @@ Une ligne tarifaire.""" ...@@ -402,7 +401,7 @@ Une ligne tarifaire."""
""" """
Take into account efficiency in converted target quantity Take into account efficiency in converted target quantity
""" """
if self.getSimulationState() in current_inventory_state_list: if self.getSimulationState() in self.getPortalCurrentInventoryStateList():
# When an order is delivered, the target quantity should be considered # When an order is delivered, the target quantity should be considered
# rather than the quantity # rather than the quantity
return Movement.getTargetStopDate(self) return Movement.getTargetStopDate(self)
...@@ -546,4 +545,4 @@ Une ligne tarifaire.""" ...@@ -546,4 +545,4 @@ Une ligne tarifaire."""
Returns the root delivery responsible of this line Returns the root delivery responsible of this line
""" """
return self.getParent().getRootDeliveryValue() return self.getParent().getRootDeliveryValue()
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.Rule import Rule from Products.ERP5.Document.Rule import Rule
from Products.ERP5.ERP5Globals import movement_type_list, order_movement_type_list, draft_order_state
from zLOG import LOG from zLOG import LOG
...@@ -137,14 +136,14 @@ An ERP5 Rule...""" ...@@ -137,14 +136,14 @@ An ERP5 Rule..."""
# Only expand if my_delivery is not None and state is not 'confirmed' # Only expand if my_delivery is not None and state is not 'confirmed'
if my_delivery is not None: if my_delivery is not None:
#if my_delivery.getSimulationState() not in ('delivered', ): #if my_delivery.getSimulationState() not in ('delivered', ):
# Even if delivered, we should always calculate consequences # Even if delivered, we should always calculate consequences
if 1: if 1:
# First, check each contained movement and make # First, check each contained movement and make
# a list of delivery ids which do not need to be copied # a list of delivery ids which do not need to be copied
# eventually delete movement which do not exist anylonger # eventually delete movement which do not exist anylonger
existing_uid_list = [] existing_uid_list = []
for movement in applied_rule.contentValues(filter={'portal_type':movement_type_list}): for movement in applied_rule.contentValues(filter={'portal_type':applied_rule.getPortalMovementTypeList()}):
delivery_value = movement.getDeliveryValue(portal_type=order_movement_type_list) delivery_value = movement.getDeliveryValue(portal_type=applied_rule.getPortalOrderMovementTypeList())
if delivery_value is None: if delivery_value is None:
movement.flushActivity(invoke=0) movement.flushActivity(invoke=0)
applied_rule._delObject(movement.getId()) # XXXX Make sure this is not deleted if already in delivery applied_rule._delObject(movement.getId()) # XXXX Make sure this is not deleted if already in delivery
...@@ -171,7 +170,7 @@ An ERP5 Rule...""" ...@@ -171,7 +170,7 @@ An ERP5 Rule..."""
existing_uid_list += [delivery_value.getUid()] existing_uid_list += [delivery_value.getUid()]
# Copy each movement (line or cell) from the delivery is that # Copy each movement (line or cell) from the delivery is that
for delivery_line_object in my_delivery.contentValues(filter={'portal_type':movement_type_list}): for delivery_line_object in my_delivery.contentValues(filter={'portal_type':applied_rule.getPortalMovementTypeList()}):
try: try:
if delivery_line_object.hasCellContent(): if delivery_line_object.hasCellContent():
for c in delivery_line_object.getCellValueList(): for c in delivery_line_object.getCellValueList():
...@@ -267,6 +266,6 @@ An ERP5 Rule...""" ...@@ -267,6 +266,6 @@ An ERP5 Rule..."""
return 1 return 1
def isDeliverable(self, m): def isDeliverable(self, m):
if m.getSimulationState() in draft_order_state: if m.getSimulationState() in m.getPortalDraftOrderState():
return 0 return 0
return 1 return 1
...@@ -30,8 +30,6 @@ from Globals import InitializeClass, PersistentMapping ...@@ -30,8 +30,6 @@ from Globals import InitializeClass, PersistentMapping
from Acquisition import aq_base, aq_inner, aq_parent, aq_self from Acquisition import aq_base, aq_inner, aq_parent, aq_self
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5.ERP5Globals import current_inventory_state_list
from Products.CMFCore.WorkflowCore import WorkflowAction from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
...@@ -195,7 +193,7 @@ Une ligne tarifaire.""" ...@@ -195,7 +193,7 @@ Une ligne tarifaire."""
variation_text = self.getVariationText(), variation_text = self.getVariationText(),
node = self.getDestination(), node = self.getDestination(),
section_category = self.getDestinationSection(), # We want to consolidate section_category = self.getDestinationSection(), # We want to consolidate
simulation_state = current_inventory_state_list) simulation_state = self.getPortalCurrentInventoryStateList())
inventory = self.getInventory() inventory = self.getInventory()
if current_inventory in (None, ''): if current_inventory in (None, ''):
current_inventory = 0.0 current_inventory = 0.0
......
...@@ -30,8 +30,6 @@ from Globals import InitializeClass, PersistentMapping ...@@ -30,8 +30,6 @@ from Globals import InitializeClass, PersistentMapping
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Acquisition import aq_base, aq_inner, aq_parent, aq_self from Acquisition import aq_base, aq_inner, aq_parent, aq_self
from Products.ERP5.ERP5Globals import current_inventory_state_list
from Products.CMFCore.WorkflowCore import WorkflowAction from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.XMLMatrix import XMLMatrix from Products.ERP5Type.XMLMatrix import XMLMatrix
...@@ -183,7 +181,7 @@ Une ligne tarifaire.""" ...@@ -183,7 +181,7 @@ Une ligne tarifaire."""
variation_text = self.getVariationText(), variation_text = self.getVariationText(),
node = self.getDestination(), node = self.getDestination(),
section_category = self.getDestinationSection(), section_category = self.getDestinationSection(),
simulation_state = current_inventory_state_list) simulation_state = self.getPortalCurrentInventoryStateList())
inventory = self.getInventory() inventory = self.getInventory()
if current_inventory in (None, ''): if current_inventory in (None, ''):
current_inventory = 0.0 current_inventory = 0.0
......
...@@ -43,7 +43,6 @@ from Products.CMFCore.WorkflowCore import WorkflowMethod ...@@ -43,7 +43,6 @@ from Products.CMFCore.WorkflowCore import WorkflowMethod
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5.Document.Immobilisation import Immobilisation from Products.ERP5.Document.Immobilisation import Immobilisation
#from Products.ERP5.Document.AmortisationRule import AmortisationRule #from Products.ERP5.Document.AmortisationRule import AmortisationRule
from Products.ERP5.ERP5Globals import movement_type_list
from zLOG import LOG from zLOG import LOG
...@@ -124,8 +123,8 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -124,8 +123,8 @@ Items in ERP5 are intended to provide a way to track objects."""
""" """
return XMLObject.generateNewId(self, id_group=id_group, default=default, method=method) return XMLObject.generateNewId(self, id_group=id_group, default=default, method=method)
### Amortisation ### Amortisation
security.declareProtected(Permissions.View, 'getImmobilisationMovementValueList') security.declareProtected(Permissions.View, 'getImmobilisationMovementValueList')
def getImmobilisationMovementValueList(self, from_date=None, to_date=None, sort_on="stop_date", filter_valid=1, owner_change=1, **kw): def getImmobilisationMovementValueList(self, from_date=None, to_date=None, sort_on="stop_date", filter_valid=1, owner_change=1, **kw):
...@@ -137,7 +136,7 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -137,7 +136,7 @@ Items in ERP5 are intended to provide a way to track objects."""
word_list = sort_on.split('_') word_list = sort_on.split('_')
for i in range(len(word_list)): for i in range(len(word_list)):
accessor += word_list[i].capitalize() accessor += word_list[i].capitalize()
def cmpfunc(a,b, accessor = accessor): def cmpfunc(a,b, accessor = accessor):
""" """
Compares the two objects according to the accessor value. Compares the two objects according to the accessor value.
...@@ -146,26 +145,26 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -146,26 +145,26 @@ Items in ERP5 are intended to provide a way to track objects."""
access_b = getattr(b, accessor, None) access_b = getattr(b, accessor, None)
if access_a is None or access_b is None: if access_a is None or access_b is None:
return 0 return 0
value_a = access_a() value_a = access_a()
value_b = access_b() value_b = access_b()
if value_a is None and value_b is None: if value_a is None and value_b is None:
return 0 return 0
if value_a is None or value_a < value_b: if value_a is None or value_a < value_b:
return -1 return -1
if value_b is None or value_b < value_a: if value_b is None or value_b < value_a:
return 1 return 1
return 0 return 0
depth = kw.get('depth', None) depth = kw.get('depth', None)
if depth is None: depth = 0 if depth is None: depth = 0
immobilisation_list = [] immobilisation_list = []
for immobilisation in self.contentValues(filter = { 'portal_type':'Immobilisation' } ): for immobilisation in self.contentValues(filter = { 'portal_type':'Immobilisation' } ):
LOG('Item, immobilisation.checkConsistency',0,immobilisation.checkConsistency()) LOG('Item, immobilisation.checkConsistency',0,immobilisation.checkConsistency())
if filter_valid: if filter_valid:
invalid = immobilisation._checkConsistency() # invalid = immobilisation._checkConsistency() #
else: else:
invalid = 0 invalid = 0
if not invalid: if not invalid:
...@@ -174,7 +173,7 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -174,7 +173,7 @@ Items in ERP5 are intended to provide a way to track objects."""
( from_date is None or immo_date - from_date >= 0 ): ( from_date is None or immo_date - from_date >= 0 ):
immobilisation_list.append(immobilisation) immobilisation_list.append(immobilisation)
LOG('Item.immobilisation_list',0,immobilisation_list) LOG('Item.immobilisation_list',0,immobilisation_list)
# Look for each change of ownership and an immobilisation movement within 1 hour # Look for each change of ownership and an immobilisation movement within 1 hour
# If found, adapt the immobilisation date to be correctly interpreted # If found, adapt the immobilisation date to be correctly interpreted
# If not found, and owner_change set to 1, create a context immobilisation movement # If not found, and owner_change set to 1, create a context immobilisation movement
...@@ -187,35 +186,35 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -187,35 +186,35 @@ Items in ERP5 are intended to provide a way to track objects."""
while i < len(immobilisation_list) and found_immo is None: while i < len(immobilisation_list) and found_immo is None:
immobilisation = immobilisation_list[i] immobilisation = immobilisation_list[i]
my_date = immobilisation.getStopDate() my_date = immobilisation.getStopDate()
if (my_date is not None) and (my_date - owner_date < 0) and (nearest_immo is None or nearest_immo.getStopDate() - my_date < 0): if (my_date is not None) and (my_date - owner_date < 0) and (nearest_immo is None or nearest_immo.getStopDate() - my_date < 0):
nearest_immo = immobilisation nearest_immo = immobilisation
if (my_date is not None) and abs(owner_date - my_date) < same_movement_interval: if (my_date is not None) and abs(owner_date - my_date) < same_movement_interval:
found_immo = immobilisation found_immo = immobilisation
i += 1 i += 1
if found_immo is None and owner_change and nearest_immo is not None: if found_immo is None and owner_change and nearest_immo is not None:
immobilisation = nearest_immo immobilisation = nearest_immo
if nearest_immo is not None: if nearest_immo is not None:
added_immo = None added_immo = None
added_immo = immobilisation.asContext() added_immo = immobilisation.asContext()
added_immo.setStopDate(owner_date + millis) added_immo.setStopDate(owner_date + millis)
if added_immo.getImmobilisation(): if added_immo.getImmobilisation():
vat = immobilisation.getVat() vat = immobilisation.getVat()
previous_value = immobilisation.getAmortisationOrDefaultAmortisationPrice() previous_value = immobilisation.getAmortisationOrDefaultAmortisationPrice()
current_value = added_immo.getDefaultAmortisationPrice(depth = depth + 1) current_value = added_immo.getDefaultAmortisationPrice(depth = depth + 1)
added_immo.setInputAccount(added_immo.getOutputAccount()) added_immo.setInputAccount(added_immo.getOutputAccount())
added_immo.setAmortisationBeginningPrice(current_value) added_immo.setAmortisationBeginningPrice(current_value)
added_immo.setAmortisationDuration(added_immo.getDefaultAmortisationDuration(depth = depth + 1)) added_immo.setAmortisationDuration(added_immo.getDefaultAmortisationDuration(depth = depth + 1))
added_immo.setVat( vat * current_value / previous_value ) added_immo.setVat( vat * current_value / previous_value )
immobilisation_list.append(added_immo) immobilisation_list.append(added_immo)
found_immo = added_immo found_immo = added_immo
if found_immo is not None: if found_immo is not None:
# Two cases : # Two cases :
# - An unimmobilising movement and ownership change are close : # - An unimmobilising movement and ownership change are close :
...@@ -229,13 +228,13 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -229,13 +228,13 @@ Items in ERP5 are intended to provide a way to track objects."""
else: else:
if found_date - owner_date > 0: if found_date - owner_date > 0:
found_immo.setStopDate(owner_date - centis) found_immo.setStopDate(owner_date - centis)
if sort_on is not None: if sort_on is not None:
immobilisation_list.sort(cmpfunc) immobilisation_list.sort(cmpfunc)
return immobilisation_list return immobilisation_list
security.declareProtected(Permissions.View, 'getUnfilteredImmobilisationMovementValueList') security.declareProtected(Permissions.View, 'getUnfilteredImmobilisationMovementValueList')
def getUnfilteredImmobilisationMovementValueList(self, from_date=None, to_date=None, sort_on="stop_date", owner_change=0, **kw): def getUnfilteredImmobilisationMovementValueList(self, from_date=None, to_date=None, sort_on="stop_date", owner_change=0, **kw):
...@@ -248,9 +247,9 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -248,9 +247,9 @@ Items in ERP5 are intended to provide a way to track objects."""
sort_on=sort_on, sort_on=sort_on,
owner_change=owner_change, owner_change=owner_change,
filter_valid=0, **kw) filter_valid=0, **kw)
security.declareProtected(Permissions.View, 'getPastImmobilisationMovementValueList') security.declareProtected(Permissions.View, 'getPastImmobilisationMovementValueList')
def getPastImmobilisationMovementValueList(self, from_date=None, at_date=None, sort_on="stop_date", owner_change=1, **kw): def getPastImmobilisationMovementValueList(self, from_date=None, at_date=None, sort_on="stop_date", owner_change=1, **kw):
""" """
Returns a list of immobilisation movements applied to current item before the given date, or now Returns a list of immobilisation movements applied to current item before the given date, or now
...@@ -262,10 +261,10 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -262,10 +261,10 @@ Items in ERP5 are intended to provide a way to track objects."""
owner_change = owner_change, **kw ) owner_change = owner_change, **kw )
return result return result
security.declareProtected(Permissions.View, 'getFutureImmobilisationMovementValueList') security.declareProtected(Permissions.View, 'getFutureImmobilisationMovementValueList')
def getFutureImmobilisationMovementValueList(self, to_date=None, at_date=None, sort_on="stop_date", owner_change=1, **kw): def getFutureImmobilisationMovementValueList(self, to_date=None, at_date=None, sort_on="stop_date", owner_change=1, **kw):
""" """
Returns a list of immobilisation movements applied to current item after the given date, or now Returns a list of immobilisation movements applied to current item after the given date, or now
""" """
if at_date is None: at_date = DateTime() if at_date is None: at_date = DateTime()
...@@ -275,25 +274,25 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -275,25 +274,25 @@ Items in ERP5 are intended to provide a way to track objects."""
owner_change = owner_change, **kw) owner_change = owner_change, **kw)
return result return result
security.declareProtected(Permissions.View, 'getLastImmobilisationMovementValue') security.declareProtected(Permissions.View, 'getLastImmobilisationMovementValue')
def getLastImmobilisationMovementValue(self, at_date=None, owner_change=1, **kw): def getLastImmobilisationMovementValue(self, at_date=None, owner_change=1, **kw):
""" """
Returns the last immobilisation movement before the given date, or now Returns the last immobilisation movement before the given date, or now
""" """
result_sql = self.getPastImmobilisationMovementValueList(at_date = at_date, owner_change=owner_change, **kw) result_sql = self.getPastImmobilisationMovementValueList(at_date = at_date, owner_change=owner_change, **kw)
result = None result = None
if len(result_sql) > 0: if len(result_sql) > 0:
result = result_sql[-1] result = result_sql[-1]
return result return result
security.declareProtected(Permissions.View, 'getLastMovementAmortisationDuration') security.declareProtected(Permissions.View, 'getLastMovementAmortisationDuration')
def getLastMovementAmortisationDuration(self, at_date=None, owner_change=1, **kw): def getLastMovementAmortisationDuration(self, at_date=None, owner_change=1, **kw):
""" """
Returns total duration of amortisation for the item. Returns total duration of amortisation for the item.
It is the theorical lifetime of this type of item. It is the theorical lifetime of this type of item.
""" """
...@@ -302,21 +301,21 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -302,21 +301,21 @@ Items in ERP5 are intended to provide a way to track objects."""
return last_immobilisation_movement.getAmortisationOrDefaultAmortisationDuration() return last_immobilisation_movement.getAmortisationOrDefaultAmortisationDuration()
else: else:
return None return None
security.declareProtected(Permissions.View, 'isCurrentlyImmobilised') security.declareProtected(Permissions.View, 'isCurrentlyImmobilised')
def isCurrentlyImmobilised(self, **kw): def isCurrentlyImmobilised(self, **kw):
""" Returns true if the item is immobilised at this time """ """ Returns true if the item is immobilised at this time """
return self.isImmobilised(at_date = DateTime(), **kw) return self.isImmobilised(at_date = DateTime(), **kw)
security.declareProtected(Permissions.View, 'isNotCurrentlyImmobilised') security.declareProtected(Permissions.View, 'isNotCurrentlyImmobilised')
def isNotCurrentlyImmobilised(self, **kw): def isNotCurrentlyImmobilised(self, **kw):
""" Returns true if the item is not immobilised at this time """ """ Returns true if the item is not immobilised at this time """
return not self.isCurrentlyImmobilised(**kw) return not self.isCurrentlyImmobilised(**kw)
security.declareProtected(Permissions.View, 'isImmobilised') security.declareProtected(Permissions.View, 'isImmobilised')
def isImmobilised(self, at_date=None, **kw): def isImmobilised(self, at_date=None, **kw):
""" Returns true if the item is immobilised at the given date. """ Returns true if the item is immobilised at the given date.
...@@ -325,31 +324,31 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -325,31 +324,31 @@ Items in ERP5 are intended to provide a way to track objects."""
if at_date is not None: if at_date is not None:
is_immobilised = 0 is_immobilised = 0
last_immobilisation_movement = self.getLastImmobilisationMovementValue(at_date = at_date, **kw) last_immobilisation_movement = self.getLastImmobilisationMovementValue(at_date = at_date, **kw)
if last_immobilisation_movement is not None: if last_immobilisation_movement is not None:
is_immobilised = last_immobilisation_movement.getImmobilisation() is_immobilised = last_immobilisation_movement.getImmobilisation()
else: else:
past_immobilisation_movement_list = self.getPastImmobilisationMovementValueList(at_date = DateTime(), **kw) past_immobilisation_movement_list = self.getPastImmobilisationMovementValueList(at_date = DateTime(), **kw)
for past_immobilisation in past_immobilisation_movement_list: for past_immobilisation in past_immobilisation_movement_list:
if past_immobilisation.getImmobilisation(): if past_immobilisation.getImmobilisation():
return 1 return 1
return is_immobilised return is_immobilised
security.declareProtected(Permissions.View, 'getCurrentAmortisationDuration') security.declareProtected(Permissions.View, 'getCurrentAmortisationDuration')
def getCurrentAmortisationDuration(self, **kw): def getCurrentAmortisationDuration(self, **kw):
""" Returns the total time the item has been amortised until now. """ """ Returns the total time the item has been amortised until now. """
return self.getRemainingAmortisationDuration(at_date = DateTime(), **kw) return self.getRemainingAmortisationDuration(at_date = DateTime(), **kw)
security.declareProtected(Permissions.View, 'getRemainingAmortisationDuration') security.declareProtected(Permissions.View, 'getRemainingAmortisationDuration')
def getRemainingAmortisationDuration(self, at_date=None, from_immobilisation=0, **kw): def getRemainingAmortisationDuration(self, at_date=None, from_immobilisation=0, **kw):
""" """
Returns the calculated remaining amortisation duration for the item. Returns the calculated remaining amortisation duration for the item.
It is based on the latest immobilisation period at given date, or now. It is based on the latest immobilisation period at given date, or now.
If from_immobilisation is set, we don't take the very last immobilisation movement If from_immobilisation is set, we don't take the very last immobilisation movement
at the date. It is needed if the function is called by this particular movement, unless at the date. It is needed if the function is called by this particular movement, unless
the function will never end. the function will never end.
...@@ -366,15 +365,15 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -366,15 +365,15 @@ Items in ERP5 are intended to provide a way to track objects."""
i = len(immobilisation_movements) - 1 i = len(immobilisation_movements) - 1
while i >= 0 and not immobilisation_movements[i].getImmobilisation(): while i >= 0 and not immobilisation_movements[i].getImmobilisation():
i -= 1 i -= 1
if i < 0: if i < 0:
# Neither of past immobilisation movements did immobilise the item... # Neither of past immobilisation movements did immobilise the item...
duration = self.getLastMovementAmortisationDuration(at_date=my_at_date) duration = self.getLastMovementAmortisationDuration(at_date=my_at_date)
if duration is not None: if duration is not None:
return int(duration) return int(duration)
return None return None
start_movement = immobilisation_movements[i] start_movement = immobilisation_movements[i]
if i > len(immobilisation_movements) - 2: if i > len(immobilisation_movements) - 2:
# Item is currently in an amortisation period # Item is currently in an amortisation period
...@@ -382,29 +381,29 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -382,29 +381,29 @@ Items in ERP5 are intended to provide a way to track objects."""
else: else:
stop_movement = immobilisation_movements[i+1] stop_movement = immobilisation_movements[i+1]
immo_period_stop_date = stop_movement.getStopDate() immo_period_stop_date = stop_movement.getStopDate()
immo_period_start_date = start_movement.getStopDate() immo_period_start_date = start_movement.getStopDate()
immo_period_remaining = start_movement.getAmortisationOrDefaultAmortisationDuration() immo_period_remaining = start_movement.getAmortisationOrDefaultAmortisationDuration()
immo_period_duration = getRoundedMonthBetween(immo_period_start_date, immo_period_stop_date) immo_period_duration = getRoundedMonthBetween(immo_period_start_date, immo_period_stop_date)
returned_value = immo_period_remaining - immo_period_duration returned_value = immo_period_remaining - immo_period_duration
if returned_value < 0: if returned_value < 0:
returned_value = 0 returned_value = 0
return int(returned_value) return int(returned_value)
security.declareProtected(Permissions.View, 'getAmortisationPrice') security.declareProtected(Permissions.View, 'getAmortisationPrice')
def getAmortisationPrice(self, at_date=None, from_immobilisation=0, with_currency=0, **kw): def getAmortisationPrice(self, at_date=None, from_immobilisation=0, with_currency=0, **kw):
""" """
Returns the deprecated value of item at given date, or now. Returns the deprecated value of item at given date, or now.
If from_immobilisation is set, we don't take the very last immobilisation movement If from_immobilisation is set, we don't take the very last immobilisation movement
at the date. It is needed if the function is called by this particular movement, unless at the date. It is needed if the function is called by this particular movement, unless
the function will never end. the function will never end.
If with_currency is set, returns a string containing the value and the corresponding currency. If with_currency is set, returns a string containing the value and the corresponding currency.
""" """
def calculateProrataTemporis(immo_period_start_date, immo_period_stop_date, raw_annuity_value=0, amortisation_type='degressive', financial_date=None): def calculateProrataTemporis(immo_period_start_date, immo_period_stop_date, raw_annuity_value=0, amortisation_type='degressive', financial_date=None):
...@@ -417,15 +416,15 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -417,15 +416,15 @@ Items in ERP5 are intended to provide a way to track objects."""
duration = getMonthAndDaysBetween(immo_period_start_date, immo_period_stop_date) duration = getMonthAndDaysBetween(immo_period_start_date, immo_period_stop_date)
month_number = duration['month'] month_number = duration['month']
day_number = duration['day'] day_number = duration['day']
annuity_value = month_value * (month_number + getMonthFraction(immo_period_stop_date, day_number)) annuity_value = month_value * (month_number + getMonthFraction(immo_period_stop_date, day_number))
return annuity_value return annuity_value
else: else:
# Linear amortisation : it is calculated on days, # Linear amortisation : it is calculated on days,
# unlike degressive amortisation which is calculated on months # unlike degressive amortisation which is calculated on months
return getDecimalNumberOfYearsBetween(immo_period_start_date, immo_period_stop_date, financial_date) * raw_annuity_value return getDecimalNumberOfYearsBetween(immo_period_start_date, immo_period_stop_date, financial_date) * raw_annuity_value
if at_date is None: if at_date is None:
at_date = DateTime() at_date = DateTime()
# Find the latest movement whose immobilisation is true # Find the latest movement whose immobilisation is true
...@@ -436,12 +435,12 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -436,12 +435,12 @@ Items in ERP5 are intended to provide a way to track objects."""
else: else:
my_at_date = at_date my_at_date = at_date
immobilisation_movements = self.getPastImmobilisationMovementValueList(at_date = my_at_date, **kw) immobilisation_movements = self.getPastImmobilisationMovementValueList(at_date = my_at_date, **kw)
length = len(immobilisation_movements) length = len(immobilisation_movements)
i = length - 1 i = length - 1
while i >= 0 and not immobilisation_movements[i].getImmobilisation(): while i >= 0 and not immobilisation_movements[i].getImmobilisation():
i -= 1 i -= 1
if i < 0: if i < 0:
# Neither of past immobilisation movements did immobilise the item... # Neither of past immobilisation movements did immobilise the item...
LOG ('ERP5 Warning :',0,'Neither of past immobilisation movements did immobilise the item %s' % self.getTitle()) LOG ('ERP5 Warning :',0,'Neither of past immobilisation movements did immobilise the item %s' % self.getTitle())
...@@ -451,8 +450,8 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -451,8 +450,8 @@ Items in ERP5 are intended to provide a way to track objects."""
return '%s %s' % (repr(returned_value), immobilisation_movements[-1].getPriceCurrency()) return '%s %s' % (repr(returned_value), immobilisation_movements[-1].getPriceCurrency())
return returned_value return returned_value
return None # XXX How to find the buy value ? return None # XXX How to find the buy value ?
# Find the latest immobilisation period and gather information # Find the latest immobilisation period and gather information
start_movement = immobilisation_movements[i] start_movement = immobilisation_movements[i]
currency = start_movement.getPriceCurrency() currency = start_movement.getPriceCurrency()
...@@ -465,13 +464,13 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -465,13 +464,13 @@ Items in ERP5 are intended to provide a way to track objects."""
else: else:
stop_movement = immobilisation_movements[i+1] stop_movement = immobilisation_movements[i+1]
immo_period_stop_date = stop_movement.getStopDate() immo_period_stop_date = stop_movement.getStopDate()
start_value = start_movement.getAmortisationOrDefaultAmortisationPrice() start_value = start_movement.getAmortisationOrDefaultAmortisationPrice()
immo_period_remaining_months = start_movement.getAmortisationOrDefaultAmortisationDuration() immo_period_remaining_months = start_movement.getAmortisationOrDefaultAmortisationDuration()
section = start_movement.getSectionValue() section = start_movement.getSectionValue()
financial_date = section.getFinancialYearStopDate() financial_date = section.getFinancialYearStopDate()
# Calculate the amortisation value # Calculate the amortisation value
amortisation_type = start_movement.getAmortisationType() amortisation_type = start_movement.getAmortisationType()
if amortisation_type == "linear": if amortisation_type == "linear":
...@@ -489,13 +488,13 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -489,13 +488,13 @@ Items in ERP5 are intended to provide a way to track objects."""
if with_currency: if with_currency:
return '%s %s' % (repr(round(new_value,2)), currency) return '%s %s' % (repr(round(new_value,2)), currency)
return round(new_value,2) return round(new_value,2)
elif amortisation_type == "degressive": elif amortisation_type == "degressive":
if financial_date is None: if financial_date is None:
LOG('ERP5 Warning :', 100, 'Organisation object "%s" has no financial date.' % (repr(section.getTitle()),)) LOG('ERP5 Warning :', 100, 'Organisation object "%s" has no financial date.' % (repr(section.getTitle()),))
return None return None
# Degressive amortisation is made on entire annuities, unless the first. # Degressive amortisation is made on entire annuities, unless the first.
# So, saying we immobilise on 114 months as degressive amortisation is meaningless : # So, saying we immobilise on 114 months as degressive amortisation is meaningless :
# in fact, we immobilise on 120 months. # in fact, we immobilise on 120 months.
...@@ -505,7 +504,7 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -505,7 +504,7 @@ Items in ERP5 are intended to provide a way to track objects."""
# However, if we immobilised the item during an incomplete year before, we also round the # However, if we immobilised the item during an incomplete year before, we also round the
# remaining period of immobilisation # remaining period of immobilisation
immo_period_remaining_months = roundMonthToGreaterEntireYear(immo_period_remaining_months) immo_period_remaining_months = roundMonthToGreaterEntireYear(immo_period_remaining_months)
# Degressive amortisation is taken in account on months, and not on days. # Degressive amortisation is taken in account on months, and not on days.
# So we need to adjust the immobilisation period start and stop date so that # So we need to adjust the immobilisation period start and stop date so that
# they are at the beginning of a month (a month of financial year - i.e. if # they are at the beginning of a month (a month of financial year - i.e. if
...@@ -518,7 +517,7 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -518,7 +517,7 @@ Items in ERP5 are intended to provide a way to track objects."""
first_financial_date = getClosestDate(target_date=immo_period_start_date, date=financial_date, precision='year') first_financial_date = getClosestDate(target_date=immo_period_start_date, date=financial_date, precision='year')
last_financial_date = getClosestDate(target_date=immo_period_stop_date, date=financial_date, precision='year', before=0) last_financial_date = getClosestDate(target_date=immo_period_stop_date, date=financial_date, precision='year', before=0)
is_last_amortisation_period = 0 is_last_amortisation_period = 0
# Adjust the immobilisation period stop date and last financial date # Adjust the immobilisation period stop date and last financial date
# if the current period exceeds the regular immobilisation period # if the current period exceeds the regular immobilisation period
month_difference = getIntervalBetweenDates(first_financial_date, last_financial_date, {'month':1} )['month'] month_difference = getIntervalBetweenDates(first_financial_date, last_financial_date, {'month':1} )['month']
...@@ -526,14 +525,14 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -526,14 +525,14 @@ Items in ERP5 are intended to provide a way to track objects."""
last_financial_date = addToDate(last_financial_date, {'month':immo_period_remaining_months} ) last_financial_date = addToDate(last_financial_date, {'month':immo_period_remaining_months} )
is_last_amortisation_period = 1 is_last_amortisation_period = 1
immo_period_stop_date = last_financial_date immo_period_stop_date = last_financial_date
#entire_annuities_duration = (last_financial_date.year() - first_financial_date.year()) * 365.25 #entire_annuities_duration = (last_financial_date.year() - first_financial_date.year()) * 365.25
# Find the degressive coefficient # Find the degressive coefficient
fiscal_coef = start_movement.getFiscalCoefficient() fiscal_coef = start_movement.getFiscalCoefficient()
normal_amortisation_coefficient = 1./ getYearFraction(first_financial_date, months=immo_period_remaining_months) normal_amortisation_coefficient = 1./ getYearFraction(first_financial_date, months=immo_period_remaining_months)
degressive_coef = normal_amortisation_coefficient * fiscal_coef degressive_coef = normal_amortisation_coefficient * fiscal_coef
annuities = 0 # Cumulated annuities value annuities = 0 # Cumulated annuities value
if getIntervalBetweenDates(first_financial_date, last_financial_date, {'day':1})['day'] > 0: if getIntervalBetweenDates(first_financial_date, last_financial_date, {'day':1})['day'] > 0:
# First annuity is particular since we use prorata temporis ratio # First annuity is particular since we use prorata temporis ratio
...@@ -547,16 +546,16 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -547,16 +546,16 @@ Items in ERP5 are intended to provide a way to track objects."""
else: else:
applied_coef = normal_amortisation_coefficient applied_coef = normal_amortisation_coefficient
raw_annuity_value = start_value * applied_coef raw_annuity_value = start_value * applied_coef
annuity_value = calculateProrataTemporis(immo_period_start_date, annuity_end_date, raw_annuity_value=raw_annuity_value) annuity_value = calculateProrataTemporis(immo_period_start_date, annuity_end_date, raw_annuity_value=raw_annuity_value)
annuities += annuity_value annuities += annuity_value
linear_coef = 0 linear_coef = 0
current_financial_date = second_financial_date current_financial_date = second_financial_date
# Other annuities # Other annuities
while current_financial_date < last_financial_date: while current_financial_date < last_financial_date:
remaining_months = immo_period_remaining_months - getIntervalBetweenDates(first_financial_date, remaining_months = immo_period_remaining_months - getIntervalBetweenDates(first_financial_date,
current_financial_date, {'month':1})['month'] current_financial_date, {'month':1})['month']
if not linear_coef: if not linear_coef:
# Linear coef has not been set yet, so we have to check # Linear coef has not been set yet, so we have to check
...@@ -570,7 +569,7 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -570,7 +569,7 @@ Items in ERP5 are intended to provide a way to track objects."""
applied_coef = linear_coef applied_coef = linear_coef
else: else:
applied_coef = linear_coef applied_coef = linear_coef
raw_annuity_value = current_value * applied_coef raw_annuity_value = current_value * applied_coef
if (not is_last_amortisation_period) and \ if (not is_last_amortisation_period) and \
getIntervalBetweenDates(current_financial_date, last_financial_date, {'year':1} )['year'] == 1: getIntervalBetweenDates(current_financial_date, last_financial_date, {'year':1} )['year'] == 1:
...@@ -579,10 +578,10 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -579,10 +578,10 @@ Items in ERP5 are intended to provide a way to track objects."""
annuity_value = calculateProrataTemporis(current_financial_date,immo_period_stop_date,raw_annuity_value=raw_annuity_value) annuity_value = calculateProrataTemporis(current_financial_date,immo_period_stop_date,raw_annuity_value=raw_annuity_value)
else: else:
annuity_value = raw_annuity_value annuity_value = raw_annuity_value
annuities += annuity_value annuities += annuity_value
current_financial_date = addToDate(current_financial_date, {'year':1} ) current_financial_date = addToDate(current_financial_date, {'year':1} )
# Return the calculated value # Return the calculated value
returned_value = start_value - annuities returned_value = start_value - annuities
if returned_value < 0: if returned_value < 0:
...@@ -590,17 +589,17 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -590,17 +589,17 @@ Items in ERP5 are intended to provide a way to track objects."""
if with_currency: if with_currency:
return '%s %s' % (repr(round(returned_value, 2)), currency) return '%s %s' % (repr(round(returned_value, 2)), currency)
return round(returned_value,2) return round(returned_value,2)
else: else:
# Unknown amortisation type # Unknown amortisation type
LOG('ERP5 Warning :', 0, 'Unknown amortisation type. (%s)' % (repr(amortisation_type),)) LOG('ERP5 Warning :', 0, 'Unknown amortisation type. (%s)' % (repr(amortisation_type),))
return None return None
security.declareProtected(Permissions.View, 'getCurrentAmortisationPrice') security.declareProtected(Permissions.View, 'getCurrentAmortisationPrice')
def getCurrentAmortisationPrice(self, with_currency=0, **kw): def getCurrentAmortisationPrice(self, with_currency=0, **kw):
""" Returns the deprecated value of item at current time """ """ Returns the deprecated value of item at current time """
return self.getAmortisationPrice (at_date = DateTime(), with_currency=with_currency, **kw) return self.getAmortisationPrice (at_date = DateTime(), with_currency=with_currency, **kw)
security.declareProtected(Permissions.ModifyPortalContent, 'immobilise') security.declareProtected(Permissions.ModifyPortalContent, 'immobilise')
def immobilise(self, **kw): def immobilise(self, **kw):
""" Create the immobilisation movement to immobilise the item """ """ Create the immobilisation movement to immobilise the item """
...@@ -617,14 +616,14 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -617,14 +616,14 @@ Items in ERP5 are intended to provide a way to track objects."""
new_id = str(self.generateNewId()) new_id = str(self.generateNewId())
self.newContent(portal_type = "Immobilisation", id=new_id) self.newContent(portal_type = "Immobilisation", id=new_id)
immobilisation = self[new_id] immobilisation = self[new_id]
immobilisation.setStopDate(DateTime()) immobilisation.setStopDate(DateTime())
immobilisation.setImmobilisation(immobilisation_state) immobilisation.setImmobilisation(immobilisation_state)
self.expandAmortisation() self.expandAmortisation()
return 1 return 1
security.declareProtected(Permissions.ModifyPortalContent, '_createAmortisationRule') security.declareProtected(Permissions.ModifyPortalContent, '_createAmortisationRule')
def _createAmortisationRule(self): def _createAmortisationRule(self):
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:
...@@ -634,7 +633,7 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -634,7 +633,7 @@ Items in ERP5 are intended to provide a way to track objects."""
my_applied_rule = portal_rules.default_amortisation_rule.constructNewAppliedRule(portal_simulation) my_applied_rule = portal_rules.default_amortisation_rule.constructNewAppliedRule(portal_simulation)
# Set causality # Set causality
my_applied_rule.setCausalityValue(self) my_applied_rule.setCausalityValue(self)
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]
...@@ -643,23 +642,23 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -643,23 +642,23 @@ Items in ERP5 are intended to provide a way to track objects."""
for my_applied_rule in my_applied_rule_list[:-1]: for my_applied_rule in my_applied_rule_list[:-1]:
my_applied_rule.aq_parent._delObject(my_applied_rule.getId()) my_applied_rule.aq_parent._delObject(my_applied_rule.getId())
my_applied_rule = my_applied_rule_list[-1] 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
my_applied_rule.expand() my_applied_rule.expand()
def expandAmortisation(self): def expandAmortisation(self):
""" """
Calculate the amortisation annuities for the item Calculate the amortisation annuities for the item
""" """
self.activate().immediateExpandAmortisation() self.activate().immediateExpandAmortisation()
def immediateExpandAmortisation(self): def immediateExpandAmortisation(self):
""" """
Calculate the amortisation annuities for the item Calculate the amortisation annuities for the item
""" """
self._createAmortisationRule() self._createAmortisationRule()
security.declareProtected(Permissions.View, 'getSectionChangeValueList') security.declareProtected(Permissions.View, 'getSectionChangeValueList')
def getSectionChangeValueList(self, at_date=None): def getSectionChangeValueList(self, at_date=None):
""" """
...@@ -674,21 +673,21 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -674,21 +673,21 @@ Items in ERP5 are intended to provide a way to track objects."""
""" """
date_a = a.getStopDate() date_a = a.getStopDate()
date_b = b.getStopDate() date_b = b.getStopDate()
if date_a is None and date_b is None: if date_a is None and date_b is None:
return 0 return 0
if date_a is None or date_a < date_b: if date_a is None or date_a < date_b:
return -1 return -1
if date_b is None or date_b < date_a: if date_b is None or date_b < date_a:
return 1 return 1
return 0 return 0
raw_list = self.getAggregateRelatedValueList() raw_list = self.getAggregateRelatedValueList()
delivery_list = [] delivery_list = []
for movement in raw_list: for movement in raw_list:
if movement.getPortalType() in movement_type_list: if movement.getPortalType() in self.getPortalMovementTypeList():
date = movement.getStopDate() date = movement.getStopDate()
if date is None: if date is None:
try: try:
...@@ -708,14 +707,14 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -708,14 +707,14 @@ Items in ERP5 are intended to provide a way to track objects."""
previous_owner = movement.getParent().getSourceSectionValue() previous_owner = movement.getParent().getSourceSectionValue()
except: except:
pass pass
if current_owner is not None and previous_owner != current_owner: if current_owner is not None and previous_owner != current_owner:
delivery_list.append(movement) delivery_list.append(movement)
delivery_list.sort(cmpfunc) delivery_list.sort(cmpfunc)
return delivery_list return delivery_list
security.declareProtected(Permissions.View, 'getSectionList') security.declareProtected(Permissions.View, 'getSectionList')
def getSectionList(self, at_date=None): def getSectionList(self, at_date=None):
""" """
...@@ -724,13 +723,13 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -724,13 +723,13 @@ Items in ERP5 are intended to provide a way to track objects."""
If at_date is None, return the result all the time If at_date is None, return the result all the time
""" """
delivery_list = self.getSectionChangeValueList(at_date = at_date) delivery_list = self.getSectionChangeValueList(at_date = at_date)
owner_list = [] owner_list = []
for delivery in delivery_list: for delivery in delivery_list:
owner_list.append( { 'owner' : delivery.getDestinationSectionValue(), 'date' : delivery.getStopDate() } ) owner_list.append( { 'owner' : delivery.getDestinationSectionValue(), 'date' : delivery.getStopDate() } )
return owner_list return owner_list
security.declareProtected(Permissions.View, 'getSectionValue') security.declareProtected(Permissions.View, 'getSectionValue')
def getSectionValue(self, at_date=None): def getSectionValue(self, at_date=None):
""" """
...@@ -738,12 +737,12 @@ Items in ERP5 are intended to provide a way to track objects.""" ...@@ -738,12 +737,12 @@ Items in ERP5 are intended to provide a way to track objects."""
If at_date is None, return the last owner without time limit If at_date is None, return the last owner without time limit
""" """
owner_list = self.getSectionList(at_date = at_date) owner_list = self.getSectionList(at_date = at_date)
if len(owner_list) > 0: if len(owner_list) > 0:
return owner_list[-1]['owner'] return owner_list[-1]['owner']
else: else:
return None return None
security.declareProtected(Permissions.View, 'getCurrentSectionValue') security.declareProtected(Permissions.View, 'getCurrentSectionValue')
def getCurrentSectionValue(self): def getCurrentSectionValue(self):
""" """
......
...@@ -32,7 +32,6 @@ from Products.CMFCore.utils import getToolByName ...@@ -32,7 +32,6 @@ from Products.CMFCore.utils import getToolByName
from Products.CMFCore.WorkflowCore import WorkflowMethod from Products.CMFCore.WorkflowCore import WorkflowMethod
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.ERP5.ERP5Globals import movement_type_list, draft_order_state, planned_order_state
from Products.ERP5.Document.Delivery import Delivery from Products.ERP5.Document.Delivery import Delivery
...@@ -120,11 +119,11 @@ An order...""" ...@@ -120,11 +119,11 @@ An order..."""
def _edit(self, REQUEST=None, force_update = 0, **kw): def _edit(self, REQUEST=None, force_update = 0, **kw):
Delivery._edit(self, REQUEST=REQUEST, force_update = force_update, **kw) Delivery._edit(self, REQUEST=REQUEST, force_update = force_update, **kw)
# We must expand our applied rule only if not confirmed # We must expand our applied rule only if not confirmed
if self.getSimulationState() in planned_order_state: if self.getSimulationState() in self.getPortalPlannedOrderStateList():
self.updateAppliedRule() # This should be implemented with the interaction tool rather than with this hard coding self.updateAppliedRule() # This should be implemented with the interaction tool rather than with this hard coding
def updateAppliedRule(self): def updateAppliedRule(self):
if self.getSimulationState() not in draft_order_state: if self.getSimulationState() not in self.getPortalDraftOrderStateList():
# Nothing to do # Nothing to do
self._createOrderRule() self._createOrderRule()
...@@ -288,7 +287,7 @@ An order...""" ...@@ -288,7 +287,7 @@ An order..."""
portal_type = 'Simulation Movement'): portal_type = 'Simulation Movement'):
# And apply # And apply
getattr(my_simulation_movement, method_id)() getattr(my_simulation_movement, method_id)()
for m in self.contentValues(filter={'portal_type': movement_type_list}): for m in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
# Find related in simulation # Find related in simulation
for my_simulation_movement in m.getOrderRelatedValueList( for my_simulation_movement in m.getOrderRelatedValueList(
portal_type = 'Simulation Movement'): portal_type = 'Simulation Movement'):
...@@ -311,7 +310,7 @@ An order...""" ...@@ -311,7 +310,7 @@ An order..."""
Returns simulation movements related to a cell or line of this order Returns simulation movements related to a cell or line of this order
""" """
result = self.getOrderRelatedValueList( portal_type = 'Simulation Movement') result = self.getOrderRelatedValueList( portal_type = 'Simulation Movement')
for m in self.contentValues(filter={'portal_type': movement_type_list}): for m in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
# Find related in simulation # Find related in simulation
result += m.getOrderRelatedValueList( portal_type = 'Simulation Movement') result += m.getOrderRelatedValueList( portal_type = 'Simulation Movement')
for c in m.contentValues(filter={'portal_type': 'Delivery Cell'}): for c in m.contentValues(filter={'portal_type': 'Delivery Cell'}):
......
...@@ -33,7 +33,6 @@ from Products.CMFCore.WorkflowCore import WorkflowAction ...@@ -33,7 +33,6 @@ from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.DeliveryLine import DeliveryLine from Products.ERP5.Document.DeliveryLine import DeliveryLine
from Products.ERP5.Document.Movement import Movement from Products.ERP5.Document.Movement import Movement
from Products.ERP5.ERP5Globals import draft_order_state
from zLOG import LOG from zLOG import LOG
...@@ -167,7 +166,7 @@ Une ligne tarifaire.""" ...@@ -167,7 +166,7 @@ Une ligne tarifaire."""
self[k].flushActivity(invoke=0) self[k].flushActivity(invoke=0)
self[k].immediateReindexObject() # We are forced to do this is url is changed (not uid) self[k].immediateReindexObject() # We are forced to do this is url is changed (not uid)
self._delObject(k) self._delObject(k)
security.declarePrivate('_checkConsistency') security.declarePrivate('_checkConsistency')
def _checkConsistency(self, fixit=0, mapped_value_property_list = ('target_quantity', 'price')): def _checkConsistency(self, fixit=0, mapped_value_property_list = ('target_quantity', 'price')):
""" """
...@@ -207,7 +206,7 @@ Une ligne tarifaire.""" ...@@ -207,7 +206,7 @@ Une ligne tarifaire."""
(Called when the object is created or moved.) (Called when the object is created or moved.)
""" """
DeliveryLine.manage_afterAdd(self, item, container) DeliveryLine.manage_afterAdd(self, item, container)
if self.aq_parent.getSimulationState() not in draft_order_state: if self.aq_parent.getSimulationState() not in self.getPortalDraftOrderStateList():
# Only reexpand order rule when we add lines # Only reexpand order rule when we add lines
self.aq_parent.activate()._createOrderRule() self.aq_parent.activate()._createOrderRule()
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.Rule import Rule from Products.ERP5.Document.Rule import Rule
from Products.ERP5.ERP5Globals import movement_type_list, order_movement_type_list, reserved_inventory_state_list, current_inventory_state_list, draft_order_state
from zLOG import LOG from zLOG import LOG
...@@ -140,15 +139,15 @@ An ERP5 Rule...""" ...@@ -140,15 +139,15 @@ An ERP5 Rule..."""
# Only expand order rule if order not yet confirmed (This is consistent # Only expand order rule if order not yet confirmed (This is consistent
# with the fact that once simulation is launched, we stick to it) # with the fact that once simulation is launched, we stick to it)
if force or \ if force or \
(applied_rule.getLastExpandSimulationState() not in reserved_inventory_state_list and \ (applied_rule.getLastExpandSimulationState() not in applied_rule.getPortalReservedInventoryStateList() and \
applied_rule.getLastExpandSimulationState() not in current_inventory_state_list): applied_rule.getLastExpandSimulationState() not in applied_rule.getPortalCurrentInventoryStateList()):
# First, check each contained movement and make # First, check each contained movement and make
# a list of order ids which do not need to be copied # a list of order ids which do not need to be copied
# eventually delete movement which do not exist anylonger # eventually delete movement which do not exist anylonger
existing_uid_list = [] existing_uid_list = []
for movement in applied_rule.contentValues(filter={'portal_type':movement_type_list}): for movement in applied_rule.contentValues(filter={'portal_type':applied_rule.getPortalMovementTypeList()}):
#LOG('Movement', 0, str(movement)) #LOG('Movement', 0, str(movement))
order_value = movement.getOrderValue(portal_type=order_movement_type_list) order_value = movement.getOrderValue(portal_type=applied_rule.getPortalOrderMovementTypeList())
if order_value is None: if order_value is None:
movement.flushActivity(invoke=0) movement.flushActivity(invoke=0)
applied_rule._delObject(movement.getId()) # XXXX Make sur this is not deleted if already in delivery applied_rule._delObject(movement.getId()) # XXXX Make sur this is not deleted if already in delivery
...@@ -164,7 +163,7 @@ An ERP5 Rule...""" ...@@ -164,7 +163,7 @@ An ERP5 Rule..."""
existing_uid_list += [order_value.getUid()] existing_uid_list += [order_value.getUid()]
# Copy each movement (line or cell) from the order # Copy each movement (line or cell) from the order
for order_line_object in my_order.contentValues(filter={'portal_type':movement_type_list}): for order_line_object in my_order.contentValues(filter={'portal_type':applied_rule.getPortalMovementTypeList()}):
try: try:
if order_line_object.hasCellContent(): if order_line_object.hasCellContent():
for c in order_line_object.getCellValueList(): for c in order_line_object.getCellValueList():
...@@ -249,6 +248,6 @@ An ERP5 Rule...""" ...@@ -249,6 +248,6 @@ An ERP5 Rule..."""
return 1 return 1
def isDeliverable(self, m): def isDeliverable(self, m):
if m.getSimulationState() in draft_order_state: if m.getSimulationState() in m.getPortalDraftOrderState():
return 0 return 0
return 1 return 1
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
from Globals import InitializeClass, PersistentMapping from Globals import InitializeClass, PersistentMapping
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.ERP5Globals import movement_type_list, draft_order_state
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
...@@ -140,14 +139,14 @@ An order...""" ...@@ -140,14 +139,14 @@ An order..."""
""" """
Returns 1 if not simulated or inconsistent target and values Returns 1 if not simulated or inconsistent target and values
""" """
if self.getSimulationState() not in draft_order_state: if self.getSimulationState() not in self.getPortalDraftOrderStateList():
if not self.isSimulated(): if not self.isSimulated():
return 1 return 1
return Delivery.isDivergent(self) return Delivery.isDivergent(self)
security.declareProtected(Permissions.ModifyPortalContent, 'updateAppliedRule') security.declareProtected(Permissions.ModifyPortalContent, 'updateAppliedRule')
def updateAppliedRule(self): def updateAppliedRule(self):
if self.getSimulationState() not in draft_order_state: if self.getSimulationState() not in self.getPortalDraftOrderStateList():
# Nothing to do if we are already simulated # Nothing to do if we are already simulated
self._createDeliveryRule() self._createDeliveryRule()
......
...@@ -35,7 +35,6 @@ from Products.ERP5Type.XMLMatrix import XMLMatrix ...@@ -35,7 +35,6 @@ from Products.ERP5Type.XMLMatrix import XMLMatrix
from Products.ERP5.Variated import Variated from Products.ERP5.Variated import Variated
from Products.ERP5.Core.Resource import Resource as CoreResource from Products.ERP5.Core.Resource import Resource as CoreResource
from Products.ERP5.ERP5Globals import resource_type_list, variation_type_list, default_section_category, current_inventory_state_list, future_inventory_state_list, reserved_inventory_state_list
from Products.ERP5.Document.SupplyLine import SupplyLineMixin from Products.ERP5.Document.SupplyLine import SupplyLineMixin
from zLOG import LOG from zLOG import LOG
...@@ -137,7 +136,7 @@ a service in a public administration).""" ...@@ -137,7 +136,7 @@ a service in a public administration)."""
# XXX - no idea why we should keep this ? JPS # XXX - no idea why we should keep this ? JPS
result += self.portal_categories.unrestrictedTraverse(c).getBaseItemList(base=base) result += self.portal_categories.unrestrictedTraverse(c).getBaseItemList(base=base)
try: try:
other_variations = self.searchFolder(portal_type = variation_type_list) other_variations = self.searchFolder(portal_type = self.getPortalVariationTypeList())
except: except:
other_variations = [] other_variations = []
if len(other_variations) > 0: if len(other_variations) > 0:
...@@ -156,12 +155,12 @@ a service in a public administration).""" ...@@ -156,12 +155,12 @@ a service in a public administration)."""
def getVariationRangeCategoryList(self, base_category_list = (), base=1, root=1, def getVariationRangeCategoryList(self, base_category_list = (), base=1, root=1,
display_id='getTitle', current_category=None): display_id='getTitle', current_category=None):
""" """
Returns the range of acceptable categories Returns the range of acceptable categories
""" """
return map(lambda x: x[0], self.getVariationRangeCategoryItemList(base_category_list=base_category_list, return map(lambda x: x[0], self.getVariationRangeCategoryItemList(base_category_list=base_category_list,
base=base, root=root, display_id=display_id, current_category=current_category)) base=base, root=root, display_id=display_id, current_category=current_category))
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVariationCategoryItemList') 'getVariationCategoryItemList')
def getVariationCategoryItemList(self, base_category_list = (), base=1, def getVariationCategoryItemList(self, base_category_list = (), base=1,
...@@ -172,7 +171,7 @@ a service in a public administration).""" ...@@ -172,7 +171,7 @@ a service in a public administration)."""
result = Variated.getVariationCategoryItemList(self, base_category_list = base_category_list, result = Variated.getVariationCategoryItemList(self, base_category_list = base_category_list,
display_id=display_id, base = base, current_category=None) display_id=display_id, base = base, current_category=None)
try: try:
other_variations = self.searchFolder(portal_type = variation_type_list) other_variations = self.searchFolder(portal_type = self.getPortalVariationTypeList())
except: except:
other_variations = [] other_variations = []
if len(other_variations) > 0: if len(other_variations) > 0:
...@@ -232,8 +231,10 @@ a service in a public administration).""" ...@@ -232,8 +231,10 @@ a service in a public administration)."""
# Stock Management # Stock Management
security.declareProtected(Permissions.AccessContentsInformation, 'getInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getInventory')
def getInventory(self, at_date = None, section = None, node = None, def getInventory(self, at_date = None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, variation_text=None, node_category=None, section_category=None, simulation_state=None, variation_text=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'): if type(simulation_state) is type('a'):
simulation_state = [simulation_state] simulation_state = [simulation_state]
result = self.Resource_zGetInventory(resource_uid = [self.getUid()], result = self.Resource_zGetInventory(resource_uid = [self.getUid()],
...@@ -251,48 +252,58 @@ a service in a public administration).""" ...@@ -251,48 +252,58 @@ a service in a public administration)."""
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventory')
def getFutureInventory(self, section = None, node = None, def getFutureInventory(self, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns inventory at infinite Returns inventory at infinite
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventory(at_date=None, section=section, node=node, return self.getInventory(at_date=None, section=section, node=node,
node_category=node_category, section_category=section_category, node_category=node_category, section_category=section_category,
simulation_state=list(future_inventory_state_list)+ \ simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(reserved_inventory_state_list)+list(current_inventory_state_list), list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()),
**kw) **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory')
def getCurrentInventory(self, section = None, node = None, def getCurrentInventory(self, section = None, node = None,
node_category=None, section_category=default_section_category, ignore_variation=0, variation_text=None, **kw): node_category=None, section_category=None, ignore_variation=0, variation_text=None, **kw):
""" """
Returns current inventory Returns current inventory
""" """
# Consider only delivered - forget date at this point # Consider only delivered - forget date at this point
return self.getInventory(simulation_state = current_inventory_state_list, section=section, node=node, if section_category is None:
node_category=node_category, section_category=section_category, **kw) section_category = self.getPortalDefaultSectionCategory()
return self.getInventory(simulation_state = self.getPortalCurrentInventoryStateList(),
section=section, node=node,
node_category=node_category, section_category=section_category, **kw)
#return self.getInventory(at_date=DateTime(), section=section, node=node, #return self.getInventory(at_date=DateTime(), section=section, node=node,
# node_category=node_category, section_category=section_category, **kw) # node_category=node_category, section_category=section_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventory')
def getAvailableInventory(self, section = None, node = None, def getAvailableInventory(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns available inventory, ie. current inventory - deliverable Returns available inventory, ie. current inventory - deliverable
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventory(at_date=DateTime(), section=section, node=node, return self.getInventory(at_date=DateTime(), section=section, node=node,
node_category=node_category, section_category=section_category, **kw) node_category=node_category, section_category=section_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryList')
def getInventoryList(self, at_date = None, section = None, node = None, def getInventoryList(self, at_date = None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'): if type(simulation_state) is type('a'):
simulation_state = [simulation_state] simulation_state = [simulation_state]
result = self.Resource_zGetInventoryList(resource_uid = [self.getUid()], result = self.Resource_zGetInventoryList(resource_uid = [self.getUid()],
...@@ -307,36 +318,45 @@ a service in a public administration).""" ...@@ -307,36 +318,45 @@ a service in a public administration)."""
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryList')
def getFutureInventoryList(self, section = None, node = None, def getFutureInventoryList(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
simulation_state=None, ignore_variation=0, **kw): simulation_state=None, ignore_variation=0, **kw):
""" """
Returns list of future inventory grouped by section or site Returns list of future inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
LOG('getFutureInventoryList',0,str(kw)) LOG('getFutureInventoryList',0,str(kw))
return self.getInventoryList(at_date=None, section=section, node=node, return self.getInventoryList(at_date=None, section=section, node=node,
node_category=node_category, section_category=section_category, node_category=node_category, section_category=section_category,
simulation_state=list(future_inventory_state_list)+ \ simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(reserved_inventory_state_list)+list(current_inventory_state_list), **kw) list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()),
**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryList')
def getCurrentInventoryList(self, section = None, node = None, def getCurrentInventoryList(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of current inventory grouped by section or site Returns list of current inventory grouped by section or site
""" """
return self.getInventoryList(simulation_state=current_inventory_state_list, section=section, node=node, if section_category is None:
node_category=node_category, section_category=section_category, **kw) section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryList(simulation_state=self.getPortalCurrentInventoryStateList(),
section=section, node=node,
node_category=node_category, section_category=section_category, **kw)
#return self.getInventoryList(at_date=DateTime(), section=section, node=node, #return self.getInventoryList(at_date=DateTime(), section=section, node=node,
# node_category=node_category, section_category=section_category, **kw) # node_category=node_category, section_category=section_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryStat')
def getInventoryStat(self, at_date = None, section = None, node = None, def getInventoryStat(self, at_date = None, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
simulation_state=None, ignore_variation=0, **kw): simulation_state=None, ignore_variation=0, **kw):
""" """
Returns statistics of inventory list grouped by section or site Returns statistics of inventory list grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'): if type(simulation_state) is type('a'):
simulation_state = [simulation_state] simulation_state = [simulation_state]
result = self.Resource_zGetInventory(resource_uid = [self.getUid()], result = self.Resource_zGetInventory(resource_uid = [self.getUid()],
...@@ -351,33 +371,42 @@ a service in a public administration).""" ...@@ -351,33 +371,42 @@ a service in a public administration)."""
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryStat')
def getFutureInventoryStat(self, section = None, node = None, def getFutureInventoryStat(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
simulation_state=None, ignore_variation=0, **kw): simulation_state=None, ignore_variation=0, **kw):
""" """
Returns statistics of future inventory list grouped by section or site Returns statistics of future inventory list grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryStat(at_date=None, section=section, node=node, return self.getInventoryStat(at_date=None, section=section, node=node,
node_category=node_category, section_category=section_category, node_category=node_category, section_category=section_category,
simulation_state=list(future_inventory_state_list)+ \ simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(reserved_inventory_state_list)+list(current_inventory_state_list), **kw) list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()),
**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryStat')
def getCurrentInventoryStat(self, section = None, node = None, def getCurrentInventoryStat(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns statistics of current inventory list grouped by section or site Returns statistics of current inventory list grouped by section or site
""" """
return self.getInventoryStat(simulation_state=current_inventory_state_list, section=section, node=node, if section_category is None:
node_category=node_category, section_category=section_category, **kw) section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryStat(simulation_state=self.getPortalCurrentInventoryStateList(),
section=section, node=node,
node_category=node_category, section_category=section_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryChart')
def getInventoryChart(self, at_date = None, section = None, node = None, def getInventoryChart(self, at_date = None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'): if type(simulation_state) is type('a'):
simulation_state = [simulation_state] simulation_state = [simulation_state]
result = self.Resource_zGetInventoryList(resource_uid = [self.getUid()], result = self.Resource_zGetInventoryList(resource_uid = [self.getUid()],
...@@ -392,36 +421,45 @@ a service in a public administration).""" ...@@ -392,36 +421,45 @@ a service in a public administration)."""
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryChart')
def getFutureInventoryChart(self, section = None, node = None, def getFutureInventoryChart(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
simulation_state=None, ignore_variation=0, **kw): simulation_state=None, ignore_variation=0, **kw):
""" """
Returns list of future inventory grouped by section or site Returns list of future inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryChart(at_date=None, section=section, node=node, return self.getInventoryChart(at_date=None, section=section, node=node,
node_category=node_category, section_category=section_category, node_category=node_category, section_category=section_category,
simulation_state=list(future_inventory_state_list)+ \ simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(reserved_inventory_state_list)+list(current_inventory_state_list), **kw) list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()),
**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryChart')
def getCurrentInventoryChart(self, section = None, node = None, def getCurrentInventoryChart(self, section = None, node = None,
node_category=None, section_category=default_section_category, node_category=None, section_category=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of current inventory grouped by section or site Returns list of current inventory grouped by section or site
""" """
return self.getInventoryChart(simulation_state=current_inventory_state_list, section=section, node=node, if section_category is None:
node_category=node_category, section_category=section_category, **kw) section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryChart(simulation_state=self.getPortalCurrentInventoryStateList(),
section=section, node=node,
node_category=node_category, section_category=section_category, **kw)
#return self.getInventoryChart(at_date=DateTime(), section=section, node=node, #return self.getInventoryChart(at_date=DateTime(), section=section, node=node,
# node_category=node_category, section_category=section_category, **kw) # node_category=node_category, section_category=section_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryList')
def getMovementHistoryList(self, from_date = None, to_date=None, section = None, node = None, def getMovementHistoryList(self, from_date = None, to_date=None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_zGetMovementHistoryList(resource_uid = [self.getUid()], result = self.Resource_zGetMovementHistoryList(resource_uid = [self.getUid()],
resource=None, resource=None,
from_date=from_date, from_date=from_date,
...@@ -436,11 +474,13 @@ a service in a public administration).""" ...@@ -436,11 +474,13 @@ a service in a public administration)."""
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryStat')
def getMovementHistoryStat(self, from_date = None, to_date=None, section = None, node = None, def getMovementHistoryStat(self, from_date = None, to_date=None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_zGetInventory(resource_uid = [self.getUid()], result = self.Resource_zGetInventory(resource_uid = [self.getUid()],
resource=None, resource=None,
from_date=from_date, from_date=from_date,
...@@ -454,12 +494,14 @@ a service in a public administration).""" ...@@ -454,12 +494,14 @@ a service in a public administration)."""
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryList')
def getInventoryHistoryList(self, from_date = None, to_date=None, section = None, node = None, def getInventoryHistoryList(self, from_date = None, to_date=None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
# Get Movement List # Get Movement List
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_getInventoryHistoryList( resource_uid = [self.getUid()], result = self.Resource_getInventoryHistoryList( resource_uid = [self.getUid()],
resource=None, resource=None,
from_date=from_date, from_date=from_date,
...@@ -475,12 +517,14 @@ a service in a public administration).""" ...@@ -475,12 +517,14 @@ a service in a public administration)."""
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryChart')
def getInventoryHistoryChart(self, from_date = None, to_date=None, section = None, node = None, def getInventoryHistoryChart(self, from_date = None, to_date=None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
# Get Movement List # Get Movement List
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_getInventoryHistoryChart( resource_uid = [self.getUid()], result = self.Resource_getInventoryHistoryChart( resource_uid = [self.getUid()],
resource=None, resource=None,
from_date=from_date, from_date=from_date,
...@@ -496,12 +540,14 @@ a service in a public administration).""" ...@@ -496,12 +540,14 @@ a service in a public administration)."""
security.declareProtected(Permissions.AccessContentsInformation, 'getNextNegativeInventoryDate') security.declareProtected(Permissions.AccessContentsInformation, 'getNextNegativeInventoryDate')
def getNextNegativeInventoryDate(self, from_date = None, section = None, node = None, def getNextNegativeInventoryDate(self, from_date = None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
variation_text = None, variation_text = None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if from_date is None: from_date = DateTime() if from_date is None: from_date = DateTime()
# Get Movement List # Get Movement List
result = self.Resource_getInventoryHistoryList( resource_uid = [self.getUid()], result = self.Resource_getInventoryHistoryList( resource_uid = [self.getUid()],
...@@ -579,10 +625,10 @@ a service in a public administration).""" ...@@ -579,10 +625,10 @@ a service in a public administration)."""
# TO BE DONE XXX # TO BE DONE XXX
# reindex cells when price, quantity or source/dest changes # reindex cells when price, quantity or source/dest changes
# For generation of matrix lines # For generation of matrix lines
security.declareProtected( Permissions.ModifyPortalContent, '_setQuantityStepList' ) security.declareProtected( Permissions.ModifyPortalContent, '_setQuantityStepList' )
def _setQuantityStepList(self, value): def _setQuantityStepList(self, value):
self._baseSetQuantityStepList(value) self._baseSetQuantityStepList(value)
value = self.getQuantityStepList() value = self.getQuantityStepList()
value.sort() value.sort()
...@@ -593,11 +639,11 @@ a service in a public administration).""" ...@@ -593,11 +639,11 @@ a service in a public administration)."""
for i in range(0, len(value) - 1): for i in range(0, len(value) - 1):
p = self.newContent(id = 'quantity_range_%s' % i, portal_type = 'Predicate') p = self.newContent(id = 'quantity_range_%s' % i, portal_type = 'Predicate')
p.setCriterionPropertyList(('quantity', )) p.setCriterionPropertyList(('quantity', ))
p.setCriterion('quantity', min=value[i], max=value[i+1]) p.setCriterion('quantity', min=value[i], max=value[i+1])
p.setTitle('%s <= quantity < %s' % (repr(value[i]),repr(value[i+1]))) p.setTitle('%s <= quantity < %s' % (repr(value[i]),repr(value[i+1])))
self.updateSupplyMatrix() self.updateSupplyMatrix()
# Predicate handling # Predicate handling
security.declareProtected(Permissions.AccessContentsInformation, 'asPredicate') security.declareProtected(Permissions.AccessContentsInformation, 'asPredicate')
def asPredicate(self): def asPredicate(self):
""" """
...@@ -608,8 +654,8 @@ a service in a public administration).""" ...@@ -608,8 +654,8 @@ a service in a public administration)."""
p.setMembershipCriterionBaseCategoryList(('resource',)) p.setMembershipCriterionBaseCategoryList(('resource',))
p.setMembershipCriterionCategoryList(('resource/%s' % self.getRelativeUrl(),)) p.setMembershipCriterionCategoryList(('resource/%s' % self.getRelativeUrl(),))
return p return p
#monkeyPatch(SupplyLineMixin) #monkeyPatch(SupplyLineMixin)
from types import FunctionType from types import FunctionType
for id, m in SupplyLineMixin.__dict__.items(): for id, m in SupplyLineMixin.__dict__.items():
if type(m) is FunctionType: if type(m) is FunctionType:
......
...@@ -34,7 +34,6 @@ from Products.ERP5Type.XMLObject import XMLObject ...@@ -34,7 +34,6 @@ from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.Utils import asList, keepIn, rejectIn from Products.ERP5Type.Utils import asList, keepIn, rejectIn
from Products.ERP5.Variated import Variated from Products.ERP5.Variated import Variated
from Products.ERP5.ERP5Globals import resource_type_list, variation_type_list
from Products.ERP5.Document.Domain import Domain from Products.ERP5.Document.Domain import Domain
......
...@@ -37,7 +37,7 @@ from Products.ERP5Type.Base import TempBase ...@@ -37,7 +37,7 @@ from Products.ERP5Type.Base import TempBase
from Products.ERP5.Document.Amount import Amount from Products.ERP5.Document.Amount import Amount
from Products.ERP5.ERP5Globals import resource_type_list, variation_type_list from Products.CMFCore.Expression import Expression
from zLOG import LOG from zLOG import LOG
...@@ -131,7 +131,7 @@ class TransformedResource(XMLObject, XMLMatrix, Amount): ...@@ -131,7 +131,7 @@ class TransformedResource(XMLObject, XMLMatrix, Amount):
'description' : "", 'description' : "",
'type' : 'tokens', 'type' : 'tokens',
'acquisition_base_category' : ('resource',), 'acquisition_base_category' : ('resource',),
'acquisition_portal_type' : resource_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalResourceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
...@@ -588,7 +588,7 @@ identify a bank account.""" ...@@ -588,7 +588,7 @@ identify a bank account."""
variation_base_category_list, variation, base=1) variation_base_category_list, variation, base=1)
# and update the price with the variation price if necessary # and update the price with the variation price if necessary
for resource_variation in self.getValueList( for resource_variation in self.getValueList(
variation_base_category_list, portal_type=variation_type_list): variation_base_category_list, portal_type=self.getPortalVariationTypeList()):
if resource_variation.hasDefaultBasePrice(): if resource_variation.hasDefaultBasePrice():
new_base_price = resource_variation.getBasePrice() new_base_price = resource_variation.getBasePrice()
try: try:
...@@ -636,7 +636,7 @@ identify a bank account.""" ...@@ -636,7 +636,7 @@ identify a bank account."""
self.portal_categories.setCategoryMembership(line_item, base_category_list, self.portal_categories.setCategoryMembership(line_item, base_category_list,
mapped_value.getCategoryMembershipList(base_category_list, base=1), base=1) mapped_value.getCategoryMembershipList(base_category_list, base=1), base=1)
for resource_variation in mapped_value.getValueList(base_category_list, for resource_variation in mapped_value.getValueList(base_category_list,
portal_type=variation_type_list): portal_type=self.getPortalVariationTypeList()):
if resource_variation.hasDefaultBasePrice(): if resource_variation.hasDefaultBasePrice():
new_base_price = resource_variation.getBasePrice() new_base_price = resource_variation.getBasePrice()
try: try:
...@@ -705,4 +705,4 @@ identify a bank account.""" ...@@ -705,4 +705,4 @@ identify a bank account."""
) )
return [line_item], total_base_price, total_source_base_price, \ return [line_item], total_base_price, total_source_base_price, \
total_variated_base_price, total_variated_source_base_price, duration total_variated_base_price, total_variated_source_base_price, duration
...@@ -34,7 +34,8 @@ from Products.ERP5Type.XMLObject import XMLObject ...@@ -34,7 +34,8 @@ from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.XMLMatrix import XMLMatrix from Products.ERP5Type.XMLMatrix import XMLMatrix
from Products.ERP5.Variated import Variated from Products.ERP5.Variated import Variated
from Products.ERP5Type.Utils import cartesianProduct from Products.ERP5Type.Utils import cartesianProduct
from Products.ERP5.ERP5Globals import resource_type_list
from Products.CMFCore.Expression import Expression
from zLOG import LOG from zLOG import LOG
...@@ -73,7 +74,7 @@ class VariatedProperty(XMLObject, XMLMatrix, Variated): ...@@ -73,7 +74,7 @@ class VariatedProperty(XMLObject, XMLMatrix, Variated):
'storage_id' : 'variation_base_category_list', 'storage_id' : 'variation_base_category_list',
'description' : "", 'description' : "",
'type' : 'tokens', 'type' : 'tokens',
'acquisition_portal_type' : resource_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalResourceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
......
...@@ -30,7 +30,6 @@ from AccessControl import ClassSecurityInfo ...@@ -30,7 +30,6 @@ from AccessControl import ClassSecurityInfo
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.Rule import Rule from Products.ERP5.Document.Rule import Rule
from Products.ERP5.ERP5Globals import movement_type_list
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from zLOG import LOG from zLOG import LOG
......
from Products.ERP5.ERP5Globals import *
from Products.ERP5.Tool.Category import addBaseCategory from Products.ERP5.Tool.Category import addBaseCategory
from Products.ERP5Type.Utils import convertToUpperCase from Products.ERP5Type.Utils import convertToUpperCase
...@@ -6,17 +5,21 @@ from Products.ERP5Type.Utils import convertToUpperCase ...@@ -6,17 +5,21 @@ from Products.ERP5Type.Utils import convertToUpperCase
def setBaseAcquisition(self): def setBaseAcquisition(self):
pc = self.portal_categories pc = self.portal_categories
# Source and destination are defined by delivery, order, parent # Source and destination are defined by delivery, order, parent
# we should not use causality here because of production reports # we should not use causality here because of production reports
# for which source or destination can be None (ie. different from Production Order) # for which source or destination can be None (ie. different from Production Order)
for bc in ('source', 'destination', for bc in ('source', 'destination',
'target_source', 'target_destination', 'target_source', 'target_destination',
'source_section', 'destination_section', 'source_section', 'destination_section',
'target_source_section', 'target_destination_section',): 'target_source_section', 'target_destination_section',):
if not hasattr(pc, bc): if not hasattr(pc, bc):
addBaseCategory(pc, bc) addBaseCategory(pc, bc)
pc[bc].setAcquisitionBaseCategoryList(('delivery', 'order', 'parent', )) pc[bc].setAcquisitionBaseCategoryList(('delivery', 'order', 'parent', ))
pc[bc].setAcquisitionPortalTypeList(movement_or_item_or_delivery_or_order_or_invoice_type_list) pc[bc].setAcquisitionPortalTypeList(self.getPortalAcquisitionMovementTypeList() + \
self.getPortalItemTypeList() + \
self.getPortalDeliveryTypeList() + \
self.getPortalOrderTypeList() + \
self.getPortalInvoiceTypeList())
pc[bc].setAcquisitionMaskValue(1) pc[bc].setAcquisitionMaskValue(1)
pc[bc].setAcquisitionCopyValue(0) pc[bc].setAcquisitionCopyValue(0)
pc[bc].setAcquisitionAppendValue(0) pc[bc].setAcquisitionAppendValue(0)
...@@ -28,7 +31,11 @@ def setBaseAcquisition(self): ...@@ -28,7 +31,11 @@ def setBaseAcquisition(self):
if not hasattr(pc, bc): if not hasattr(pc, bc):
addBaseCategory(pc, bc) addBaseCategory(pc, bc)
pc[bc].setAcquisitionBaseCategoryList(('delivery', 'order', 'parent', 'causality')) pc[bc].setAcquisitionBaseCategoryList(('delivery', 'order', 'parent', 'causality'))
pc[bc].setAcquisitionPortalTypeList(movement_or_item_or_delivery_or_order_or_invoice_type_list) pc[bc].setAcquisitionPortalTypeList(self.getPortalAcquisitionMovementTypeList() + \
self.getPortalItemTypeList() + \
self.getPortalDeliveryTypeList() + \
self.getPortalOrderTypeList() + \
self.getPortalInvoiceTypeList())
pc[bc].setAcquisitionMaskValue(1) pc[bc].setAcquisitionMaskValue(1)
pc[bc].setAcquisitionCopyValue(0) pc[bc].setAcquisitionCopyValue(0)
pc[bc].setAcquisitionAppendValue(0) pc[bc].setAcquisitionAppendValue(0)
...@@ -37,7 +44,11 @@ def setBaseAcquisition(self): ...@@ -37,7 +44,11 @@ def setBaseAcquisition(self):
if not hasattr(pc, bc): if not hasattr(pc, bc):
addBaseCategory(pc, bc) addBaseCategory(pc, bc)
pc[bc].setAcquisitionBaseCategoryList(('delivery', 'order', 'parent')) pc[bc].setAcquisitionBaseCategoryList(('delivery', 'order', 'parent'))
pc[bc].setAcquisitionPortalTypeList(movement_or_item_or_delivery_or_order_or_invoice_type_list) pc[bc].setAcquisitionPortalTypeList(self.getPortalAcquisitionMovementTypeList() + \
self.getPortalItemTypeList() + \
self.getPortalDeliveryTypeList() + \
self.getPortalOrderTypeList() + \
self.getPortalInvoiceTypeList())
pc[bc].setAcquisitionMaskValue(1) pc[bc].setAcquisitionMaskValue(1)
pc[bc].setAcquisitionCopyValue(0) pc[bc].setAcquisitionCopyValue(0)
pc[bc].setAcquisitionAppendValue(0) pc[bc].setAcquisitionAppendValue(0)
...@@ -46,7 +57,11 @@ def setBaseAcquisition(self): ...@@ -46,7 +57,11 @@ def setBaseAcquisition(self):
if not hasattr(pc, bc): if not hasattr(pc, bc):
addBaseCategory(pc, bc) addBaseCategory(pc, bc)
pc[bc].setAcquisitionBaseCategoryList(('delivery', 'order', 'parent', )) pc[bc].setAcquisitionBaseCategoryList(('delivery', 'order', 'parent', ))
pc[bc].setAcquisitionPortalTypeList(movement_or_item_or_delivery_or_order_or_invoice_type_list) pc[bc].setAcquisitionPortalTypeList(self.getPortalAcquisitionMovementTypeList() + \
self.getPortalItemTypeList() + \
self.getPortalDeliveryTypeList() + \
self.getPortalOrderTypeList() + \
self.getPortalInvoiceTypeList())
pc[bc].setAcquisitionMaskValue(1) pc[bc].setAcquisitionMaskValue(1)
pc[bc].setAcquisitionCopyValue(0) pc[bc].setAcquisitionCopyValue(0)
pc[bc].setAcquisitionAppendValue(0) pc[bc].setAcquisitionAppendValue(0)
...@@ -55,8 +70,12 @@ def setBaseAcquisition(self): ...@@ -55,8 +70,12 @@ def setBaseAcquisition(self):
if not hasattr(pc, bc): if not hasattr(pc, bc):
addBaseCategory(pc, bc) addBaseCategory(pc, bc)
pc[bc].setAcquisitionBaseCategoryList(('delivery', 'order', 'parent', 'resource')) pc[bc].setAcquisitionBaseCategoryList(('delivery', 'order', 'parent', 'resource'))
pc[bc].setAcquisitionPortalTypeList( pc[bc].setAcquisitionPortalTypeList(self.getPortalAcquisitionMovementTypeList() + \
movement_or_item_or_delivery_or_order_or_invoice_or_resource_type_list) self.getPortalItemTypeList() + \
self.getPortalDeliveryTypeList() + \
self.getPortalOrderTypeList() + \
self.getPortalInvoiceTypeList() + \
self.getPortalResourceTypeList())
pc[bc].setAcquisitionMaskValue(1) pc[bc].setAcquisitionMaskValue(1)
pc[bc].setAcquisitionCopyValue(0) pc[bc].setAcquisitionCopyValue(0)
pc[bc].setAcquisitionAppendValue(0) pc[bc].setAcquisitionAppendValue(0)
...@@ -86,13 +105,13 @@ def setBaseAcquisition(self): ...@@ -86,13 +105,13 @@ def setBaseAcquisition(self):
pc[bc].setAcquisitionSyncValue(1) pc[bc].setAcquisitionSyncValue(1)
pc[bc].setAcquisitionObjectIdList(['default_career']) pc[bc].setAcquisitionObjectIdList(['default_career'])
# Immobilisation acquisition # Immobilisation acquisition
for bc in ('input_account', 'output_account', 'immobilisation_account', for bc in ('input_account', 'output_account', 'immobilisation_account',
'amortisation_account', 'depreciation_account', 'vat_account', 'amortisation_account', 'depreciation_account', 'vat_account',
'amortisation_type', ): 'amortisation_type', ):
if not hasattr(pc, bc): if not hasattr(pc, bc):
addBaseCategory(pc, bc) addBaseCategory(pc, bc)
pc[bc].setAcquisitionBaseCategoryList('parent',) pc[bc].setAcquisitionBaseCategoryList('parent',)
pc[bc].setAcquisitionPortalTypeList(item_type_list) pc[bc].setAcquisitionPortalTypeList(self.getPortalItemTypeList())
pc[bc].setAcquisitionMaskValue(1) pc[bc].setAcquisitionMaskValue(1)
pc[bc].setAcquisitionCopyValue(1) pc[bc].setAcquisitionCopyValue(1)
pc[bc].setAcquisitionAppendValue(0) pc[bc].setAcquisitionAppendValue(0)
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import default_section_category, current_inventory_state_list, reserved_inventory_state_list,reserved_inventory_state_list2,future_inventory_state_list
from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain
from DateTime import DateTime from DateTime import DateTime
from ZTUtils import make_query from ZTUtils import make_query
...@@ -30,7 +29,7 @@ class InventoryBrain(ZSQLBrain): ...@@ -30,7 +29,7 @@ class InventoryBrain(ZSQLBrain):
simulation_state = [simulation_state] simulation_state = [simulation_state]
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], result = self.Resource_zGetInventory( resource_uid = [self.resource_uid],
to_date=at_date, omit_simulation = 0, to_date=at_date, omit_simulation = 0,
section_category = default_section_category, section_category = self.getPortalDefaultSectionCategory(),
simulation_state=simulation_state) simulation_state=simulation_state)
inventory = None inventory = None
if len(result) > 0: if len(result) > 0:
...@@ -45,14 +44,17 @@ class InventoryBrain(ZSQLBrain): ...@@ -45,14 +44,17 @@ class InventoryBrain(ZSQLBrain):
""" """
Returns current inventory Returns current inventory
""" """
return self.getInventory(simulation_state=current_inventory_state_list, ignore_variation=1) return self.getInventory(simulation_state=self.getPortalCurrentInventoryStateList(), ignore_variation=1)
#return self.getInventory(at_date=DateTime(), ignore_variation=1) #return self.getInventory(at_date=DateTime(), ignore_variation=1)
def getFutureInventory(self): def getFutureInventory(self):
""" """
Returns current inventory Returns current inventory
""" """
return self.getInventory(ignore_variation=1,simulation_state=list(future_inventory_state_list)+list(reserved_inventory_state_list)+list(current_inventory_state_list)) return self.getInventory(ignore_variation=1,
simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()))
def getAvailableInventory(self): def getAvailableInventory(self):
""" """
...@@ -62,8 +64,8 @@ class InventoryBrain(ZSQLBrain): ...@@ -62,8 +64,8 @@ class InventoryBrain(ZSQLBrain):
current = self.getCurrentInventory() current = self.getCurrentInventory()
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], ignore_variation=1, result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], ignore_variation=1,
omit_simulation = 1, omit_input = 1, omit_simulation = 1, omit_input = 1,
section_category = default_section_category, section_category = self.getPortalDefaultSectionCategory(),
simulation_state = reserved_inventory_state_list) simulation_state = self.getPortalReservedInventoryStateList())
reserved_inventory = None reserved_inventory = None
if len(result) > 0: if len(result) > 0:
reserved_inventory = result[0].inventory reserved_inventory = result[0].inventory
...@@ -71,22 +73,23 @@ class InventoryBrain(ZSQLBrain): ...@@ -71,22 +73,23 @@ class InventoryBrain(ZSQLBrain):
reserved_inventory = 0.0 reserved_inventory = 0.0
return current + reserved_inventory return current + reserved_inventory
def getAvailableInventory2(self): # ????
""" #def getAvailableInventory2(self):
Returns current inventory # """
""" # Returns current inventory
at_date=DateTime() # """
current = self.getCurrentInventory() # at_date=DateTime()
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], ignore_variation=1, # current = self.getCurrentInventory()
omit_simulation = 1, omit_input = 1, # result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], ignore_variation=1,
section_category = default_section_category, # omit_simulation = 1, omit_input = 1,
simulation_state = reserved_inventory_state_list2) # section_category = self.getPortalDefaultSectionCategory(),
reserved_inventory = None # simulation_state = reserved_inventory_state_list2)
if len(result) > 0: # reserved_inventory = None
reserved_inventory = result[0].inventory # if len(result) > 0:
if reserved_inventory is None: # reserved_inventory = result[0].inventory
reserved_inventory = 0.0 # if reserved_inventory is None:
return current + reserved_inventory # reserved_inventory = 0.0
# return current + reserved_inventory
def getQuantityUnit(self, **kw): def getQuantityUnit(self, **kw):
try: try:
...@@ -132,14 +135,17 @@ class InventoryListBrain(ZSQLBrain): ...@@ -132,14 +135,17 @@ class InventoryListBrain(ZSQLBrain):
""" """
Returns current inventory Returns current inventory
""" """
return self.getInventory(simulation_state=current_inventory_state_list, ignore_variation=0) return self.getInventory(simulation_state=self.getPortalCurrentInventoryStateList(), ignore_variation=0)
#return self.getInventory(at_date=DateTime(), ignore_variation=0) #return self.getInventory(at_date=DateTime(), ignore_variation=0)
def getFutureInventory(self): def getFutureInventory(self):
""" """
Returns current inventory Returns current inventory
""" """
return self.getInventory(ignore_variation=0, simulation_state=list(future_inventory_state_list)+list(reserved_inventory_state_list)+list(current_inventory_state_list)) return self.getInventory(ignore_variation=0,
simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()))
def getAvailableInventory(self): def getAvailableInventory(self):
""" """
...@@ -152,7 +158,7 @@ class InventoryListBrain(ZSQLBrain): ...@@ -152,7 +158,7 @@ class InventoryListBrain(ZSQLBrain):
section=self.section_relative_url, section=self.section_relative_url,
node=self.node_relative_url, node=self.node_relative_url,
variation_text = self.variation_text, variation_text = self.variation_text,
simulation_state = reserved_inventory_state_list) simulation_state = self.getPortalReservedInventoryStateList())
reserved_inventory = None reserved_inventory = None
if len(result) > 0: if len(result) > 0:
reserved_inventory = result[0].inventory reserved_inventory = result[0].inventory
...@@ -160,25 +166,26 @@ class InventoryListBrain(ZSQLBrain): ...@@ -160,25 +166,26 @@ class InventoryListBrain(ZSQLBrain):
reserved_inventory = 0.0 reserved_inventory = 0.0
return current + reserved_inventory return current + reserved_inventory
def getAvailableInventory2(self): # ????
""" #def getAvailableInventory2(self):
Returns current inventory # """
""" # Returns current inventory
at_date=DateTime() # """
current = self.getCurrentInventory() # at_date=DateTime()
# XXX - This code is not OK if we define section_category / node_category # current = self.getCurrentInventory()
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], # # XXX - This code is not OK if we define section_category / node_category
omit_simulation = 1, omit_input = 1, # result = self.Resource_zGetInventory( resource_uid = [self.resource_uid],
section=self.section_relative_url, # omit_simulation = 1, omit_input = 1,
node=self.node_relative_url, # section=self.section_relative_url,
variation_text = self.variation_text, # node=self.node_relative_url,
simulation_state = reserved_inventory_state_list2) # variation_text = self.variation_text,
reserved_inventory = None # simulation_state = reserved_inventory_state_list2)
if len(result) > 0: # reserved_inventory = None
reserved_inventory = result[0].inventory # if len(result) > 0:
if reserved_inventory is None: # reserved_inventory = result[0].inventory
reserved_inventory = 0.0 # if reserved_inventory is None:
return current + reserved_inventory # reserved_inventory = 0.0
# return current + reserved_inventory
def getQuantity(self, **kw): def getQuantity(self, **kw):
result = self.Delivery_zGetTotal( resource_uid = [self.resource_uid], result = self.Delivery_zGetTotal( resource_uid = [self.resource_uid],
...@@ -228,27 +235,27 @@ class InventoryListBrain(ZSQLBrain): ...@@ -228,27 +235,27 @@ class InventoryListBrain(ZSQLBrain):
resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url) resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url)
return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(), return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(),
make_query(variation_text=self.variation_text, selection_name=selection_name, selection_index=selection_index, make_query(variation_text=self.variation_text, selection_name=selection_name, selection_index=selection_index,
simulation_state=list(current_inventory_state_list))) simulation_state=list(self.getPortalCurrentInventoryStateList())))
elif cname_id in ('getAvailableInventory',): elif cname_id in ('getAvailableInventory',):
resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url) resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url)
return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(), return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(),
make_query(variation_text=self.variation_text, selection_name=selection_name, selection_index=selection_index,omit_simulation = 1, omit_input = 1, make_query(variation_text=self.variation_text, selection_name=selection_name, selection_index=selection_index,omit_simulation = 1, omit_input = 1,
simulation_state=list(reserved_inventory_state_list))) simulation_state=list(self.getPortalReservedInventoryStateList())))
elif cname_id in ('getAvailableInventory2',): #elif cname_id in ('getAvailableInventory2',):
resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url) # resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url)
return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(), # return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(),
make_query(variation_text=self.variation_text, selection_name=selection_name, selection_index=selection_index,omit_simulation = 1, omit_input = 1, # make_query(variation_text=self.variation_text, selection_name=selection_name, selection_index=selection_index,omit_simulation = 1, omit_input = 1,
simulation_state=list(reserved_inventory_state_list2))) # simulation_state=list(reserved_inventory_state_list2)))
elif cname_id in ('getFutureInventory','inventory', ): elif cname_id in ('getFutureInventory','inventory', ):
resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url) resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url)
return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(), return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(),
make_query(variation_text=self.variation_text, make_query(variation_text=self.variation_text,
selection_name=selection_name, selection_index=selection_index, simulation_state=list(future_inventory_state_list)+list(reserved_inventory_state_list))) selection_name=selection_name, selection_index=selection_index, simulation_state=list(self.getPortalFutureInventoryStateList())+list(self.getPortalReservedInventoryStateList())))
elif cname_id in ('getInventoryAtDate',): elif cname_id in ('getInventoryAtDate',):
resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url) resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url)
return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(), return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(),
make_query(variation_text=self.variation_text, to_date=self.at_date, make_query(variation_text=self.variation_text, to_date=self.at_date,
selection_name=selection_name, selection_index=selection_index, simulation_state=list(future_inventory_state_list)+list(reserved_inventory_state_list))) selection_name=selection_name, selection_index=selection_index, simulation_state=list(self.getPortalFutureInventoryStateList())+list(self.getPortalReservedInventoryStateList())))
else: else:
resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url) resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url)
return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(), return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(),
...@@ -326,7 +333,7 @@ class DeliveryListBrain(InventoryListBrain): ...@@ -326,7 +333,7 @@ class DeliveryListBrain(InventoryListBrain):
where_expression = None where_expression = None
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], result = self.Resource_zGetInventory( resource_uid = [self.resource_uid],
to_date=at_date, to_date=at_date,
section_category = default_section_category, section_category = self.getPortalDefaultSectionCategory(),
variation_text = self.variation_text, variation_text = self.variation_text,
simulation_state = simulation_state, simulation_state = simulation_state,
where_expression = where_expression) where_expression = where_expression)
...@@ -346,39 +353,40 @@ class DeliveryListBrain(InventoryListBrain): ...@@ -346,39 +353,40 @@ class DeliveryListBrain(InventoryListBrain):
current = self.getCurrentInventory() current = self.getCurrentInventory()
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], result = self.Resource_zGetInventory( resource_uid = [self.resource_uid],
omit_simulation = 1, omit_input = 1, omit_simulation = 1, omit_input = 1,
section_category = default_section_category, section_category = self.getPortalDefaultSectionCategory(),
variation_text = self.variation_text, variation_text = self.variation_text,
simulation_state = reserved_inventory_state_list ) simulation_state = self.getPortalReservedInventoryStateList())
reserved_inventory = None reserved_inventory = None
if len(result) > 0: if len(result) > 0:
reserved_inventory = result[0].inventory reserved_inventory = result[0].inventory
if reserved_inventory is None: if reserved_inventory is None:
reserved_inventory = 0.0 reserved_inventory = 0.0
return current + reserved_inventory return current + reserved_inventory
# ????
#def getAvailableInventory2(self):
# """
# Returns current inventory at current date
# """
# at_date=DateTime()
# current = self.getCurrentInventory()
# result = self.Resource_zGetInventory( resource_uid = [self.resource_uid],
# omit_simulation = 1, omit_input = 1,
# section_category = self.getPortalDefaultSectionCategory(),
# variation_text = self.variation_text,
# simulation_state = reserved_inventory_state_list2)
# reserved_inventory = None
# if len(result) > 0:
# reserved_inventory = result[0].inventory
# if reserved_inventory is None:
# reserved_inventory = 0.0
# return current + reserved_inventory
def getAvailableInventory2(self):
"""
Returns current inventory at current date
"""
at_date=DateTime()
current = self.getCurrentInventory()
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid],
omit_simulation = 1, omit_input = 1,
section_category = default_section_category,
variation_text = self.variation_text,
simulation_state = reserved_inventory_state_list2)
reserved_inventory = None
if len(result) > 0:
reserved_inventory = result[0].inventory
if reserved_inventory is None:
reserved_inventory = 0.0
return current + reserved_inventory
def getInventoryAtDate(self): def getInventoryAtDate(self):
""" """
Returns inventory at the date provided by the SQL method Returns inventory at the date provided by the SQL method
""" """
at_date=self.at_date at_date=self.at_date
LOG("At Date",0,str(at_date)) LOG("At Date",0,str(at_date))
return self.getInventory(at_date=at_date, ignore_variation=0, simulation_state=list(future_inventory_state_list)+list(reserved_inventory_state_list)+list(current_inventory_state_list)) return self.getInventory(at_date=at_date, ignore_variation=0, simulation_state=list(self.getPortalFutureInventoryStateList())+list(self.getPortalReservedInventoryStateList())+list(self.getPortalCurrentInventoryStateList()))
...@@ -36,7 +36,6 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface ...@@ -36,7 +36,6 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass, DTMLFile from Globals import InitializeClass, DTMLFile
from Products.CMFCategory.Category import Category from Products.CMFCategory.Category import Category
from Products.ERP5.ERP5Globals import order_type_list, delivery_type_list
from zLOG import LOG from zLOG import LOG
manage_addRootMovementGroupForm=DTMLFile('dtml/SimulationTool_addRootMovementGroup', globals()) manage_addRootMovementGroupForm=DTMLFile('dtml/SimulationTool_addRootMovementGroup', globals())
...@@ -82,7 +81,7 @@ class RootMovementGroup(Folder): ...@@ -82,7 +81,7 @@ class RootMovementGroup(Folder):
""" """
This sets an appropriate nested class. This sets an appropriate nested class.
""" """
LOG('RootGroup.setNestedClass, check_list:',0,check_list) LOG('RootGroup.setNestedClass, check_list:',0,check_list)
for i in range(len(check_list)): for i in range(len(check_list)):
LOG('RootGroup.setNestedClass, check_list[i]:',0,check_list[i]) LOG('RootGroup.setNestedClass, check_list[i]:',0,check_list[i])
...@@ -164,12 +163,12 @@ class OrderMovementGroup(RootMovementGroup,Folder): ...@@ -164,12 +163,12 @@ class OrderMovementGroup(RootMovementGroup,Folder):
if hasattr(movement, 'getRootAppliedRule'): if hasattr(movement, 'getRootAppliedRule'):
# This is a simulation movement # This is a simulation movement
order_value = movement.getRootAppliedRule().getCausalityValue( order_value = movement.getRootAppliedRule().getCausalityValue(
portal_type=order_type_list) portal_type=movement.getPortalOrderTypeList())
if order_value is None: if order_value is None:
# In some cases (ex. DeliveryRule), there is no order # In some cases (ex. DeliveryRule), there is no order
# we may consider a PackingList as the order in the OrderGroup # we may consider a PackingList as the order in the OrderGroup
order_value = movement.getRootAppliedRule().getCausalityValue( order_value = movement.getRootAppliedRule().getCausalityValue(
portal_type=delivery_type_list) portal_type=movement.getPortalDeliveryTypeList())
else: else:
# This is a temp movement # This is a temp movement
order_value = None order_value = None
...@@ -184,13 +183,13 @@ class OrderMovementGroup(RootMovementGroup,Folder): ...@@ -184,13 +183,13 @@ class OrderMovementGroup(RootMovementGroup,Folder):
def test(self,movement): def test(self,movement):
if hasattr(movement, 'getRootAppliedRule'): if hasattr(movement, 'getRootAppliedRule'):
order_value = movement.getRootAppliedRule().getCausalityValue( order_value = movement.getRootAppliedRule().getCausalityValue(
portal_type=order_type_list) portal_type=movement.getPortalOrderTypeList())
if order_value is None: if order_value is None:
# In some cases (ex. DeliveryRule), there is no order # In some cases (ex. DeliveryRule), there is no order
# we may consider a PackingList as the order in the OrderGroup # we may consider a PackingList as the order in the OrderGroup
order_value = movement.getRootAppliedRule().getCausalityValue( order_value = movement.getRootAppliedRule().getCausalityValue(
portal_type=delivery_type_list) portal_type=movement.getPortalDeliveryTypeList())
else: else:
# This is a temp movement # This is a temp movement
order_value = None order_value = None
......
...@@ -26,27 +26,27 @@ ...@@ -26,27 +26,27 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import * from Products.CMFCore.Expression import Expression
class Amortisation: class Amortisation:
""" """
Properties which allow to immobilise an item Properties which allow to immobilise an item
These properties are applied to an Immobilisation Movement or to an Item These properties are applied to an Immobilisation Movement or to an Item
TODO: TODO:
- rename categories for more genericity (input_acount -> input) - rename categories for more genericity (input_acount -> input)
- rename vat property - rename vat property
""" """
_properties = ( _properties = (
{ 'id' : 'amortisation_beginning_price', { 'id' : 'amortisation_beginning_price',
'description' : 'The value to use to calculate the accounting amortisation movements (net of tax)', 'description' : 'The value to use to calculate the accounting amortisation movements (net of tax)',
'type' : 'float', 'type' : 'float',
'acquisition_base_category' : ('parent',), 'acquisition_base_category' : ('parent',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getAmortisationBeginningPrice', 'acquisition_accessor_id' : 'getAmortisationBeginningPrice',
...@@ -56,7 +56,7 @@ class Amortisation: ...@@ -56,7 +56,7 @@ class Amortisation:
'description' : 'The remaining amortisation duration in months', 'description' : 'The remaining amortisation duration in months',
'type' : 'int', 'type' : 'int',
'acquisition_base_category' : ('parent',), 'acquisition_base_category' : ('parent',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getAmortisationDuration', 'acquisition_accessor_id' : 'getAmortisationDuration',
...@@ -66,7 +66,7 @@ class Amortisation: ...@@ -66,7 +66,7 @@ class Amortisation:
'description' : 'The item is immobilised after the movement', 'description' : 'The item is immobilised after the movement',
'type' : 'boolean', 'type' : 'boolean',
'acquisition_base_category' : ('parent',), 'acquisition_base_category' : ('parent',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getImmobilisation', 'acquisition_accessor_id' : 'getImmobilisation',
...@@ -76,7 +76,7 @@ class Amortisation: ...@@ -76,7 +76,7 @@ class Amortisation:
'description' : 'The fiscal coefficient to use in degressive amortisation', 'description' : 'The fiscal coefficient to use in degressive amortisation',
'type' : 'float', 'type' : 'float',
'acquisition_base_category' : ('parent',), 'acquisition_base_category' : ('parent',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getFiscalCoefficient', 'acquisition_accessor_id' : 'getFiscalCoefficient',
...@@ -86,15 +86,15 @@ class Amortisation: ...@@ -86,15 +86,15 @@ class Amortisation:
'description' : 'The VAT at the beginning of the immobilisation period', 'description' : 'The VAT at the beginning of the immobilisation period',
'type' : 'float', 'type' : 'float',
'acquisition_base_category' : ('parent',), 'acquisition_base_category' : ('parent',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getVat', 'acquisition_accessor_id' : 'getVat',
'acquisition_depends' : None, 'acquisition_depends' : None,
'mode' : 'w' }, 'mode' : 'w' },
) )
_categories = ('input_account', 'output_account', 'immobilisation_account', _categories = ('input_account', 'output_account', 'immobilisation_account',
'amortisation_account', 'depreciation_account', 'amortisation_account', 'depreciation_account',
'vat_account', 'amortisation_type') # XXX Some rename required 'vat_account', 'amortisation_type') # XXX Some rename required
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
############################################################################## ##############################################################################
# This has to be chanegd and improved by the new category acquisition tool # This has to be chanegd and improved by the new category acquisition tool
from Products.ERP5.ERP5Globals import * from Products.CMFCore.Expression import Expression
class Amount: class Amount:
""" """
...@@ -48,7 +48,7 @@ class Amount: ...@@ -48,7 +48,7 @@ class Amount:
'description' : "The resource id involved", 'description' : "The resource id involved",
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('resource',), 'acquisition_base_category' : ('resource',),
'acquisition_portal_type' : resource_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalResourceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
...@@ -60,7 +60,7 @@ class Amount: ...@@ -60,7 +60,7 @@ class Amount:
'description' : "The resource relative url involved", 'description' : "The resource relative url involved",
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('resource',), 'acquisition_base_category' : ('resource',),
'acquisition_portal_type' : resource_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalResourceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
...@@ -71,7 +71,7 @@ class Amount: ...@@ -71,7 +71,7 @@ class Amount:
'description' : "The resource title involved", 'description' : "The resource title involved",
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('resource',), 'acquisition_base_category' : ('resource',),
'acquisition_portal_type' : resource_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalResourceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
...@@ -85,7 +85,7 @@ class Amount: ...@@ -85,7 +85,7 @@ class Amount:
'type' : 'float', 'type' : 'float',
'default' : 0.0, 'default' : 0.0,
'acquisition_base_category' : ('delivery',), 'acquisition_base_category' : ('delivery',),
'acquisition_portal_type' : movement_or_delivery_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalAcquisitionMovementTypeList() + portal.getPortalDeliveryTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getQuantity', 'acquisition_accessor_id' : 'getQuantity',
...@@ -97,7 +97,7 @@ class Amount: ...@@ -97,7 +97,7 @@ class Amount:
'type' : 'float', 'type' : 'float',
'default' : 1.0, 'default' : 1.0,
'acquisition_base_category' : ('delivery',), 'acquisition_base_category' : ('delivery',),
'acquisition_portal_type' : movement_or_delivery_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalAcquisitionMovementTypeList() + portal.getPortalDeliveryTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getEfficiency', 'acquisition_accessor_id' : 'getEfficiency',
...@@ -110,7 +110,7 @@ class Amount: ...@@ -110,7 +110,7 @@ class Amount:
'type' : 'float', 'type' : 'float',
'default' : 0.0, 'default' : 0.0,
'acquisition_base_category' : ('order',), 'acquisition_base_category' : ('order',),
'acquisition_portal_type' : movement_or_order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalAcquisitionMovementTypeList() + portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getTargetQuantity', 'acquisition_accessor_id' : 'getTargetQuantity',
...@@ -121,7 +121,7 @@ class Amount: ...@@ -121,7 +121,7 @@ class Amount:
'type' : 'float', 'type' : 'float',
'default' : 1.0, 'default' : 1.0,
'acquisition_base_category' : ('order',), 'acquisition_base_category' : ('order',),
'acquisition_portal_type' : movement_or_order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalAcquisitionMovementTypeList() + portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getTargetEfficiency', 'acquisition_accessor_id' : 'getTargetEfficiency',
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import * from Products.CMFCore.Expression import Expression
class Arrow: class Arrow:
""" """
...@@ -42,7 +42,7 @@ class Arrow: ...@@ -42,7 +42,7 @@ class Arrow:
'description' : 'The title of the source of this movement', 'description' : 'The title of the source of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source',), 'acquisition_base_category' : ('source',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -52,7 +52,7 @@ class Arrow: ...@@ -52,7 +52,7 @@ class Arrow:
'description' : 'The id of the destination of this movement', 'description' : 'The id of the destination of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source',), 'acquisition_base_category' : ('source',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -62,7 +62,7 @@ class Arrow: ...@@ -62,7 +62,7 @@ class Arrow:
'description' : 'The titles of the destination of this movement', 'description' : 'The titles of the destination of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source',), 'acquisition_base_category' : ('source',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -91,7 +91,7 @@ class Arrow: ...@@ -91,7 +91,7 @@ class Arrow:
'description' : 'The title of the destination of this movement', 'description' : 'The title of the destination of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination',), 'acquisition_base_category' : ('destination',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -101,7 +101,7 @@ class Arrow: ...@@ -101,7 +101,7 @@ class Arrow:
'description' : 'The id of the destination of this movement', 'description' : 'The id of the destination of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination',), 'acquisition_base_category' : ('destination',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -111,7 +111,7 @@ class Arrow: ...@@ -111,7 +111,7 @@ class Arrow:
'description' : 'The titles of the destination of this movement', 'description' : 'The titles of the destination of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination',), 'acquisition_base_category' : ('destination',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -140,7 +140,7 @@ class Arrow: ...@@ -140,7 +140,7 @@ class Arrow:
'description' : 'The title of the target source of this movement', 'description' : 'The title of the target source of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_source',), 'acquisition_base_category' : ('target_source',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -150,7 +150,7 @@ class Arrow: ...@@ -150,7 +150,7 @@ class Arrow:
'description' : 'The id of the target source of this movement', 'description' : 'The id of the target source of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_source',), 'acquisition_base_category' : ('target_source',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -160,7 +160,7 @@ class Arrow: ...@@ -160,7 +160,7 @@ class Arrow:
'description' : 'The relative url of the target destination of this movement', 'description' : 'The relative url of the target destination of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_source',), 'acquisition_base_category' : ('target_source',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -191,7 +191,7 @@ class Arrow: ...@@ -191,7 +191,7 @@ class Arrow:
'description' : 'The title of the target destination of this movement', 'description' : 'The title of the target destination of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_destination',), 'acquisition_base_category' : ('target_destination',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -201,7 +201,7 @@ class Arrow: ...@@ -201,7 +201,7 @@ class Arrow:
'description' : 'The id of the target destination of this movement', 'description' : 'The id of the target destination of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_destination',), 'acquisition_base_category' : ('target_destination',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -211,7 +211,7 @@ class Arrow: ...@@ -211,7 +211,7 @@ class Arrow:
'description' : 'The relative url of the target destination of this movement', 'description' : 'The relative url of the target destination of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_destination',), 'acquisition_base_category' : ('target_destination',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -242,7 +242,7 @@ class Arrow: ...@@ -242,7 +242,7 @@ class Arrow:
'description' : 'The title of the source decision of this movement', 'description' : 'The title of the source decision of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_decision',), 'acquisition_base_category' : ('source_decision',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -252,7 +252,7 @@ class Arrow: ...@@ -252,7 +252,7 @@ class Arrow:
'description' : 'The id of the source decision of this movement', 'description' : 'The id of the source decision of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_decision',), 'acquisition_base_category' : ('source_decision',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -262,7 +262,7 @@ class Arrow: ...@@ -262,7 +262,7 @@ class Arrow:
'description' : 'The titles of the source decision of this movement', 'description' : 'The titles of the source decision of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_decision',), 'acquisition_base_category' : ('source_decision',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -273,7 +273,7 @@ class Arrow: ...@@ -273,7 +273,7 @@ class Arrow:
'description' : 'The title of the destination decision of this movement', 'description' : 'The title of the destination decision of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_decision',), 'acquisition_base_category' : ('destination_decision',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -283,7 +283,7 @@ class Arrow: ...@@ -283,7 +283,7 @@ class Arrow:
'description' : 'The id of the destination decision of this movement', 'description' : 'The id of the destination decision of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_decision',), 'acquisition_base_category' : ('destination_decision',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -293,7 +293,7 @@ class Arrow: ...@@ -293,7 +293,7 @@ class Arrow:
'description' : 'The titles of the destination decision of this movement', 'description' : 'The titles of the destination decision of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_decision',), 'acquisition_base_category' : ('destination_decision',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -304,7 +304,7 @@ class Arrow: ...@@ -304,7 +304,7 @@ class Arrow:
'description' : 'The title of the source section of this movement', 'description' : 'The title of the source section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_section',), 'acquisition_base_category' : ('source_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -314,7 +314,7 @@ class Arrow: ...@@ -314,7 +314,7 @@ class Arrow:
'description' : 'The id of the source section of this movement', 'description' : 'The id of the source section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_section',), 'acquisition_base_category' : ('source_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -324,7 +324,7 @@ class Arrow: ...@@ -324,7 +324,7 @@ class Arrow:
'description' : 'The titles of the source section of this movement', 'description' : 'The titles of the source section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_section',), 'acquisition_base_category' : ('source_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -335,7 +335,7 @@ class Arrow: ...@@ -335,7 +335,7 @@ class Arrow:
'description' : 'The title of the destination section of this movement', 'description' : 'The title of the destination section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_section',), 'acquisition_base_category' : ('destination_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -345,7 +345,7 @@ class Arrow: ...@@ -345,7 +345,7 @@ class Arrow:
'description' : 'The id of the destination section of this movement', 'description' : 'The id of the destination section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_section',), 'acquisition_base_category' : ('destination_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -355,7 +355,7 @@ class Arrow: ...@@ -355,7 +355,7 @@ class Arrow:
'description' : 'The titles of the destination section of this movement', 'description' : 'The titles of the destination section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_section',), 'acquisition_base_category' : ('destination_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -366,7 +366,7 @@ class Arrow: ...@@ -366,7 +366,7 @@ class Arrow:
'description' : 'The title of the target source section of this movement', 'description' : 'The title of the target source section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_source_section',), 'acquisition_base_category' : ('target_source_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -376,7 +376,7 @@ class Arrow: ...@@ -376,7 +376,7 @@ class Arrow:
'description' : 'The id of the target source section of this movement', 'description' : 'The id of the target source section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_source_section',), 'acquisition_base_category' : ('target_source_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -386,7 +386,7 @@ class Arrow: ...@@ -386,7 +386,7 @@ class Arrow:
'description' : 'The relative url of the target source section of this movement', 'description' : 'The relative url of the target source section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_source_section',), 'acquisition_base_category' : ('target_source_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -397,7 +397,7 @@ class Arrow: ...@@ -397,7 +397,7 @@ class Arrow:
'description' : 'The title of the target destination section of this movement', 'description' : 'The title of the target destination section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_destination_section',), 'acquisition_base_category' : ('target_destination_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -407,7 +407,7 @@ class Arrow: ...@@ -407,7 +407,7 @@ class Arrow:
'description' : 'The id of the target destination section of this movement', 'description' : 'The id of the target destination section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_destination_section',), 'acquisition_base_category' : ('target_destination_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -417,7 +417,7 @@ class Arrow: ...@@ -417,7 +417,7 @@ class Arrow:
'description' : 'The relative url of the target destination section of this movement', 'description' : 'The relative url of the target destination section of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('target_destination_section',), 'acquisition_base_category' : ('target_destination_section',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -428,7 +428,7 @@ class Arrow: ...@@ -428,7 +428,7 @@ class Arrow:
'description' : 'The title of the source administration of this movement', 'description' : 'The title of the source administration of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_administration',), 'acquisition_base_category' : ('source_administration',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -438,7 +438,7 @@ class Arrow: ...@@ -438,7 +438,7 @@ class Arrow:
'description' : 'The id of the source administration of this movement', 'description' : 'The id of the source administration of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_administration',), 'acquisition_base_category' : ('source_administration',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -448,7 +448,7 @@ class Arrow: ...@@ -448,7 +448,7 @@ class Arrow:
'description' : 'The titles of the source administration of this movement', 'description' : 'The titles of the source administration of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_administration',), 'acquisition_base_category' : ('source_administration',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -459,7 +459,7 @@ class Arrow: ...@@ -459,7 +459,7 @@ class Arrow:
'description' : 'The title of the destination administration of this movement', 'description' : 'The title of the destination administration of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_administration',), 'acquisition_base_category' : ('destination_administration',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -469,7 +469,7 @@ class Arrow: ...@@ -469,7 +469,7 @@ class Arrow:
'description' : 'The id of the destination administration of this movement', 'description' : 'The id of the destination administration of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_administration',), 'acquisition_base_category' : ('destination_administration',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -479,7 +479,7 @@ class Arrow: ...@@ -479,7 +479,7 @@ class Arrow:
'description' : 'The titles of the destination administration of this movement', 'description' : 'The titles of the destination administration of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_administration',), 'acquisition_base_category' : ('destination_administration',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'alt_accessor_id' : ('_categoryGetDestinationAdministrationRelativeUrl', ), 'alt_accessor_id' : ('_categoryGetDestinationAdministrationRelativeUrl', ),
...@@ -490,7 +490,7 @@ class Arrow: ...@@ -490,7 +490,7 @@ class Arrow:
'description' : 'The title of the source payment of this movement', 'description' : 'The title of the source payment of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_payment',), 'acquisition_base_category' : ('source_payment',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -500,7 +500,7 @@ class Arrow: ...@@ -500,7 +500,7 @@ class Arrow:
'description' : 'The id of the source payment of this movement', 'description' : 'The id of the source payment of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_payment',), 'acquisition_base_category' : ('source_payment',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -510,7 +510,7 @@ class Arrow: ...@@ -510,7 +510,7 @@ class Arrow:
'description' : 'The titles of the source payment of this movement', 'description' : 'The titles of the source payment of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_payment',), 'acquisition_base_category' : ('source_payment',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -521,7 +521,7 @@ class Arrow: ...@@ -521,7 +521,7 @@ class Arrow:
'description' : 'The title of the destination payment of this movement', 'description' : 'The title of the destination payment of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_payment',), 'acquisition_base_category' : ('destination_payment',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -531,7 +531,7 @@ class Arrow: ...@@ -531,7 +531,7 @@ class Arrow:
'description' : 'The id of the destination payment of this movement', 'description' : 'The id of the destination payment of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_payment',), 'acquisition_base_category' : ('destination_payment',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -541,7 +541,7 @@ class Arrow: ...@@ -541,7 +541,7 @@ class Arrow:
'description' : 'The titles of the destination payment of this movement', 'description' : 'The titles of the destination payment of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_payment',), 'acquisition_base_category' : ('destination_payment',),
'acquisition_portal_type' : node_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalNodeTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -589,7 +589,7 @@ class Arrow: ...@@ -589,7 +589,7 @@ class Arrow:
'description' : 'The title of the source project of this movement', 'description' : 'The title of the source project of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_project',), 'acquisition_base_category' : ('source_project',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -599,7 +599,7 @@ class Arrow: ...@@ -599,7 +599,7 @@ class Arrow:
'description' : 'The id of the source project of this movement', 'description' : 'The id of the source project of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_project',), 'acquisition_base_category' : ('source_project',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -609,7 +609,7 @@ class Arrow: ...@@ -609,7 +609,7 @@ class Arrow:
'description' : 'The titles of the source project of this movement', 'description' : 'The titles of the source project of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_project',), 'acquisition_base_category' : ('source_project',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -620,7 +620,7 @@ class Arrow: ...@@ -620,7 +620,7 @@ class Arrow:
'description' : 'The title of the destination project of this movement', 'description' : 'The title of the destination project of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_project',), 'acquisition_base_category' : ('destination_project',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -630,7 +630,7 @@ class Arrow: ...@@ -630,7 +630,7 @@ class Arrow:
'description' : 'The id of the destination project of this movement', 'description' : 'The id of the destination project of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_project',), 'acquisition_base_category' : ('destination_project',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -640,7 +640,7 @@ class Arrow: ...@@ -640,7 +640,7 @@ class Arrow:
'description' : 'The titles of the destination project of this movement', 'description' : 'The titles of the destination project of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_project',), 'acquisition_base_category' : ('destination_project',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -651,7 +651,7 @@ class Arrow: ...@@ -651,7 +651,7 @@ class Arrow:
'description' : 'The title of the source budget of this movement', 'description' : 'The title of the source budget of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_budget',), 'acquisition_base_category' : ('source_budget',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -661,7 +661,7 @@ class Arrow: ...@@ -661,7 +661,7 @@ class Arrow:
'description' : 'The id of the source budget of this movement', 'description' : 'The id of the source budget of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_budget',), 'acquisition_base_category' : ('source_budget',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -671,7 +671,7 @@ class Arrow: ...@@ -671,7 +671,7 @@ class Arrow:
'description' : 'The titles of the source budget of this movement', 'description' : 'The titles of the source budget of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('source_budget',), 'acquisition_base_category' : ('source_budget',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -682,7 +682,7 @@ class Arrow: ...@@ -682,7 +682,7 @@ class Arrow:
'description' : 'The title of the destination budget of this movement', 'description' : 'The title of the destination budget of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_budget',), 'acquisition_base_category' : ('destination_budget',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -692,7 +692,7 @@ class Arrow: ...@@ -692,7 +692,7 @@ class Arrow:
'description' : 'The id of the destination budget of this movement', 'description' : 'The id of the destination budget of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_budget',), 'acquisition_base_category' : ('destination_budget',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -702,7 +702,7 @@ class Arrow: ...@@ -702,7 +702,7 @@ class Arrow:
'description' : 'The titles of the destination budget of this movement', 'description' : 'The titles of the destination budget of this movement',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('destination_budget',), 'acquisition_base_category' : ('destination_budget',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import *
from Products.ERP5.PropertySheet.Path import Path from Products.ERP5.PropertySheet.Path import Path
class Assignment(Path): class Assignment(Path):
...@@ -38,7 +37,7 @@ class Assignment(Path): ...@@ -38,7 +37,7 @@ class Assignment(Path):
{ 'id' : 'salary_coefficient', { 'id' : 'salary_coefficient',
'description' : 'A coefficient related to the salary classification of the person.', 'description' : 'A coefficient related to the salary classification of the person.',
'type' : 'int', 'type' : 'int',
'mode' : 'w' }, 'mode' : 'w' },
{ 'id' : 'salary_level', { 'id' : 'salary_level',
'description' : 'A level to classify the salary of the person.', 'description' : 'A level to classify the salary of the person.',
'type' : 'int', 'type' : 'int',
...@@ -46,7 +45,7 @@ class Assignment(Path): ...@@ -46,7 +45,7 @@ class Assignment(Path):
{ 'id' : 'collective_agreement_title', { 'id' : 'collective_agreement_title',
'description' : 'A title that identify the collective agreement of this person in the case of employee/employer relation.', 'description' : 'A title that identify the collective agreement of this person in the case of employee/employer relation.',
'type' : 'string', 'type' : 'string',
'mode' : 'w' }, 'mode' : 'w' },
{ 'id' : 'subordination_title', { 'id' : 'subordination_title',
'description' : 'The title of the organisation this person is subordinated to', 'description' : 'The title of the organisation this person is subordinated to',
'type' : 'string', 'type' : 'string',
...@@ -68,7 +67,7 @@ class Assignment(Path): ...@@ -68,7 +67,7 @@ class Assignment(Path):
'acquisition_accessor_id' : 'getDefaultAddressValue', 'acquisition_accessor_id' : 'getDefaultAddressValue',
'acquisition_depends' : None, 'acquisition_depends' : None,
'mode' : 'r' }, 'mode' : 'r' },
) )
_categories = ('activity', 'function', 'grade', 'role', 'skill', 'destination', 'group', 'product_line', 'subordination', 'region', ) _categories = ('activity', 'function', 'grade', 'role', 'skill', 'destination', 'group', 'product_line', 'subordination', 'region', )
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import *
class Container: class Container:
""" """
Properties of container Properties of container
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import order_type_list, order_or_delivery_type_list from Products.CMFCore.Expression import Expression
class Delivery: class Delivery:
""" """
...@@ -41,7 +41,7 @@ class Delivery: ...@@ -41,7 +41,7 @@ class Delivery:
'type' : 'lines', 'type' : 'lines',
'override' : 1, 'override' : 1,
'acquisition_base_category' : ('causality',), 'acquisition_base_category' : ('causality',),
'acquisition_portal_type' : order_or_delivery_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList() + portal.getPortalDeliveryTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
...@@ -52,7 +52,7 @@ class Delivery: ...@@ -52,7 +52,7 @@ class Delivery:
'type' : 'lines', 'type' : 'lines',
'override' : 1, 'override' : 1,
'acquisition_base_category' : ('causality',), 'acquisition_base_category' : ('causality',),
'acquisition_portal_type' : order_or_delivery_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList() + portal.getPortalDeliveryTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
############################################################################## ##############################################################################
# This has to be chanegd and improved by the new category acquisition tool # This has to be chanegd and improved by the new category acquisition tool
from Products.ERP5.ERP5Globals import * from Products.CMFCore.Expression import Expression
class Inventory: class Inventory:
""" """
...@@ -35,7 +35,7 @@ class Inventory: ...@@ -35,7 +35,7 @@ class Inventory:
No default value is set in order to allow No default value is set in order to allow
None inventory values in movements None inventory values in movements
""" """
_properties = ( _properties = (
...@@ -45,7 +45,7 @@ class Inventory: ...@@ -45,7 +45,7 @@ class Inventory:
'description' : """The quantity of items in stock after inventory.""", 'description' : """The quantity of items in stock after inventory.""",
'type' : 'float', 'type' : 'float',
'acquisition_base_category' : ('delivery',), 'acquisition_base_category' : ('delivery',),
'acquisition_portal_type' : movement_or_delivery_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalMovementTypeList() + portal.getPortalDeliveryTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getInventory', 'acquisition_accessor_id' : 'getInventory',
......
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import * from Products.CMFCore.Expression import Expression
class Item: class Item:
""" """
...@@ -45,5 +46,5 @@ class Item: ...@@ -45,5 +46,5 @@ class Item:
'mode' : 'w' }, 'mode' : 'w' },
) )
_categories = tuple(['package_type'] + list(variation_base_category_list)) _categories = ('package_type', Expression('python: portal.getPortalVariationBaseCategoryList()'))
# XXX Please check if it is meaningful to add order cat to all items ? # XXX Please check if it is meaningful to add order cat to all items ?
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import * from Products.CMFCore.Expression import Expression
class ItemAggregation: class ItemAggregation:
...@@ -39,7 +39,7 @@ class ItemAggregation: ...@@ -39,7 +39,7 @@ class ItemAggregation:
'description' : 'list of ids of items', 'description' : 'list of ids of items',
'type' : 'lines', 'type' : 'lines',
'acquisition_base_category' : ('aggregate',), 'acquisition_base_category' : ('aggregate',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -48,7 +48,7 @@ class ItemAggregation: ...@@ -48,7 +48,7 @@ class ItemAggregation:
'description' : 'list of titles of items', 'description' : 'list of titles of items',
'type' : 'lines', 'type' : 'lines',
'acquisition_base_category' : ('aggregate',), 'acquisition_base_category' : ('aggregate',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -57,7 +57,7 @@ class ItemAggregation: ...@@ -57,7 +57,7 @@ class ItemAggregation:
'description' : 'list of ids of produced items', 'description' : 'list of ids of produced items',
'type' : 'lines', 'type' : 'lines',
'acquisition_base_category' : ('aggregate',), 'acquisition_base_category' : ('aggregate',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -66,7 +66,7 @@ class ItemAggregation: ...@@ -66,7 +66,7 @@ class ItemAggregation:
'description' : 'list of ids of produced items', 'description' : 'list of ids of produced items',
'type' : 'lines', 'type' : 'lines',
'acquisition_base_category' : ('aggregate',), 'acquisition_base_category' : ('aggregate',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -75,7 +75,7 @@ class ItemAggregation: ...@@ -75,7 +75,7 @@ class ItemAggregation:
'description' : 'list of ids of consumed items', 'description' : 'list of ids of consumed items',
'type' : 'lines', 'type' : 'lines',
'acquisition_base_category' : ('aggregate',), 'acquisition_base_category' : ('aggregate',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -84,7 +84,7 @@ class ItemAggregation: ...@@ -84,7 +84,7 @@ class ItemAggregation:
'description' : 'list of ids of consumed items', 'description' : 'list of ids of consumed items',
'type' : 'lines', 'type' : 'lines',
'acquisition_base_category' : ('aggregate',), 'acquisition_base_category' : ('aggregate',),
'acquisition_portal_type' : item_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalItemTypeList()'),
'acquisition_copy_value' : 1, 'acquisition_copy_value' : 1,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import * from Products.CMFCore.Expression import Expression
class Movement: class Movement:
""" """
...@@ -48,7 +48,7 @@ class Movement: ...@@ -48,7 +48,7 @@ class Movement:
'description' : 'The title of the order which defines contractual conditions', 'description' : 'The title of the order which defines contractual conditions',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('order',), 'acquisition_base_category' : ('order',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getTitle', 'acquisition_accessor_id' : 'getTitle',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -58,7 +58,7 @@ class Movement: ...@@ -58,7 +58,7 @@ class Movement:
'description' : 'The id of the order which defines contractual conditions', 'description' : 'The id of the order which defines contractual conditions',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('order',), 'acquisition_base_category' : ('order',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getId', 'acquisition_accessor_id' : 'getId',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -68,7 +68,7 @@ class Movement: ...@@ -68,7 +68,7 @@ class Movement:
'description' : 'The relative_url of the order which defines contractual conditions', 'description' : 'The relative_url of the order which defines contractual conditions',
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('order',), 'acquisition_base_category' : ('order',),
'acquisition_portal_type' : order_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalOrderTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_accessor_id' : 'getRelativeUrl', 'acquisition_accessor_id' : 'getRelativeUrl',
'acquisition_depends' : None, 'acquisition_depends' : None,
...@@ -76,5 +76,5 @@ class Movement: ...@@ -76,5 +76,5 @@ class Movement:
'mode' : 'w' }, 'mode' : 'w' },
) )
_categories = tuple(['order'] + list(variation_base_category_list)) _categories = ('order', Expression('python: portal.getPortalVariationBaseCategoryList()'))
# XXX Please check if it is meaningful to add order cat to all movemements ? # XXX Please check if it is meaningful to add order cat to all movemements ?
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import * from Products.CMFCore.Expression import Expression
class Path: class Path:
""" """
...@@ -38,7 +38,7 @@ class Path: ...@@ -38,7 +38,7 @@ class Path:
'description' : "The resource id involved", 'description' : "The resource id involved",
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('resource',), 'acquisition_base_category' : ('resource',),
'acquisition_portal_type' : resource_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalResourceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
...@@ -49,7 +49,7 @@ class Path: ...@@ -49,7 +49,7 @@ class Path:
'description' : "The resource relative url involved", 'description' : "The resource relative url involved",
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('resource',), 'acquisition_base_category' : ('resource',),
'acquisition_portal_type' : resource_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalResourceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
...@@ -60,7 +60,7 @@ class Path: ...@@ -60,7 +60,7 @@ class Path:
'description' : "The resource title involved", 'description' : "The resource title involved",
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('resource',), 'acquisition_base_category' : ('resource',),
'acquisition_portal_type' : resource_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalResourceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import * from Products.CMFCore.Expression import Expression
class Price: class Price:
""" """
...@@ -39,7 +39,7 @@ class Price: ...@@ -39,7 +39,7 @@ class Price:
'description' : 'A typical per unit price', 'description' : 'A typical per unit price',
'type' : 'float', 'type' : 'float',
'acquisition_base_category' : ('order', 'delivery',), 'acquisition_base_category' : ('order', 'delivery',),
'acquisition_portal_type' : movement_or_delivery_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalMovementTypeList() + portal.getPortalDeliveryTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getPrice', 'acquisition_accessor_id' : 'getPrice',
...@@ -82,6 +82,6 @@ class Price: ...@@ -82,6 +82,6 @@ class Price:
'description' : 'A list of quantity values which define acceptable ranges', 'description' : 'A list of quantity values which define acceptable ranges',
'type' : 'float', 'type' : 'float',
'multivalued' : 1, 'multivalued' : 1,
'mode' : 'w' }, 'mode' : 'w' },
) )
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import * from Products.CMFCore.Expression import Expression
class Task: class Task:
""" """
...@@ -49,7 +49,7 @@ class Task: ...@@ -49,7 +49,7 @@ class Task:
'type' : 'date', 'type' : 'date',
'default' : None, 'default' : None,
'acquisition_base_category' : ('delivery', 'order', 'parent',), 'acquisition_base_category' : ('delivery', 'order', 'parent',),
'acquisition_portal_type' : movement_or_delivery_or_order_or_invoice_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalAcquisitionMovementTypeList() + portal.getPortalDeliveryTypeList() + portal.getPortalOrderTypeList() + portal.getPortalInvoiceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getStartDate', 'acquisition_accessor_id' : 'getStartDate',
...@@ -61,7 +61,7 @@ class Task: ...@@ -61,7 +61,7 @@ class Task:
'type' : 'date', 'type' : 'date',
'default' : None, 'default' : None,
'acquisition_base_category' : ('delivery', 'order', 'parent',), 'acquisition_base_category' : ('delivery', 'order', 'parent',),
'acquisition_portal_type' : movement_or_delivery_or_order_or_invoice_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalAcquisitionMovementTypeList() + portal.getPortalDeliveryTypeList() + portal.getPortalOrderTypeList() + portal.getPortalInvoiceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getStopDate', 'acquisition_accessor_id' : 'getStopDate',
...@@ -74,7 +74,7 @@ class Task: ...@@ -74,7 +74,7 @@ class Task:
'type' : 'date', 'type' : 'date',
'default' : None, 'default' : None,
'acquisition_base_category' : ('parent',), # Do not acquire through order 'acquisition_base_category' : ('parent',), # Do not acquire through order
'acquisition_portal_type' : movement_or_delivery_or_order_or_invoice_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalAcquisitionMovementTypeList() + portal.getPortalDeliveryTypeList() + portal.getPortalOrderTypeList() + portal.getPortalInvoiceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getTargetStartDate', 'acquisition_accessor_id' : 'getTargetStartDate',
...@@ -86,7 +86,7 @@ class Task: ...@@ -86,7 +86,7 @@ class Task:
'type' : 'date', 'type' : 'date',
'default' : None, 'default' : None,
'acquisition_base_category' : ('parent',), # Do not acquire through order 'acquisition_base_category' : ('parent',), # Do not acquire through order
'acquisition_portal_type' : movement_or_delivery_or_order_or_invoice_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalAcquisitionMovementTypeList() + portal.getPortalDeliveryTypeList() + portal.getPortalOrderTypeList() + portal.getPortalInvoiceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_accessor_id' : 'getTargetStopDate', 'acquisition_accessor_id' : 'getTargetStopDate',
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import resource_type_list from Products.CMFCore.Expression import Expression
class Transformation: class Transformation:
""" """
...@@ -71,7 +71,7 @@ class Transformation: ...@@ -71,7 +71,7 @@ class Transformation:
'description' : "The contact persons involved", 'description' : "The contact persons involved",
'type' : 'string', 'type' : 'string',
'acquisition_base_category' : ('resource',), 'acquisition_base_category' : ('resource',),
'acquisition_portal_type' : resource_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalResourceTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 0, 'acquisition_mask_value' : 0,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.ERP5Globals import invoice_or_invoice_movement_type_list from Products.CMFCore.Expression import Expression
class ValueAddedTax: class ValueAddedTax:
""" """
...@@ -40,7 +40,7 @@ class ValueAddedTax: ...@@ -40,7 +40,7 @@ class ValueAddedTax:
'description' : 'Ratio which should be applied to income to calculate VAT', 'description' : 'Ratio which should be applied to income to calculate VAT',
'type' : 'float', 'type' : 'float',
'acquisition_base_category' : ('parent',), 'acquisition_base_category' : ('parent',),
'acquisition_portal_type' : invoice_or_invoice_movement_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalInvoiceTypeList() + portal.getPortalInvoiceMovementTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
...@@ -51,7 +51,7 @@ class ValueAddedTax: ...@@ -51,7 +51,7 @@ class ValueAddedTax:
'description' : 'Defines recoverability of the VAT', 'description' : 'Defines recoverability of the VAT',
'type' : 'boolean', 'type' : 'boolean',
'acquisition_base_category' : ('parent',), 'acquisition_base_category' : ('parent',),
'acquisition_portal_type' : invoice_or_invoice_movement_type_list, 'acquisition_portal_type' : Expression('python: portal.getPortalInvoiceTypeList() + portal.getPortalInvoiceMovementTypeList()'),
'acquisition_copy_value' : 0, 'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1, 'acquisition_mask_value' : 1,
'acquisition_sync_value' : 0, 'acquisition_sync_value' : 0,
......
...@@ -32,7 +32,6 @@ from Products.ERP5Type.Document.Folder import Folder ...@@ -32,7 +32,6 @@ from Products.ERP5Type.Document.Folder import Folder
from Products.ERP5Type.Tool.BaseTool import BaseTool from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5 import _dtmldir from Products.ERP5 import _dtmldir
from Products.ERP5.ERP5Globals import alarm_type_list
from Products.CMFCore import CMFCorePermissions from Products.CMFCore import CMFCorePermissions
from DateTime import DateTime from DateTime import DateTime
...@@ -91,7 +90,7 @@ class AlarmTool(BaseTool): ...@@ -91,7 +90,7 @@ class AlarmTool(BaseTool):
""" """
We retrieve thanks to the catalog the full list of alarms We retrieve thanks to the catalog the full list of alarms
""" """
catalog_search = self.portal_catalog(portal_type = alarm_type_list) catalog_search = self.portal_catalog(portal_type = self.getPortalAlarmTypeList())
alarm_list = map(lambda x:x.getObject(),catalog_search) alarm_list = map(lambda x:x.getObject(),catalog_search)
return alarm_list return alarm_list
......
...@@ -32,7 +32,6 @@ from AccessControl import ClassSecurityInfo ...@@ -32,7 +32,6 @@ from AccessControl import ClassSecurityInfo
from Globals import InitializeClass, DTMLFile from Globals import InitializeClass, DTMLFile
from Products.ERP5Type.Document.Folder import Folder from Products.ERP5Type.Document.Folder import Folder
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5.ERP5Globals import default_section_category, order_type_list, delivery_type_list, current_inventory_state_list, discount_type_list, simulated_movement_type_list, container_type_list, payment_condition_type_list, invoice_movement_type_list
from Products.ERP5 import _dtmldir from Products.ERP5 import _dtmldir
...@@ -201,8 +200,10 @@ class SimulationTool (Folder, UniqueObject): ...@@ -201,8 +200,10 @@ class SimulationTool (Folder, UniqueObject):
# Stock Management # Stock Management
security.declareProtected(Permissions.AccessContentsInformation, 'getInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getInventory')
def getInventory(self, resource_uid=None, at_date = None, section = None, node = None, def getInventory(self, resource_uid=None, at_date = None, section = None, node = None,
node_category=None, section_category=default_section_category, simulation_state=None, node_category=None, section_category=None, simulation_state=None,
ignore_variation=0, **kw): ignore_variation=0, **kw):
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_zGetInventory(resource_uid = resource_uid, result = self.Resource_zGetInventory(resource_uid = resource_uid,
to_date=at_date, to_date=at_date,
section=section, node=node, section=section, node=node,
...@@ -241,7 +242,7 @@ class SimulationTool (Folder, UniqueObject): ...@@ -241,7 +242,7 @@ class SimulationTool (Folder, UniqueObject):
def collectMovement(self, movement_list,check_list=None,**kw): def collectMovement(self, movement_list,check_list=None,**kw):
""" """
group movements in the way we want. Thanks to this method, we are able to retrieve group movements in the way we want. Thanks to this method, we are able to retrieve
movement classed by order, resource, criterion,.... movement classed by order, resource, criterion,....
movement_list : the list of movement wich we want to group movement_list : the list of movement wich we want to group
...@@ -263,7 +264,7 @@ class SimulationTool (Folder, UniqueObject): ...@@ -263,7 +264,7 @@ class SimulationTool (Folder, UniqueObject):
my_root_group.append(movement,check_list=check_list) my_root_group.append(movement,check_list=check_list)
return my_root_group return my_root_group
def buildOrderList(self, movement_group): def buildOrderList(self, movement_group):
# Build orders from a list of movements (attached to orders) # Build orders from a list of movements (attached to orders)
order_list = [] order_list = []
...@@ -398,10 +399,10 @@ class SimulationTool (Folder, UniqueObject): ...@@ -398,10 +399,10 @@ class SimulationTool (Folder, UniqueObject):
return order_list return order_list
def buildDeliveryList(self, movement_group): def buildDeliveryList(self, movement_group):
# Build deliveries from a list of movements # Build deliveries from a list of movements
LOG('buildDeliveryList root_group',0,movement_group) LOG('buildDeliveryList root_group',0,movement_group)
...@@ -409,10 +410,10 @@ class SimulationTool (Folder, UniqueObject): ...@@ -409,10 +410,10 @@ class SimulationTool (Folder, UniqueObject):
for group in movement_group.group_list: for group in movement_group.group_list:
LOG('buildDeliveryList group.__dict__',0,group.__dict__) LOG('buildDeliveryList group.__dict__',0,group.__dict__)
LOG('buildDeliveryList nested_class.__dict__',0,movement_group.nested_class.__dict__) LOG('buildDeliveryList nested_class.__dict__',0,movement_group.nested_class.__dict__)
def orderGroupProcessing(order_group, delivery_list, reindexable_movement_list, **kw): def orderGroupProcessing(order_group, delivery_list, reindexable_movement_list, **kw):
# Order should never be None # Order should never be None
LOG("buildDeliveryList", 0, str(order_group.__dict__)) LOG("buildDeliveryList", 0, str(order_group.__dict__))
if order_group.order is not None: if order_group.order is not None:
...@@ -450,14 +451,14 @@ class SimulationTool (Folder, UniqueObject): ...@@ -450,14 +451,14 @@ class SimulationTool (Folder, UniqueObject):
order=order, order=order,
delivery_list=delivery_list, delivery_list=delivery_list,
reindexable_movement_list=reindexable_movement_list, **kw) reindexable_movement_list=reindexable_movement_list, **kw)
return 0 return 0
def pathGroupProcessing(path_group, delivery_module, delivery_type, delivery_line_type, delivery_cell_type, order, delivery_list, reindexable_movement_list, default_rule_id=None, **kw): def pathGroupProcessing(path_group, delivery_module, delivery_type, delivery_line_type, delivery_cell_type, order, delivery_list, reindexable_movement_list, default_rule_id=None, **kw):
# we create a new delivery for each DateGroup # we create a new delivery for each DateGroup
if default_rule_id is 'default_amortisation_rule': if default_rule_id is 'default_amortisation_rule':
pass pass
else: else:
...@@ -468,7 +469,7 @@ class SimulationTool (Folder, UniqueObject): ...@@ -468,7 +469,7 @@ class SimulationTool (Folder, UniqueObject):
LOG("Builder",0, "Strange Path %s " % path_group.target_source) LOG("Builder",0, "Strange Path %s " % path_group.target_source)
LOG("Builder",0, "Strange Path %s " % path_group.target_destination) LOG("Builder",0, "Strange Path %s " % path_group.target_destination)
LOG("Builder path_group in pathGroupProcessing",0, path_group.__dict__) LOG("Builder path_group in pathGroupProcessing",0, path_group.__dict__)
if path_group.target_source is None or path_group.target_destination is None: if path_group.target_source is None or path_group.target_destination is None:
delivery_module = self.rapport_fabrication delivery_module = self.rapport_fabrication
delivery_type = 'Production Report' delivery_type = 'Production Report'
...@@ -498,26 +499,26 @@ class SimulationTool (Folder, UniqueObject): ...@@ -498,26 +499,26 @@ class SimulationTool (Folder, UniqueObject):
delivery_list=delivery_list, delivery_list=delivery_list,
reindexable_movement_list=reindexable_movement_list, reindexable_movement_list=reindexable_movement_list,
default_rule_id=default_rule_id, **kw) default_rule_id=default_rule_id, **kw)
def dateGroupProcessing(date_group, path_group, delivery_module, delivery_type, delivery_line_type, delivery_cell_type, order, delivery_list, reindexable_movement_list, default_rule_id=None, resource=None, **kw): def dateGroupProcessing(date_group, path_group, delivery_module, delivery_type, delivery_line_type, delivery_cell_type, order, delivery_list, reindexable_movement_list, default_rule_id=None, resource=None, **kw):
if default_rule_id == 'default_amortisation_rule': if default_rule_id == 'default_amortisation_rule':
accounting_transaction_data_list = {} accounting_transaction_data_list = {}
for path_group in date_group.group_list: for path_group in date_group.group_list:
source_section = path_group.source_section source_section = path_group.source_section
destination_section = path_group.destination_section destination_section = path_group.destination_section
source = path_group.source source = path_group.source
destination = path_group.destination destination = path_group.destination
accounting_transaction_data = accounting_transaction_data_list.get( (source_section, destination_section), None) accounting_transaction_data = accounting_transaction_data_list.get( (source_section, destination_section), None)
if accounting_transaction_data is None: if accounting_transaction_data is None:
accounting_transaction_data_list[ (source_section, destination_section) ] = {} accounting_transaction_data_list[ (source_section, destination_section) ] = {}
accounting_transaction_data = accounting_transaction_data_list.get( (source_section, destination_section), None) accounting_transaction_data = accounting_transaction_data_list.get( (source_section, destination_section), None)
quantity = 0 quantity = 0
source_movement_list = [] source_movement_list = []
for movement in path_group.movement_list: for movement in path_group.movement_list:
if movement.getDeliveryValue() is None: if movement.getDeliveryValue() is None:
quantity += movement.getQuantity() quantity += movement.getQuantity()
...@@ -525,12 +526,12 @@ class SimulationTool (Folder, UniqueObject): ...@@ -525,12 +526,12 @@ class SimulationTool (Folder, UniqueObject):
LOG('buildDeliveryList :', 0, 'adding movement %s : quantity = %s' % (repr(movement), repr(movement.getQuantity()))) LOG('buildDeliveryList :', 0, 'adding movement %s : quantity = %s' % (repr(movement), repr(movement.getQuantity())))
else: else:
LOG('buildDeliveryList :', 0, 'movement %s... delivery value = %s' % (repr(movement), repr(movement.getDeliveryValue()))) LOG('buildDeliveryList :', 0, 'movement %s... delivery value = %s' % (repr(movement), repr(movement.getDeliveryValue())))
accounting_transaction_data[ (source, destination) ] = (quantity, source_movement_list) accounting_transaction_data[ (source, destination) ] = (quantity, source_movement_list)
if len(source_movement_list) == 0: if len(source_movement_list) == 0:
LOG('buildDeliveryList :', 0, 'deleting transaction line because no source movement list... path_group.movement_list = %s' % repr(path_group.movement_list)) LOG('buildDeliveryList :', 0, 'deleting transaction line because no source movement list... path_group.movement_list = %s' % repr(path_group.movement_list))
del accounting_transaction_data[ (source, destination) ] del accounting_transaction_data[ (source, destination) ]
for (source_section, destination_section), accounting_transaction_data in accounting_transaction_data_list.items(): for (source_section, destination_section), accounting_transaction_data in accounting_transaction_data_list.items():
if len(accounting_transaction_data.items()) > 0: if len(accounting_transaction_data.items()) > 0:
new_delivery_id = str(delivery_module.generateNewId()) new_delivery_id = str(delivery_module.generateNewId())
...@@ -562,7 +563,7 @@ class SimulationTool (Folder, UniqueObject): ...@@ -562,7 +563,7 @@ class SimulationTool (Folder, UniqueObject):
movement.setDeliveryValue(accounting_transaction_line) movement.setDeliveryValue(accounting_transaction_line)
LOG('buildDeliveryList :', 0, 'after setting it, movement.delivery_value = %s' % repr(movement.getDeliveryValue())) LOG('buildDeliveryList :', 0, 'after setting it, movement.delivery_value = %s' % repr(movement.getDeliveryValue()))
movement.recursiveImmediateReindexObject() movement.recursiveImmediateReindexObject()
else: else:
# Create a new packing list # Create a new packing list
new_delivery_id = str(delivery_module.generateNewId()) new_delivery_id = str(delivery_module.generateNewId())
...@@ -591,10 +592,10 @@ class SimulationTool (Folder, UniqueObject): ...@@ -591,10 +592,10 @@ class SimulationTool (Folder, UniqueObject):
) )
# the new delivery is added to the delivery_list # the new delivery is added to the delivery_list
delivery_list.append(delivery) delivery_list.append(delivery)
# LOG('Livraison cre',0,str(delivery.getId())) # LOG('Livraison cre',0,str(delivery.getId()))
# Create each delivery_line in the new delivery # Create each delivery_line in the new delivery
for resource_group in date_group.group_list : for resource_group in date_group.group_list :
resourceGroupProcessing(resource_group=resource_group, resourceGroupProcessing(resource_group=resource_group,
delivery=delivery, delivery=delivery,
...@@ -603,10 +604,10 @@ class SimulationTool (Folder, UniqueObject): ...@@ -603,10 +604,10 @@ class SimulationTool (Folder, UniqueObject):
delivery_cell_type=delivery_cell_type, delivery_cell_type=delivery_cell_type,
delivery_list=delivery_list, delivery_list=delivery_list,
reindexable_movement_list=reindexable_movement_list, **kw) reindexable_movement_list=reindexable_movement_list, **kw)
def resourceGroupProcessing(resource_group, delivery, delivery_type, delivery_line_type, delivery_cell_type, delivery_list, reindexable_movement_list, delivery_module=None, default_rule_id=None, **kw): def resourceGroupProcessing(resource_group, delivery, delivery_type, delivery_line_type, delivery_cell_type, delivery_list, reindexable_movement_list, delivery_module=None, default_rule_id=None, **kw):
if default_rule_id == 'default_amortisation_rule': if default_rule_id == 'default_amortisation_rule':
resource = resource_group.resource resource = resource_group.resource
for date_group in resource_group.group_list: for date_group in resource_group.group_list:
...@@ -622,13 +623,13 @@ class SimulationTool (Folder, UniqueObject): ...@@ -622,13 +623,13 @@ class SimulationTool (Folder, UniqueObject):
default_rule_id=default_rule_id, default_rule_id=default_rule_id,
resource=resource) resource=resource)
else: else:
if delivery_type == 'Production Report': if delivery_type == 'Production Report':
if resource_group.resource.find('operation') == 0: if resource_group.resource.find('operation') == 0:
delivery_line_type = 'Production Report Operation' delivery_line_type = 'Production Report Operation'
else: else:
delivery_line_type = 'Production Report Component' delivery_line_type = 'Production Report Component'
new_delivery_line_id = str(delivery.generateNewId()) new_delivery_line_id = str(delivery.generateNewId())
self.portal_types.constructContent(type_name = delivery_line_type, self.portal_types.constructContent(type_name = delivery_line_type,
container = delivery, container = delivery,
...@@ -636,10 +637,10 @@ class SimulationTool (Folder, UniqueObject): ...@@ -636,10 +637,10 @@ class SimulationTool (Folder, UniqueObject):
resource = resource_group.resource, resource = resource_group.resource,
) )
delivery_line = delivery[new_delivery_line_id] delivery_line = delivery[new_delivery_line_id]
line_variation_category_list = [] line_variation_category_list = []
line_variation_base_category_dict = {} line_variation_base_category_dict = {}
# compute line_variation_base_category_list and # compute line_variation_base_category_list and
# line_variation_category_list for new delivery_line # line_variation_category_list for new delivery_line
for variant_group in resource_group.group_list : for variant_group in resource_group.group_list :
...@@ -649,14 +650,14 @@ class SimulationTool (Folder, UniqueObject): ...@@ -649,14 +650,14 @@ class SimulationTool (Folder, UniqueObject):
variation_base_category_items = variation_item.split('/') variation_base_category_items = variation_item.split('/')
if len(variation_base_category_items) > 0 : if len(variation_base_category_items) > 0 :
line_variation_base_category_dict[variation_base_category_items[0]] = 1 line_variation_base_category_dict[variation_base_category_items[0]] = 1
# update variation_base_category_list and line_variation_category_list for delivery_line # update variation_base_category_list and line_variation_category_list for delivery_line
line_variation_base_category_list = line_variation_base_category_dict.keys() line_variation_base_category_list = line_variation_base_category_dict.keys()
delivery_line._setVariationBaseCategoryList(line_variation_base_category_list) delivery_line._setVariationBaseCategoryList(line_variation_base_category_list)
delivery_line.setVariationCategoryList(line_variation_category_list) delivery_line.setVariationCategoryList(line_variation_category_list)
# IMPORTANT : delivery cells are automatically created during setVariationCategoryList # IMPORTANT : delivery cells are automatically created during setVariationCategoryList
# update target_quantity for each delivery_cell # update target_quantity for each delivery_cell
for variant_group in resource_group.group_list : for variant_group in resource_group.group_list :
#LOG('Variant_group examin?,0,str(variant_group.category_list)) #LOG('Variant_group examin?,0,str(variant_group.category_list))
...@@ -680,11 +681,11 @@ class SimulationTool (Folder, UniqueObject): ...@@ -680,11 +681,11 @@ class SimulationTool (Folder, UniqueObject):
break break
else : else :
categories_identity = 1 categories_identity = 1
if categories_identity : if categories_identity :
object_to_update = delivery_cell object_to_update = delivery_cell
break break
# compute target_quantity, quantity and price for delivery_cell or delivery_line and # compute target_quantity, quantity and price for delivery_cell or delivery_line and
# build relation between simulation_movement and delivery_cell or delivery_line # build relation between simulation_movement and delivery_cell or delivery_line
if object_to_update is not None : if object_to_update is not None :
...@@ -698,7 +699,7 @@ class SimulationTool (Folder, UniqueObject): ...@@ -698,7 +699,7 @@ class SimulationTool (Folder, UniqueObject):
cell_total_price += movement.getNetConvertedTargetQuantity()*movement.getPrice() # XXX WARNING - ADD PRICED QUANTITY cell_total_price += movement.getNetConvertedTargetQuantity()*movement.getPrice() # XXX WARNING - ADD PRICED QUANTITY
except: except:
cell_total_price = None cell_total_price = None
if movement.getPortalType() == 'Simulation Movement' : if movement.getPortalType() == 'Simulation Movement' :
# update every simulation_movement # update every simulation_movement
# we set delivery_value and target dates and quantity # we set delivery_value and target dates and quantity
...@@ -721,7 +722,7 @@ class SimulationTool (Folder, UniqueObject): ...@@ -721,7 +722,7 @@ class SimulationTool (Folder, UniqueObject):
# We will reindex later # We will reindex later
reindexable_movement_list.append(movement) reindexable_movement_list.append(movement)
if cell_target_quantity <> 0 and cell_total_price is not None: if cell_target_quantity <> 0 and cell_total_price is not None:
average_price = cell_total_price/cell_target_quantity average_price = cell_total_price/cell_target_quantity
else : else :
...@@ -733,11 +734,11 @@ class SimulationTool (Folder, UniqueObject): ...@@ -733,11 +734,11 @@ class SimulationTool (Folder, UniqueObject):
force_update = 1, force_update = 1,
) )
delivery_list = [] delivery_list = []
reindexable_movement_list = [] reindexable_movement_list = []
if movement_group is not None: if movement_group is not None:
# Verify the rule used to build the movements # Verify the rule used to build the movements
...@@ -747,8 +748,8 @@ class SimulationTool (Folder, UniqueObject): ...@@ -747,8 +748,8 @@ class SimulationTool (Folder, UniqueObject):
if f is not None: if f is not None:
applied_rule = f() applied_rule = f()
default_rule_id = applied_rule.getSpecialiseId() default_rule_id = applied_rule.getSpecialiseId()
LOG('buildDeliveryList :', 0, 'default_rule = %s' % repr(default_rule_id)) LOG('buildDeliveryList :', 0, 'default_rule = %s' % repr(default_rule_id))
if default_rule_id == 'default_amortisation_rule': if default_rule_id == 'default_amortisation_rule':
LOG('buildDeliveryList :', 0, 'default_rule is default_amortisation_rule') LOG('buildDeliveryList :', 0, 'default_rule is default_amortisation_rule')
...@@ -756,7 +757,7 @@ class SimulationTool (Folder, UniqueObject): ...@@ -756,7 +757,7 @@ class SimulationTool (Folder, UniqueObject):
delivery_type = 'Amortisation Transaction' delivery_type = 'Amortisation Transaction'
delivery_line_type = delivery_type + ' Line' delivery_line_type = delivery_type + ' Line'
delivery_cell_type = None delivery_cell_type = None
for resource_group in movement_group.group_list: for resource_group in movement_group.group_list:
resourceGroupProcessing(resource_group=resource_group, resourceGroupProcessing(resource_group=resource_group,
delivery=None, delivery=None,
...@@ -769,16 +770,16 @@ class SimulationTool (Folder, UniqueObject): ...@@ -769,16 +770,16 @@ class SimulationTool (Folder, UniqueObject):
default_rule_id=default_rule_id) default_rule_id=default_rule_id)
for movement in movement_group.movement_list: for movement in movement_group.movement_list:
movement.immediateReindexObject() movement.immediateReindexObject()
else: else:
for order_group in movement_group.group_list: for order_group in movement_group.group_list:
if orderGroupProcessing(order_group=order_group, if orderGroupProcessing(order_group=order_group,
delivery_list=delivery_list, delivery_list=delivery_list,
reindexable_movement_list=reindexable_movement_list) == -1: reindexable_movement_list=reindexable_movement_list) == -1:
return delivery_list return delivery_list
# If we reach this point, it means we could # If we reach this point, it means we could
# create deliveries # create deliveries
# get_transaction().commit() # get_transaction().commit()
...@@ -1016,7 +1017,9 @@ class SimulationTool (Folder, UniqueObject): ...@@ -1016,7 +1017,9 @@ class SimulationTool (Folder, UniqueObject):
# Asset Price Calculation # Asset Price Calculation
def updateAssetPrice(self, resource, variation_text, section_category, node_category, def updateAssetPrice(self, resource, variation_text, section_category, node_category,
strict_membership=0, simulation_state=current_inventory_state_list): strict_membership=0, simulation_state=None):
if simulation_state is None:
simulation_state = self.getPortalCurrentInventoryStateList()
section_value = self.portal_categories.resolveCategory(section_category) section_value = self.portal_categories.resolveCategory(section_category)
node_value = self.portal_categories.resolveCategory(node_category) node_value = self.portal_categories.resolveCategory(node_category)
# Initialize price # Initialize price
...@@ -1223,9 +1226,9 @@ class SimulationTool (Folder, UniqueObject): ...@@ -1223,9 +1226,9 @@ class SimulationTool (Folder, UniqueObject):
"%s is not the same between %s and %s (%s and %s)" % (attr, delivery.getId(), main_delivery.getId(), value, main_value) "%s is not the same between %s and %s (%s and %s)" % (attr, delivery.getId(), main_delivery.getId(), value, main_value)
# One more sanity check. Check if discounts are the same, if any. # One more sanity check. Check if discounts are the same, if any.
main_discount_list = main_delivery.contentValues(filter = {'portal_type': discount_type_list}) main_discount_list = main_delivery.contentValues(filter = {'portal_type': self.getPortalDiscountTypeList()})
for delivery in delivery_list: for delivery in delivery_list:
discount_list = delivery.contentValues(filter = {'portal_type': discount_type_list}) discount_list = delivery.contentValues(filter = {'portal_type': self.getPortalDiscountTypeList()})
if len(main_discount_list) != len(discount_list): if len(main_discount_list) != len(discount_list):
raise self.MergeDeliveryListError, "Discount is not the same between %s and %s" % (delivery.getId(), main_delivery.getId()) raise self.MergeDeliveryListError, "Discount is not the same between %s and %s" % (delivery.getId(), main_delivery.getId())
for discount in discount_list: for discount in discount_list:
...@@ -1239,9 +1242,9 @@ class SimulationTool (Folder, UniqueObject): ...@@ -1239,9 +1242,9 @@ class SimulationTool (Folder, UniqueObject):
raise self.MergeDeliveryListError, "Discount is not the same between %s and %s" % (delivery.getId(), main_delivery.getId()) raise self.MergeDeliveryListError, "Discount is not the same between %s and %s" % (delivery.getId(), main_delivery.getId())
# One more sanity check. Check if payment conditions are the same, if any. # One more sanity check. Check if payment conditions are the same, if any.
main_payment_condition_list = main_delivery.contentValues(filter = {'portal_type': payment_condition_type_list}) main_payment_condition_list = main_delivery.contentValues(filter = {'portal_type': self.getPortalPaymentConditionTypeList()})
for delivery in delivery_list: for delivery in delivery_list:
payment_condition_list = delivery.contentValues(filter = {'portal_type': payment_condition_type_list}) payment_condition_list = delivery.contentValues(filter = {'portal_type': self.getPortalPaymentConditionTypeList()})
if len(main_payment_condition_list) != len(payment_condition_list): if len(main_payment_condition_list) != len(payment_condition_list):
raise self.MergeDeliveryListError, "Payment Condition is not the same between %s and %s" % (delivery.getId(), main_delivery.getId()) raise self.MergeDeliveryListError, "Payment Condition is not the same between %s and %s" % (delivery.getId(), main_delivery.getId())
for condition in payment_condition_list: for condition in payment_condition_list:
...@@ -1258,10 +1261,10 @@ class SimulationTool (Folder, UniqueObject): ...@@ -1258,10 +1261,10 @@ class SimulationTool (Folder, UniqueObject):
# Make sure that all activities are flushed, to get simulation movements from delivery cells. # Make sure that all activities are flushed, to get simulation movements from delivery cells.
for delivery in delivery_list: for delivery in delivery_list:
for order in delivery.getCausalityValueList(portal_type = order_type_list): for order in delivery.getCausalityValueList(portal_type = self.getPortalOrderTypeList()):
for applied_rule in order.getCausalityRelatedValueList(portal_type = 'Applied Rule'): for applied_rule in order.getCausalityRelatedValueList(portal_type = 'Applied Rule'):
applied_rule.flushActivity(invoke = 1) applied_rule.flushActivity(invoke = 1)
for causality_related_delivery in delivery.getCausalityValueList(portal_type = delivery_type_list): for causality_related_delivery in delivery.getCausalityValueList(portal_type = self.getPortalDeliveryTypeList()):
for applied_rule in causality_related_delivery.getCausalityRelatedValueList(portal_type = 'Applied Rule'): for applied_rule in causality_related_delivery.getCausalityRelatedValueList(portal_type = 'Applied Rule'):
applied_rule.flushActivity(invoke = 1) applied_rule.flushActivity(invoke = 1)
...@@ -1313,8 +1316,8 @@ class SimulationTool (Folder, UniqueObject): ...@@ -1313,8 +1316,8 @@ class SimulationTool (Folder, UniqueObject):
delivery_line = None delivery_line = None
for movement in base_variant_group.movement_list: for movement in base_variant_group.movement_list:
if movement in main_movement_list: if movement in main_movement_list:
if movement.aq_parent.getPortalType() in simulated_movement_type_list \ if movement.aq_parent.getPortalType() in self.getPortalSimulatedMovementTypeList() \
or movement.aq_parent.getPortalType() in invoice_movement_type_list: or movement.aq_parent.getPortalType() in self.getPortalInvoiceMovementTypeList():
delivery_line = movement.aq_parent delivery_line = movement.aq_parent
else: else:
delivery_line = movement delivery_line = movement
...@@ -1324,8 +1327,8 @@ class SimulationTool (Folder, UniqueObject): ...@@ -1324,8 +1327,8 @@ class SimulationTool (Folder, UniqueObject):
if delivery_line is None: if delivery_line is None:
# Not found. So create a new delivery line. # Not found. So create a new delivery line.
movement = base_variant_group.movement_list[0] movement = base_variant_group.movement_list[0]
if movement.aq_parent.getPortalType() in simulated_movement_type_list \ if movement.aq_parent.getPortalType() in self.getPortalSimulatedMovementTypeList() \
or movement.aq_parent.getPortalType() in invoice_movement_type_list: or movement.aq_parent.getPortalType() in self.getPortalInvoiceMovementTypeList():
delivery_line_type = movement.aq_parent.getPortalType() delivery_line_type = movement.aq_parent.getPortalType()
else: else:
delivery_line_type = movement.getPortalType() delivery_line_type = movement.getPortalType()
...@@ -1397,12 +1400,12 @@ class SimulationTool (Folder, UniqueObject): ...@@ -1397,12 +1400,12 @@ class SimulationTool (Folder, UniqueObject):
LOG('mergeDeliveryList', 0, 'object_to_update = %s, cell_category_list = %s, cell_target_quantity = %s, cell_quantity = %s, average_price = %s' % (repr(object_to_update), repr(cell_category_list), repr(cell_target_quantity), repr(cell_quantity), repr(average_price))) LOG('mergeDeliveryList', 0, 'object_to_update = %s, cell_category_list = %s, cell_target_quantity = %s, cell_quantity = %s, average_price = %s' % (repr(object_to_update), repr(cell_category_list), repr(cell_target_quantity), repr(cell_quantity), repr(average_price)))
object_to_update.setCategoryList(cell_category_list) object_to_update.setCategoryList(cell_category_list)
if object_to_update.getPortalType() in simulated_movement_type_list: if object_to_update.getPortalType() in self.getPortalSimulatedMovementTypeList():
object_to_update.edit(target_quantity = cell_target_quantity, object_to_update.edit(target_quantity = cell_target_quantity,
quantity = cell_quantity, quantity = cell_quantity,
price = average_price, price = average_price,
) )
elif object_to_update.getPortalType() in invoice_movement_type_list: elif object_to_update.getPortalType() in self.getPortalInvoiceMovementTypeList():
# Invoices do not have target quantities, and the price never change. # Invoices do not have target quantities, and the price never change.
object_to_update.edit(quantity = cell_quantity, object_to_update.edit(quantity = cell_quantity,
price = cell_price, price = cell_price,
...@@ -1415,7 +1418,7 @@ class SimulationTool (Folder, UniqueObject): ...@@ -1415,7 +1418,7 @@ class SimulationTool (Folder, UniqueObject):
# Merge containers. Just copy them from other deliveries into the main. # Merge containers. Just copy them from other deliveries into the main.
for delivery in delivery_list: for delivery in delivery_list:
container_id_list = delivery.contentIds(filter = {'portal_type': container_type_list}) container_id_list = delivery.contentIds(filter = {'portal_type': self.getPortalContainerTypeList()})
if len(container_id_list) > 0: if len(container_id_list) > 0:
copy_data = delivery.manage_copyObjects(ids = container_id_list) copy_data = delivery.manage_copyObjects(ids = container_id_list)
new_id_list = main_delivery.manage_pasteObjects(copy_data) new_id_list = main_delivery.manage_pasteObjects(copy_data)
......
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