Commit 56831a07 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fix typos and cosmetic changes only.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23646 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0d838be4
############################################################################# #############################################################################
# #
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2006-2008 Nexedi SA and Contributors. All Rights Reserved.
# Rafael Monnerat <rafael@nexedi.com> # Rafael Monnerat <rafael@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -35,7 +35,7 @@ from Products.ERP5.Document.PropertyDivergenceTester import \ ...@@ -35,7 +35,7 @@ from Products.ERP5.Document.PropertyDivergenceTester import \
class CategoryDivergenceTester(PropertyDivergenceTester): class CategoryDivergenceTester(PropertyDivergenceTester):
""" """
The purpose of this divergence tester is to check the The purpose of this divergence tester is to check the
consistency between delivery movement and simulation movement consistency between delivery movement and simulation movement
for some specific categories. for some specific categories.
""" """
...@@ -44,7 +44,7 @@ class CategoryDivergenceTester(PropertyDivergenceTester): ...@@ -44,7 +44,7 @@ class CategoryDivergenceTester(PropertyDivergenceTester):
add_permission = Permissions.AddPortalContent add_permission = Permissions.AddPortalContent
isPortalContent = 1 isPortalContent = 1
isRADContent = 1 isRADContent = 1
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
...@@ -60,7 +60,7 @@ class CategoryDivergenceTester(PropertyDivergenceTester): ...@@ -60,7 +60,7 @@ class CategoryDivergenceTester(PropertyDivergenceTester):
, PropertySheet.DivergenceTester , PropertySheet.DivergenceTester
) )
def explain(self, simulation_movement): def explain(self, simulation_movement):
""" """
This method returns a list of messages that contains This method returns a list of messages that contains
...@@ -83,21 +83,21 @@ class CategoryDivergenceTester(PropertyDivergenceTester): ...@@ -83,21 +83,21 @@ class CategoryDivergenceTester(PropertyDivergenceTester):
delivery_mvt.getPropertyList(tested_property_id) delivery_mvt.getPropertyList(tested_property_id)
simulation_category_list = \ simulation_category_list = \
simulation_movement.getPropertyList(tested_property_id) simulation_movement.getPropertyList(tested_property_id)
# XXX Don't we need to check the order too ? # XXX Don't we need to check the order too ?
delivery_mvt_category_list.sort() delivery_mvt_category_list.sort()
simulation_category_list.sort() simulation_category_list.sort()
if delivery_mvt_category_list != simulation_category_list: if delivery_mvt_category_list != simulation_category_list:
delivery_mvt_category_title_list = [] delivery_mvt_category_title_list = []
for mvt_category in delivery_mvt_category_list: for mvt_category in delivery_mvt_category_list:
category_value = delivery_mvt.resolveCategory(mvt_category) category_value = delivery_mvt.resolveCategory(mvt_category)
if category_value is not None: if category_value is not None:
if category_value.getPortalType() == 'Category': if category_value.getPortalType() == 'Category':
delivery_mvt_category_title_list.append(category_value.getTranslatedTitle()) delivery_mvt_category_title_list.append(category_value.getTranslatedTitle())
else: else:
delivery_mvt_category_title_list.append(category_value.getTitle()) delivery_mvt_category_title_list.append(category_value.getTitle())
simulation_category_title_list = [] simulation_category_title_list = []
for mvt_category in simulation_category_list: for mvt_category in simulation_category_list:
category_value = delivery_mvt.resolveCategory(mvt_category) category_value = delivery_mvt.resolveCategory(mvt_category)
...@@ -106,20 +106,20 @@ class CategoryDivergenceTester(PropertyDivergenceTester): ...@@ -106,20 +106,20 @@ class CategoryDivergenceTester(PropertyDivergenceTester):
simulation_category_title_list.append(category_value.getTranslatedTitle()) simulation_category_title_list.append(category_value.getTranslatedTitle())
else: else:
simulation_category_title_list.append(category_value.getTitle()) simulation_category_title_list.append(category_value.getTitle())
delivery_mvt_property = ' , '.join(delivery_mvt_category_title_list) delivery_mvt_property = ' , '.join(delivery_mvt_category_title_list)
simulation_mvt_property = ' , '.join(simulation_category_title_list) simulation_mvt_property = ' , '.join(simulation_category_title_list)
message = ObjectMessage( message = ObjectMessage(
object_relative_url=delivery_mvt.getRelativeUrl(), object_relative_url=delivery_mvt.getRelativeUrl(),
simulation_movement=simulation_movement, simulation_movement=simulation_movement,
decision_value=delivery_mvt_property , decision_value=delivery_mvt_property ,
prevision_value=simulation_mvt_property, prevision_value=simulation_mvt_property,
tested_property=tested_property_id, tested_property=tested_property_id,
message=tested_property_title, message=tested_property_title,
solver_script_list=solver_script_list solver_script_list=solver_script_list
) )
divergence_message_list.append(message) divergence_message_list.append(message)
return divergence_message_list return divergence_message_list
############################################################################## ##############################################################################
# #
# Copyright (c) 2002, 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com> # Jean-Paul Smets-Solanes <jp@nexedi.com>
# Romain Courteaud <romain@nexedi.com> # Romain Courteaud <romain@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -140,7 +140,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -140,7 +140,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['portal_type'] = self.getPortalTaxMovementTypeList() kw['portal_type'] = self.getPortalTaxMovementTypeList()
return total_price + self.getTotalPrice(fast=fast, src__=src__, **kw) return total_price + self.getTotalPrice(fast=fast, src__=src__, **kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getTotalQuantity') 'getTotalQuantity')
def getTotalQuantity(self, fast=0, src__=0, **kw): def getTotalQuantity(self, fast=0, src__=0, **kw):
""" Returns the total quantity of this order. """ Returns the total quantity of this order.
...@@ -294,7 +294,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -294,7 +294,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
return 0 return 0
# else Do we need to create a simulation movement ? XXX probably not # else Do we need to create a simulation movement ? XXX probably not
return 1 return 1
security.declareProtected(Permissions.View, 'isDivergent') security.declareProtected(Permissions.View, 'isDivergent')
def isDivergent(self, fast=0, **kw): def isDivergent(self, fast=0, **kw):
""" """
...@@ -440,7 +440,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -440,7 +440,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
resource_dict[r] = 1 resource_dict[r] = 1
return resource_dict.keys() return resource_dict.keys()
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getInventory') 'getInventory')
def getInventory(self, **kw): def getInventory(self, **kw):
""" """
...@@ -449,7 +449,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -449,7 +449,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getInventory(**kw) return self.portal_simulation.getInventory(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentInventory') 'getCurrentInventory')
def getCurrentInventory(self, **kw): def getCurrentInventory(self, **kw):
""" """
...@@ -458,7 +458,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -458,7 +458,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getCurrentInventory(**kw) return self.portal_simulation.getCurrentInventory(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getAvailableInventory') 'getAvailableInventory')
def getAvailableInventory(self, **kw): def getAvailableInventory(self, **kw):
""" """
...@@ -468,7 +468,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -468,7 +468,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getAvailableInventory(**kw) return self.portal_simulation.getAvailableInventory(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getFutureInventory') 'getFutureInventory')
def getFutureInventory(self, **kw): def getFutureInventory(self, **kw):
""" """
...@@ -477,7 +477,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -477,7 +477,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getFutureInventory(**kw) return self.portal_simulation.getFutureInventory(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryList') 'getInventoryList')
def getInventoryList(self, **kw): def getInventoryList(self, **kw):
""" """
...@@ -486,7 +486,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -486,7 +486,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getInventoryList(**kw) return self.portal_simulation.getInventoryList(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentInventoryList') 'getCurrentInventoryList')
def getCurrentInventoryList(self, **kw): def getCurrentInventoryList(self, **kw):
""" """
...@@ -495,7 +495,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -495,7 +495,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getCurrentInventoryList(**kw) return self.portal_simulation.getCurrentInventoryList(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getFutureInventoryList') 'getFutureInventoryList')
def getFutureInventoryList(self, **kw): def getFutureInventoryList(self, **kw):
""" """
...@@ -504,7 +504,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -504,7 +504,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getFutureInventoryList(**kw) return self.portal_simulation.getFutureInventoryList(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryStat') 'getInventoryStat')
def getInventoryStat(self, **kw): def getInventoryStat(self, **kw):
""" """
...@@ -513,7 +513,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -513,7 +513,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getInventoryStat(**kw) return self.portal_simulation.getInventoryStat(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentInventoryStat') 'getCurrentInventoryStat')
def getCurrentInventoryStat(self, **kw): def getCurrentInventoryStat(self, **kw):
""" """
...@@ -522,7 +522,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -522,7 +522,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getCurrentInventoryStat(**kw) return self.portal_simulation.getCurrentInventoryStat(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getFutureInventoryStat') 'getFutureInventoryStat')
def getFutureInventoryStat(self, **kw): def getFutureInventoryStat(self, **kw):
""" """
...@@ -531,7 +531,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -531,7 +531,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getFutureInventoryStat(**kw) return self.portal_simulation.getFutureInventoryStat(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryChart') 'getInventoryChart')
def getInventoryChart(self, **kw): def getInventoryChart(self, **kw):
""" """
...@@ -540,7 +540,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -540,7 +540,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getInventoryChart(**kw) return self.portal_simulation.getInventoryChart(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentInventoryChart') 'getCurrentInventoryChart')
def getCurrentInventoryChart(self, **kw): def getCurrentInventoryChart(self, **kw):
""" """
...@@ -549,7 +549,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -549,7 +549,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getCurrentInventoryChart(**kw) return self.portal_simulation.getCurrentInventoryChart(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getFutureInventoryChart') 'getFutureInventoryChart')
def getFutureInventoryChart(self, **kw): def getFutureInventoryChart(self, **kw):
""" """
...@@ -558,7 +558,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -558,7 +558,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getFutureInventoryChart(**kw) return self.portal_simulation.getFutureInventoryChart(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryHistoryList') 'getInventoryHistoryList')
def getInventoryHistoryList(self, **kw): def getInventoryHistoryList(self, **kw):
""" """
...@@ -567,7 +567,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -567,7 +567,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getInventoryHistoryList(**kw) return self.portal_simulation.getInventoryHistoryList(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryHistoryChart') 'getInventoryHistoryChart')
def getInventoryHistoryChart(self, **kw): def getInventoryHistoryChart(self, **kw):
""" """
...@@ -576,7 +576,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -576,7 +576,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getInventoryHistoryChart(**kw) return self.portal_simulation.getInventoryHistoryChart(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getMovementHistoryList') 'getMovementHistoryList')
def getMovementHistoryList(self, **kw): def getMovementHistoryList(self, **kw):
""" """
...@@ -585,7 +585,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -585,7 +585,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
kw['resource'] = self._getMovementResourceList() kw['resource'] = self._getMovementResourceList()
return self.portal_simulation.getMovementHistoryList(**kw) return self.portal_simulation.getMovementHistoryList(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getMovementHistoryStat') 'getMovementHistoryStat')
def getMovementHistoryStat(self, **kw): def getMovementHistoryStat(self, **kw):
""" """
...@@ -607,7 +607,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -607,7 +607,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
# """ # """
# kw['category'] = self._getMovementResourceList() # kw['category'] = self._getMovementResourceList()
# return self.portal_simulation.getInventoryAssetPrice(**kw) # return self.portal_simulation.getInventoryAssetPrice(**kw)
# #
# security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryAssetPrice') # security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryAssetPrice')
# def getFutureInventoryAssetPrice(self, **kw): # def getFutureInventoryAssetPrice(self, **kw):
# """ # """
...@@ -615,7 +615,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -615,7 +615,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
# """ # """
# kw['category'] = self._getMovementResourceList() # kw['category'] = self._getMovementResourceList()
# return self.portal_simulation.getFutureInventoryAssetPrice(**kw) # return self.portal_simulation.getFutureInventoryAssetPrice(**kw)
# #
# security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryAssetPrice') # security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryAssetPrice')
# def getCurrentInventoryAssetPrice(self, **kw): # def getCurrentInventoryAssetPrice(self, **kw):
# """ # """
...@@ -623,7 +623,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -623,7 +623,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
# """ # """
# kw['category'] = self._getMovementResourceList() # kw['category'] = self._getMovementResourceList()
# return self.portal_simulation.getCurrentInventoryAssetPrice(**kw) # return self.portal_simulation.getCurrentInventoryAssetPrice(**kw)
# #
# security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventoryAssetPrice') # security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventoryAssetPrice')
# def getAvailableInventoryAssetPrice(self, **kw): # def getAvailableInventoryAssetPrice(self, **kw):
# """ # """
...@@ -704,8 +704,8 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -704,8 +704,8 @@ class Delivery(XMLObject, ImmobilisationDelivery):
portal_type='Applied Rule') portal_type='Applied Rule')
my_applied_rule = None my_applied_rule = None
if len(my_applied_rule_list) == 0: if len(my_applied_rule_list) == 0:
if self.isSimulated(): if self.isSimulated():
# No need to create a DeliveryRule # No need to create a DeliveryRule
# if we are already in the simulation process # if we are already in the simulation process
pass pass
else: else:
...@@ -743,7 +743,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -743,7 +743,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
def expand(self, *args,**kw): def expand(self, *args,**kw):
""" """
Reexpand applied rule Reexpand applied rule
Also reexpand all rules related to movements Also reexpand all rules related to movements
""" """
expand = UnrestrictedMethod(self._expand) expand = UnrestrictedMethod(self._expand)
...@@ -820,7 +820,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -820,7 +820,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
# (e.g. item) # (e.g. item)
if hasattr(causality, 'getRootCausalityValueList'): if hasattr(causality, 'getRootCausalityValueList'):
tmp_causality_list = causality.getRootCausalityValueList() tmp_causality_list = causality.getRootCausalityValueList()
initial_list.extend([x for x in tmp_causality_list initial_list.extend([x for x in tmp_causality_list
if x not in initial_list]) if x not in initial_list])
return initial_list return initial_list
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2005-2008 Nexedi SA and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com> # Romain Courteaud <romain@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -43,38 +43,38 @@ class SelectMovementError(Exception): pass ...@@ -43,38 +43,38 @@ class SelectMovementError(Exception): pass
class DeliveryBuilder(OrderBuilder): class DeliveryBuilder(OrderBuilder):
""" """
Delivery Builder objects allow to gather multiple Simulation Movements Delivery Builder objects allow to gather multiple Simulation Movements
into a single Delivery. into a single Delivery.
The initial quantity property of the Delivery Line is calculated by The initial quantity property of the Delivery Line is calculated by
summing quantities of related Simulation Movements. summing quantities of related Simulation Movements.
Delivery Builders are called for example whenever an order is confirmed. Delivery Builders are called for example whenever an order is confirmed.
They are also called globaly in order to gather any confirmed or above They are also called globaly in order to gather any confirmed or above
Simulation Movement which was not associated to any Delivery Line. Simulation Movement which was not associated to any Delivery Line.
Such movements are called orphaned Simulation Movements. Such movements are called orphaned Simulation Movements.
Delivery Builder objects are provided with a set a parameters to achieve Delivery Builder objects are provided with a set a parameters to achieve
their goal: their goal:
A path definition: source, destination, etc. which defines the general A path definition: source, destination, etc. which defines the general
kind of movements it applies. kind of movements it applies.
simulation_select_method which defines how to query all Simulation simulation_select_method which defines how to query all Simulation
Movements which meet certain criteria (including the above path path Movements which meet certain criteria (including the above path path
definition). definition).
collect_order_list which defines how to group selected movements collect_order_list which defines how to group selected movements
according to gathering rules. according to gathering rules.
delivery_select_method which defines how to select existing Delivery delivery_select_method which defines how to select existing Delivery
which may eventually be updated with selected simulation movements. which may eventually be updated with selected simulation movements.
delivery_module, delivery_type and delivery_line_type which define the delivery_module, delivery_type and delivery_line_type which define the
module and portal types for newly built Deliveries and Delivery Lines. module and portal types for newly built Deliveries and Delivery Lines.
Delivery Builders can also be provided with optional parameters to Delivery Builders can also be provided with optional parameters to
restrict selection to a given root Applied Rule caused by a single Order restrict selection to a given root Applied Rule caused by a single Order
or to Simulation Movements related to a limited set of existing or to Simulation Movements related to a limited set of existing
Deliveries. Deliveries.
""" """
...@@ -103,7 +103,7 @@ class DeliveryBuilder(OrderBuilder): ...@@ -103,7 +103,7 @@ class DeliveryBuilder(OrderBuilder):
done before building Delivery. done before building Delivery.
""" """
pass pass
def searchMovementList(self, applied_rule_uid=None,**kw): def searchMovementList(self, applied_rule_uid=None,**kw):
""" """
defines how to query all Simulation Movements which meet certain criteria defines how to query all Simulation Movements which meet certain criteria
...@@ -157,7 +157,7 @@ class DeliveryBuilder(OrderBuilder): ...@@ -157,7 +157,7 @@ class DeliveryBuilder(OrderBuilder):
and delivery movement. and delivery movement.
""" """
OrderBuilder._setDeliveryMovementProperties( OrderBuilder._setDeliveryMovementProperties(
self, delivery_movement, self, delivery_movement,
simulation_movement, property_dict, simulation_movement, property_dict,
update_existing_movement=update_existing_movement) update_existing_movement=update_existing_movement)
# Check if simulation movement is not already linked to a existing # Check if simulation movement is not already linked to a existing
...@@ -170,11 +170,11 @@ class DeliveryBuilder(OrderBuilder): ...@@ -170,11 +170,11 @@ class DeliveryBuilder(OrderBuilder):
simulation_movement.edit(delivery_value=delivery_movement) simulation_movement.edit(delivery_value=delivery_movement)
# Simulation consistency propagation # Simulation consistency propagation
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'updateFromSimulation') 'updateFromSimulation')
def updateFromSimulation(self, delivery_relative_url, create_new_delivery=1): def updateFromSimulation(self, delivery_relative_url, create_new_delivery=1):
""" """
Update all lines of this transaction based on movements in the Update all lines of this transaction based on movements in the
simulation related to this transaction. simulation related to this transaction.
""" """
updateFromSimulation = UnrestrictedMethod(self._updateFromSimulation) updateFromSimulation = UnrestrictedMethod(self._updateFromSimulation)
...@@ -194,7 +194,7 @@ class DeliveryBuilder(OrderBuilder): ...@@ -194,7 +194,7 @@ class DeliveryBuilder(OrderBuilder):
for simulation_movement in movement.getDeliveryRelatedValueList( for simulation_movement in movement.getDeliveryRelatedValueList(
portal_type="Simulation Movement"): portal_type="Simulation Movement"):
simulation_movement.setDelivery(None) simulation_movement.setDelivery(None)
simulation_movement_list.append(simulation_movement) simulation_movement_list.append(simulation_movement)
# Collect # Collect
root_group = self.collectMovement(simulation_movement_list) root_group = self.collectMovement(simulation_movement_list)
...@@ -259,7 +259,7 @@ class DeliveryBuilder(OrderBuilder): ...@@ -259,7 +259,7 @@ class DeliveryBuilder(OrderBuilder):
rejected_movement_list.extend(group.getMovementList()) rejected_movement_list.extend(group.getMovementList())
movement_group = movement_group.getGroupList()[0] movement_group = movement_group.getGroupList()[0]
property_dict.update(movement_group.getGroupEditDict()) property_dict.update(movement_group.getGroupEditDict())
# Put properties on delivery # Put properties on delivery
delivery.edit(**property_dict) delivery.edit(**property_dict)
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2005-2008 Nexedi SA and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com> # Romain Courteaud <romain@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -42,33 +42,33 @@ class MatrixError(Exception): pass ...@@ -42,33 +42,33 @@ class MatrixError(Exception): pass
class OrderBuilder(XMLObject, Amount, Predicate): class OrderBuilder(XMLObject, Amount, Predicate):
""" """
Order Builder objects allow to gather multiple Simulation Movements Order Builder objects allow to gather multiple Simulation Movements
into a single Delivery. into a single Delivery.
The initial quantity property of the Delivery Line is calculated by The initial quantity property of the Delivery Line is calculated by
summing quantities of related Simulation Movements. summing quantities of related Simulation Movements.
Order Builder objects are provided with a set a parameters to achieve Order Builder objects are provided with a set a parameters to achieve
their goal: their goal:
A path definition: source, destination, etc. which defines the general A path definition: source, destination, etc. which defines the general
kind of movements it applies. kind of movements it applies.
simulation_select_method which defines how to query all Simulation simulation_select_method which defines how to query all Simulation
Movements which meet certain criteria (including the above path path Movements which meet certain criteria (including the above path path
definition). definition).
collect_order_list which defines how to group selected movements collect_order_list which defines how to group selected movements
according to gathering rules. according to gathering rules.
delivery_select_method which defines how to select existing Delivery delivery_select_method which defines how to select existing Delivery
which may eventually be updated with selected simulation movements. which may eventually be updated with selected simulation movements.
delivery_module, delivery_type and delivery_line_type which define the delivery_module, delivery_type and delivery_line_type which define the
module and portal types for newly built Deliveries and Delivery Lines. module and portal types for newly built Deliveries and Delivery Lines.
Order Builders can also be provided with optional parameters to Order Builders can also be provided with optional parameters to
restrict selection to a given root Applied Rule caused by a single Order restrict selection to a given root Applied Rule caused by a single Order
or to Simulation Movements related to a limited set of existing or to Simulation Movements related to a limited set of existing
Deliveries. Deliveries.
""" """
...@@ -90,7 +90,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -90,7 +90,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
, PropertySheet.Comment , PropertySheet.Comment
, PropertySheet.DeliveryBuilder , PropertySheet.DeliveryBuilder
) )
security.declarePublic('build') security.declarePublic('build')
def build(self, applied_rule_uid=None, movement_relative_url_list=None, def build(self, applied_rule_uid=None, movement_relative_url_list=None,
delivery_relative_url_list=None,**kw): delivery_relative_url_list=None,**kw):
...@@ -129,10 +129,10 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -129,10 +129,10 @@ class OrderBuilder(XMLObject, Amount, Predicate):
def callBeforeBuildingScript(self): def callBeforeBuildingScript(self):
""" """
Call a script on the module, for example, to remove some Call a script on the module, for example, to remove some
auto_planned Order. auto_planned Order.
This part can only be done with a script, because user may want This part can only be done with a script, because user may want
to keep existing auto_planned Order, and only update lines in to keep existing auto_planned Order, and only update lines in
them. them.
No activities are used when deleting a object, so, current No activities are used when deleting a object, so, current
implementation should be OK. implementation should be OK.
...@@ -147,9 +147,9 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -147,9 +147,9 @@ class OrderBuilder(XMLObject, Amount, Predicate):
""" """
Defines how to query all Simulation Movements which meet certain Defines how to query all Simulation Movements which meet certain
criteria (including the above path path definition). criteria (including the above path path definition).
First, select movement matching to criteria define on First, select movement matching to criteria define on
DeliveryBuilder. DeliveryBuilder.
Then, call script simulation_select_method to restrict Then, call script simulation_select_method to restrict
movement_list. movement_list.
""" """
from Products.ERP5Type.Document import newTempMovement from Products.ERP5Type.Document import newTempMovement
...@@ -175,7 +175,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -175,7 +175,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
if (inventory_item.inventory is not None): if (inventory_item.inventory is not None):
dumb_movement = inventory_item.getObject() dumb_movement = inventory_item.getObject()
# Create temporary movement # Create temporary movement
movement = newTempMovement(self.getPortalObject(), movement = newTempMovement(self.getPortalObject(),
str(id_count)) str(id_count))
id_count += 1 id_count += 1
movement.edit( movement.edit(
...@@ -224,7 +224,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -224,7 +224,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
def collectMovement(self, movement_list): def collectMovement(self, movement_list):
""" """
group movements in the way we want. Thanks to this method, we are able group movements in the way we want. Thanks to this method, we are able
to retrieve movement classed by order, resource, criterion,.... to retrieve 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
check_list : the list of classes used to group movements. The order check_list : the list of classes used to group movements. The order
...@@ -295,7 +295,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -295,7 +295,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
**kw) **kw)
return delivery_list return delivery_list
def _deliveryGroupProcessing(self, delivery_module, movement_group, def _deliveryGroupProcessing(self, delivery_module, movement_group,
collect_order_list, property_dict, collect_order_list, property_dict,
delivery_to_update_list=None, delivery_to_update_list=None,
activate_kw=None,**kw): activate_kw=None,**kw):
...@@ -321,7 +321,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -321,7 +321,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
activate_kw=activate_kw) activate_kw=activate_kw)
delivery_list.extend(new_delivery_list) delivery_list.extend(new_delivery_list)
else: else:
# Test if we can update a existing delivery, or if we need to create # Test if we can update a existing delivery, or if we need to create
# a new one # a new one
delivery = None delivery = None
for delivery_to_update in delivery_to_update_list: for delivery_to_update in delivery_to_update_list:
...@@ -352,7 +352,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -352,7 +352,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
activate_kw=activate_kw,**kw) activate_kw=activate_kw,**kw)
delivery_list.append(delivery) delivery_list.append(delivery)
return delivery_list return delivery_list
def _deliveryLineGroupProcessing(self, delivery, movement_group, def _deliveryLineGroupProcessing(self, delivery, movement_group,
collect_order_list, property_dict, collect_order_list, property_dict,
activate_kw=None,**kw): activate_kw=None,**kw):
...@@ -403,7 +403,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -403,7 +403,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
# Then, create delivery movement (delivery cell or complete delivery # Then, create delivery movement (delivery cell or complete delivery
# line) # line)
group_list = movement_group.getGroupList() group_list = movement_group.getGroupList()
# If no group is defined for cell, we need to continue, in order to # If no group is defined for cell, we need to continue, in order to
# save the quantity value # save the quantity value
if list(group_list) != []: if list(group_list) != []:
for group in group_list: for group in group_list:
...@@ -438,9 +438,9 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -438,9 +438,9 @@ class OrderBuilder(XMLObject, Amount, Predicate):
# Get sorted movement for each delivery line # Get sorted movement for each delivery line
for group in movement_group.getGroupList(): for group in movement_group.getGroupList():
self._deliveryCellGroupProcessing( self._deliveryCellGroupProcessing(
delivery_line, delivery_line,
group, group,
collect_order_list[1:], collect_order_list[1:],
property_dict.copy(), property_dict.copy(),
update_existing_line=update_existing_line, update_existing_line=update_existing_line,
activate_kw=activate_kw) activate_kw=activate_kw)
...@@ -473,7 +473,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -473,7 +473,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
cell = delivery_line.getCell(base_id=base_id, *cell_key) cell = delivery_line.getCell(base_id=base_id, *cell_key)
if self.testObjectProperties(cell, property_dict): if self.testObjectProperties(cell, property_dict):
# We update a existing cell # We update a existing cell
# delivery_ratio of new related movement to this cell # delivery_ratio of new related movement to this cell
# must be updated to 0. # must be updated to 0.
update_existing_movement = 1 update_existing_movement = 1
object_to_update = cell object_to_update = cell
...@@ -484,7 +484,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -484,7 +484,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
omit_optional_variation=1) omit_optional_variation=1)
if not delivery_line.hasCell(base_id=base_id, *cell_key): if not delivery_line.hasCell(base_id=base_id, *cell_key):
cell = delivery_line.newCell(base_id=base_id, \ cell = delivery_line.newCell(base_id=base_id, \
portal_type=self.getDeliveryCellPortalType(), portal_type=self.getDeliveryCellPortalType(),
activate_kw=activate_kw,*cell_key) activate_kw=activate_kw,*cell_key)
vcl = movement.getVariationCategoryList() vcl = movement.getVariationCategoryList()
cell._edit(category_list=vcl, cell._edit(category_list=vcl,
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2006-2008 Nexedi SA and Contributors. All Rights Reserved.
# Rafael Monnerat <rafael@nexedi.com> # Rafael Monnerat <rafael@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -35,7 +35,7 @@ from Products.ERP5Type import Permissions, PropertySheet, Interface ...@@ -35,7 +35,7 @@ from Products.ERP5Type import Permissions, PropertySheet, Interface
class PropertyDivergenceTester(XMLObject): class PropertyDivergenceTester(XMLObject):
""" """
The purpose of this divergence tester is to check the The purpose of this divergence tester is to check the
consistency between delivery movement and simulation movement consistency between delivery movement and simulation movement
for some specific properties. for some specific properties.
""" """
...@@ -44,7 +44,7 @@ class PropertyDivergenceTester(XMLObject): ...@@ -44,7 +44,7 @@ class PropertyDivergenceTester(XMLObject):
add_permission = Permissions.AddPortalContent add_permission = Permissions.AddPortalContent
isPortalContent = 1 isPortalContent = 1
isRADContent = 1 isRADContent = 1
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
...@@ -73,12 +73,12 @@ class PropertyDivergenceTester(XMLObject): ...@@ -73,12 +73,12 @@ class PropertyDivergenceTester(XMLObject):
the divergence of the Delivery Line. the divergence of the Delivery Line.
""" """
divergence_message_list = [] divergence_message_list = []
tested_property = self.getTestedPropertyList() tested_property = self.getTestedPropertyList()
# Get the list of solvers callable in this case # Get the list of solvers callable in this case
solver_script_list = self.getSolverScriptList() solver_script_list = self.getSolverScriptList()
if solver_script_list is None: if solver_script_list is None:
solver_script_list = [] solver_script_list = []
solver_script_list = self._splitStringList(solver_script_list) solver_script_list = self._splitStringList(solver_script_list)
delivery_mvt = simulation_movement.getDeliveryValue() delivery_mvt = simulation_movement.getDeliveryValue()
...@@ -96,13 +96,13 @@ class PropertyDivergenceTester(XMLObject): ...@@ -96,13 +96,13 @@ class PropertyDivergenceTester(XMLObject):
message=tested_property_title, message=tested_property_title,
solver_script_list=solver_script_list solver_script_list=solver_script_list
) )
divergence_message_list.append(message) divergence_message_list.append(message)
return divergence_message_list return divergence_message_list
def _splitStringList(self, string_list): def _splitStringList(self, string_list):
""" """
Convert a list of string with a pipe (ex: ["azert | qsdfg", ] ) Convert a list of string with a pipe (ex: ["azert | qsdfg", ] )
to a list of tuple (ex: [("azert", "qsdfg"), ] ) to a list of tuple (ex: [("azert", "qsdfg"), ] )
""" """
return [tuple([x.strip() for x in x.split('|')]) for x in string_list] return [tuple([x.strip() for x in x.split('|')]) for x in string_list]
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
# Rafael M. Monnerat <rafael@nexedi.com> # Rafael M. Monnerat <rafael@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -35,7 +35,7 @@ from Products.ERP5.Document.PropertyDivergenceTester import \ ...@@ -35,7 +35,7 @@ from Products.ERP5.Document.PropertyDivergenceTester import \
class QuantityDivergenceTester(PropertyDivergenceTester): class QuantityDivergenceTester(PropertyDivergenceTester):
""" """
The purpose of this divergence tester is to check the The purpose of this divergence tester is to check the
consistency between delivery movement and simulation movement consistency between delivery movement and simulation movement
for the property quantity. for the property quantity.
""" """
...@@ -44,14 +44,14 @@ class QuantityDivergenceTester(PropertyDivergenceTester): ...@@ -44,14 +44,14 @@ class QuantityDivergenceTester(PropertyDivergenceTester):
add_permission = Permissions.AddPortalContent add_permission = Permissions.AddPortalContent
isPortalContent = 1 isPortalContent = 1
isRADContent = 1 isRADContent = 1
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative interfaces # Declarative interfaces
__implements__ = ( Interface.DivergenceTester, ) __implements__ = ( Interface.DivergenceTester, )
# Declarative properties # Declarative properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
...@@ -61,7 +61,7 @@ class QuantityDivergenceTester(PropertyDivergenceTester): ...@@ -61,7 +61,7 @@ class QuantityDivergenceTester(PropertyDivergenceTester):
, PropertySheet.DivergenceTester , PropertySheet.DivergenceTester
) )
def explain(self, simulation_movement): def explain(self, simulation_movement):
""" """
This method returns a list of messages that contains This method returns a list of messages that contains
...@@ -72,11 +72,11 @@ class QuantityDivergenceTester(PropertyDivergenceTester): ...@@ -72,11 +72,11 @@ class QuantityDivergenceTester(PropertyDivergenceTester):
d_quantity = delivery.getQuantity() d_quantity = delivery.getQuantity()
quantity = simulation_movement.getCorrectedQuantity() quantity = simulation_movement.getCorrectedQuantity()
d_error = simulation_movement.getDeliveryError() d_error = simulation_movement.getDeliveryError()
solver_script_list = self.getSolverScriptList() solver_script_list = self.getSolverScriptList()
if solver_script_list is None: if solver_script_list is None:
solver_script_list = [] solver_script_list = []
message = ObjectMessage(object_relative_url= delivery.getRelativeUrl(), message = ObjectMessage(object_relative_url= delivery.getRelativeUrl(),
simulation_movement = simulation_movement, simulation_movement = simulation_movement,
decision_value = d_quantity , decision_value = d_quantity ,
...@@ -85,8 +85,8 @@ class QuantityDivergenceTester(PropertyDivergenceTester): ...@@ -85,8 +85,8 @@ class QuantityDivergenceTester(PropertyDivergenceTester):
message='Quantity', message='Quantity',
solver_script_list=self._splitStringList(solver_script_list) solver_script_list=self._splitStringList(solver_script_list)
) )
if quantity is None: if quantity is None:
if d_quantity is None: if d_quantity is None:
return [] return []
......
...@@ -1369,7 +1369,7 @@ class ERP5Generator(PortalGenerator): ...@@ -1369,7 +1369,7 @@ class ERP5Generator(PortalGenerator):
addMessageCatalog('default', 'ERP5 Localized Messages', ('en',)) addMessageCatalog('default', 'ERP5 Localized Messages', ('en',))
addMessageCatalog('erp5_ui', 'ERP5 Localized Interface', ('en',)) addMessageCatalog('erp5_ui', 'ERP5 Localized Interface', ('en',))
addMessageCatalog('erp5_content', 'ERP5 Localized Content', ('en',)) addMessageCatalog('erp5_content', 'ERP5 Localized Content', ('en',))
# Add an error_log # Add an error_log
if 'error_log' not in p.objectIds(): if 'error_log' not in p.objectIds():
manage_addErrorLog(p) manage_addErrorLog(p)
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2002, 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002-2008 Nexedi SA and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com> # Sebastien Robin <seb@nexedi.com>
# Yoshinori Okuji <yo@nexedi.com> # Yoshinori Okuji <yo@nexedi.com>
# Romain Courteaud <romain@nexedi.com> # Romain Courteaud <romain@nexedi.com>
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2006-2008 Nexedi SA and Contributors. All Rights Reserved.
# Rafael Monnerat <rafael@nexedi.com> # Rafael Monnerat <rafael@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -41,6 +41,6 @@ class DivergenceTester: ...@@ -41,6 +41,6 @@ class DivergenceTester:
{ 'id' : 'solver_script', { 'id' : 'solver_script',
'description' : 'List of scripts used to call the solvers', 'description' : 'List of scripts used to call the solvers',
'type' : 'string', 'type' : 'string',
'multivalued' : 1, 'multivalued' : 1,
'mode' : 'w' }, 'mode' : 'w' },
) )
############################################################################## ##############################################################################
# #
# Copyright (c) 2004 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2004-2008 Nexedi SA and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com> # Sebastien Robin <seb@nexedi.com>
# Jerome Perrin <jerome@nexedi.com> # Jerome Perrin <jerome@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -287,7 +287,7 @@ class TestInvoice(TestInvoiceMixin): ...@@ -287,7 +287,7 @@ class TestInvoice(TestInvoiceMixin):
resource_value=resource, resource_value=resource,
quantity=1, quantity=1,
price=2) price=2)
other_entity = self.portal.organisation_module.newContent( other_entity = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
title='Other Entity') title='Other Entity')
...@@ -301,7 +301,7 @@ class TestInvoice(TestInvoiceMixin): ...@@ -301,7 +301,7 @@ class TestInvoice(TestInvoiceMixin):
delivery_movement = related_applied_rule.contentValues()[0] delivery_movement = related_applied_rule.contentValues()[0]
invoice_applied_rule = delivery_movement.contentValues()[0] invoice_applied_rule = delivery_movement.contentValues()[0]
invoice_movement = invoice_applied_rule.contentValues()[0] invoice_movement = invoice_applied_rule.contentValues()[0]
order_line.setSourceValue(other_entity) order_line.setSourceValue(other_entity)
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
...@@ -497,7 +497,7 @@ class TestInvoice(TestInvoiceMixin): ...@@ -497,7 +497,7 @@ class TestInvoice(TestInvoiceMixin):
invoice_transaction_applied_rule = invoice_movement.contentValues()[0] invoice_transaction_applied_rule = invoice_movement.contentValues()[0]
invoice_transaction_movement =\ invoice_transaction_movement =\
invoice_transaction_applied_rule._getOb('income') invoice_transaction_applied_rule._getOb('income')
order_line.setSourceSectionValue(other_entity) order_line.setSourceSectionValue(other_entity)
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
...@@ -655,7 +655,7 @@ class TestInvoice(TestInvoiceMixin): ...@@ -655,7 +655,7 @@ class TestInvoice(TestInvoiceMixin):
invoice.confirm() invoice.confirm()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
odt = invoice.Invoice_viewAsODT() odt = invoice.Invoice_viewAsODT()
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator() odf_validator = Validator()
...@@ -719,7 +719,7 @@ class TestInvoice(TestInvoiceMixin): ...@@ -719,7 +719,7 @@ class TestInvoice(TestInvoiceMixin):
related_packing_list = order.getCausalityRelatedValue( related_packing_list = order.getCausalityRelatedValue(
portal_type=self.packing_list_portal_type) portal_type=self.packing_list_portal_type)
self.assertNotEquals(related_packing_list, None) self.assertNotEquals(related_packing_list, None)
related_packing_list.start() related_packing_list.start()
related_packing_list.stop() related_packing_list.stop()
get_transaction().commit() get_transaction().commit()
...@@ -733,7 +733,7 @@ class TestInvoice(TestInvoiceMixin): ...@@ -733,7 +733,7 @@ class TestInvoice(TestInvoiceMixin):
portal_type=self.invoice_line_portal_type) portal_type=self.invoice_line_portal_type)
self.assertEquals(1, len(line_list)) self.assertEquals(1, len(line_list))
invoice_line = line_list[0] invoice_line = line_list[0]
self.assertEquals(resource, invoice_line.getResourceValue()) self.assertEquals(resource, invoice_line.getResourceValue())
self.assertEquals(['size'], invoice_line.getVariationBaseCategoryList()) self.assertEquals(['size'], invoice_line.getVariationBaseCategoryList())
self.assertEquals(2, self.assertEquals(2,
...@@ -791,7 +791,7 @@ class TestSaleInvoiceMixin(TestInvoiceMixin, ...@@ -791,7 +791,7 @@ class TestSaleInvoiceMixin(TestInvoiceMixin,
invoice_line_portal_type = 'Invoice Line' invoice_line_portal_type = 'Invoice Line'
invoice_cell_portal_type = 'Invoice Cell' invoice_cell_portal_type = 'Invoice Cell'
invoice_transaction_line_portal_type = 'Sale Invoice Transaction Line' invoice_transaction_line_portal_type = 'Sale Invoice Transaction Line'
# default sequence for one line of not varianted resource. # default sequence for one line of not varianted resource.
PACKING_LIST_DEFAULT_SEQUENCE = """ PACKING_LIST_DEFAULT_SEQUENCE = """
stepCreateEntities stepCreateEntities
...@@ -1239,7 +1239,7 @@ class TestSaleInvoiceMixin(TestInvoiceMixin, ...@@ -1239,7 +1239,7 @@ class TestSaleInvoiceMixin(TestInvoiceMixin,
resource_precision = line.getResourceValue().getQuantityPrecision() resource_precision = line.getResourceValue().getQuantityPrecision()
self.assertEquals(round(line.getQuantity(), resource_precision), self.assertEquals(round(line.getQuantity(), resource_precision),
round(expected_price * line_ratio, resource_precision)) round(expected_price * line_ratio, resource_precision))
def stepCheckInvoiceLineHasReferenceAndIntIndex(self, sequence=None, **kw): def stepCheckInvoiceLineHasReferenceAndIntIndex(self, sequence=None, **kw):
"""Check that the unique invoice line in the invoice has reference and int """Check that the unique invoice line in the invoice has reference and int
index. index.
...@@ -1254,9 +1254,9 @@ class TestSaleInvoiceMixin(TestInvoiceMixin, ...@@ -1254,9 +1254,9 @@ class TestSaleInvoiceMixin(TestInvoiceMixin,
def stepCheckPackingListInvoice( def stepCheckPackingListInvoice(
self, sequence=None, sequence_list=None, **kw): self, sequence=None, sequence_list=None, **kw):
""" Checks if the delivery builder is working as expected, """ Checks if the delivery builder is working as expected,
coping the atributes from packing list to invoice.""" coping the atributes from packing list to invoice."""
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
related_invoice_list = packing_list.getCausalityRelatedValueList( related_invoice_list = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type) portal_type=self.invoice_portal_type)
self.assertEquals(len(related_invoice_list), 1) self.assertEquals(len(related_invoice_list), 1)
...@@ -2520,7 +2520,7 @@ class TestSaleInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase): ...@@ -2520,7 +2520,7 @@ class TestSaleInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase):
# We could generate a better reference here. # We could generate a better reference here.
self.assertEquals('1', invoice.getReference()) self.assertEquals('1', invoice.getReference())
def test_16_ManuallyAddedMovements(self, quiet=quiet, run=RUN_ALL_TESTS): def test_16_ManuallyAddedMovements(self, quiet=quiet, run=RUN_ALL_TESTS):
""" """
Checks that adding invoice lines and accounting lines to one invoice Checks that adding invoice lines and accounting lines to one invoice
......
############################################################################## ##############################################################################
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
# Copyright (c) 2004, 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2004-2008 Nexedi SA and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com> # Sebastien Robin <seb@nexedi.com>
# Romain Courteaud <romain@nexedi.com> # Romain Courteaud <romain@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -571,7 +571,7 @@ class TestOrderMixin: ...@@ -571,7 +571,7 @@ class TestOrderMixin:
self.assertEquals( order.getTotalPrice(fast = 0), self.assertEquals( order.getTotalPrice(fast = 0),
order.getTotalPrice(fast = 1) ) order.getTotalPrice(fast = 1) )
def stepCheckOrderTotalPriceAndQuantityFastParameter(self, def stepCheckOrderTotalPriceAndQuantityFastParameter(self,
sequence=None, sequence_list=None, **kw): sequence=None, sequence_list=None, **kw):
""" """
Check the method getTotalPrice on a order . Check the method getTotalPrice on a order .
...@@ -682,7 +682,7 @@ class TestOrderMixin: ...@@ -682,7 +682,7 @@ class TestOrderMixin:
""" """
self.checkOrderRuleSimulation(rule_id = 'default_order_rule', sequence=sequence, \ self.checkOrderRuleSimulation(rule_id = 'default_order_rule', sequence=sequence, \
sequence_list=sequence_list, **kw) sequence_list=sequence_list, **kw)
def checkOrderRuleSimulation(self, rule_id, sequence=None, sequence_list=None, **kw): def checkOrderRuleSimulation(self, rule_id, sequence=None, sequence_list=None, **kw):
""" """
Test if simulation is matching order, be sure that rule_id is used Test if simulation is matching order, be sure that rule_id is used
...@@ -953,7 +953,7 @@ class TestOrderMixin: ...@@ -953,7 +953,7 @@ class TestOrderMixin:
for applied_rule in related_applied_rule_list.keys(): for applied_rule in related_applied_rule_list.keys():
self.assertTrue(applied_rule.isStable()) self.assertTrue(applied_rule.isStable())
def stepPackingListAdoptPrevision(self,sequence=None, sequence_list=None, def stepPackingListAdoptPrevision(self,sequence=None, sequence_list=None,
**kw): **kw):
""" """
Check if simulation movement are disconnected Check if simulation movement are disconnected
...@@ -998,7 +998,7 @@ class TestOrderMixin: ...@@ -998,7 +998,7 @@ class TestOrderMixin:
variated_order_creation_without_tic = variated_order_line_creation + \ variated_order_creation_without_tic = variated_order_line_creation + \
variated_line_completion_without_tic variated_line_completion_without_tic
def stepCheckCatalogued(self, sequence=None, def stepCheckCatalogued(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Check that order is catalogued Check that order is catalogued
...@@ -1010,10 +1010,10 @@ class TestOrderMixin: ...@@ -1010,10 +1010,10 @@ class TestOrderMixin:
result = sql_connection.manage_test(sql) result = sql_connection.manage_test(sql)
simulation_state_list = [x['simulation_state'] for x in result] simulation_state_list = [x['simulation_state'] for x in result]
self.assertEquals(1, len(simulation_state_list)) self.assertEquals(1, len(simulation_state_list))
self.assertEquals(order.getSimulationState(), self.assertEquals(order.getSimulationState(),
simulation_state_list[0]) simulation_state_list[0])
def stepCheckCataloguedSimulation(self, sequence=None, def stepCheckCataloguedSimulation(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Check that simulation is catalogued Check that simulation is catalogued
...@@ -1027,7 +1027,7 @@ class TestOrderMixin: ...@@ -1027,7 +1027,7 @@ class TestOrderMixin:
result = sql_connection.manage_test(sql) result = sql_connection.manage_test(sql)
simulation_state_list = [x['simulation_state'] for x in result] simulation_state_list = [x['simulation_state'] for x in result]
self.assertEquals(1, len(simulation_state_list)) self.assertEquals(1, len(simulation_state_list))
self.assertEquals(order.getSimulationState(), self.assertEquals(order.getSimulationState(),
simulation_state_list[0]) simulation_state_list[0])
class TestOrder(TestOrderMixin, ERP5TypeTestCase): class TestOrder(TestOrderMixin, ERP5TypeTestCase):
...@@ -1883,7 +1883,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -1883,7 +1883,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
order_line = order.newContent(portal_type=self.order_line_portal_type) order_line = order.newContent(portal_type=self.order_line_portal_type)
self.assertEquals(1, len(order.getMovementList())) self.assertEquals(1, len(order.getMovementList()))
# If a sub line is created, its parent should not be considered # If a sub line is created, its parent should not be considered
# as a movement # as a movement
sub_order_line = order_line.newContent( sub_order_line = order_line.newContent(
portal_type=self.order_line_portal_type) portal_type=self.order_line_portal_type)
...@@ -1894,7 +1894,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -1894,7 +1894,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
portal_type=self.order_line_portal_type) portal_type=self.order_line_portal_type)
self.assertEquals(2, len(order.getMovementList())) self.assertEquals(2, len(order.getMovementList()))
# Create recursively sub lines, and check that the ovement number # Create recursively sub lines, and check that the ovement number
# is still the same. # is still the same.
for i in range(5): for i in range(5):
sub_order_line = sub_order_line.newContent( sub_order_line = sub_order_line.newContent(
...@@ -1930,7 +1930,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -1930,7 +1930,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
cell_key_list.sort() cell_key_list.sort()
for cell_key in cell_key_list: for cell_key in cell_key_list:
cell = sub_order_line.newCell(base_id=base_id, cell = sub_order_line.newCell(base_id=base_id,
portal_type=self.order_cell_portal_type, portal_type=self.order_cell_portal_type,
*cell_key) *cell_key)
self.assertEquals(2-1+len(cell_key_list), len(order.getMovementList())) self.assertEquals(2-1+len(cell_key_list), len(order.getMovementList()))
...@@ -1944,7 +1944,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -1944,7 +1944,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
cell_key_list.sort() cell_key_list.sort()
for cell_key in cell_key_list: for cell_key in cell_key_list:
cell = order_line.newCell(base_id=base_id, cell = order_line.newCell(base_id=base_id,
portal_type=self.order_cell_portal_type, portal_type=self.order_cell_portal_type,
*cell_key) *cell_key)
self.assertEquals(2-1+len(cell_key_list), len(order.getMovementList())) self.assertEquals(2-1+len(cell_key_list), len(order.getMovementList()))
...@@ -2002,7 +2002,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2002,7 +2002,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
cell_key = order_line.getCellKeyList(base_id=base_id)[0] cell_key = order_line.getCellKeyList(base_id=base_id)[0]
cell = order_line.newCell( cell = order_line.newCell(
base_id=base_id, base_id=base_id,
portal_type=self.order_cell_portal_type, portal_type=self.order_cell_portal_type,
*cell_key) *cell_key)
cell.edit(mapped_value_property_list=['price', 'quantity'], cell.edit(mapped_value_property_list=['price', 'quantity'],
price=3, quantity=4, price=3, quantity=4,
...@@ -2121,7 +2121,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2121,7 +2121,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
sub_cell_key = sub_order_line.getCellKeyList(base_id=base_id)[0] sub_cell_key = sub_order_line.getCellKeyList(base_id=base_id)[0]
sub_cell = sub_order_line.newCell( sub_cell = sub_order_line.newCell(
base_id=base_id, base_id=base_id,
portal_type=self.order_cell_portal_type, portal_type=self.order_cell_portal_type,
*cell_key) *cell_key)
sub_cell.edit(mapped_value_property_list=['price', 'quantity'], sub_cell.edit(mapped_value_property_list=['price', 'quantity'],
price=5, quantity=6, price=5, quantity=6,
...@@ -2220,7 +2220,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2220,7 +2220,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
title="Sub Order Line") title="Sub Order Line")
sequence.edit(order_line=order_line) sequence.edit(order_line=order_line)
def test_20_testHierarchicalOrderAppliedRuleGeneration(self, quiet=0, def test_20_testHierarchicalOrderAppliedRuleGeneration(self, quiet=0,
run=run_all_test): run=run_all_test):
""" """
Test generation and update of an hierarchical order applied rule. Test generation and update of an hierarchical order applied rule.
...@@ -2286,7 +2286,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2286,7 +2286,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def test_order_cell_getTotalPrice(self): def test_order_cell_getTotalPrice(self):
# test getTotalPrice and getTotalQuantity on a line with cells # test getTotalPrice and getTotalQuantity on a line with cells
# More precisely, it tests a previous bug where creating a line with # More precisely, it tests a previous bug where creating a line with
...@@ -2315,7 +2315,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2315,7 +2315,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
self.assertEquals(0, line.getTotalPrice()) self.assertEquals(0, line.getTotalPrice())
self.assertEquals(0, order.getTotalQuantity()) self.assertEquals(0, order.getTotalQuantity())
self.assertEquals(0, order.getTotalPrice()) self.assertEquals(0, order.getTotalPrice())
self.assertTrue(line.hasInRange('size/Baby', base_id='movement')) self.assertTrue(line.hasInRange('size/Baby', base_id='movement'))
cell_baby = line.newCell('size/Baby', base_id='movement', cell_baby = line.newCell('size/Baby', base_id='movement',
portal_type=self.order_cell_portal_type) portal_type=self.order_cell_portal_type)
...@@ -2408,7 +2408,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2408,7 +2408,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
order.confirm() order.confirm()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
odt = order.Order_viewAsODT() odt = order.Order_viewAsODT()
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator() odf_validator = Validator()
...@@ -2440,7 +2440,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2440,7 +2440,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
order.confirm() order.confirm()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
odt = order.Order_viewAsODT() odt = order.Order_viewAsODT()
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator() odf_validator = Validator()
...@@ -2477,7 +2477,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2477,7 +2477,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
order.confirm() order.confirm()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
odt = order.Order_viewAsODT() odt = order.Order_viewAsODT()
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator() odf_validator = Validator()
...@@ -2517,7 +2517,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2517,7 +2517,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
order.confirm() order.confirm()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
odt = order.Order_viewAsODT() odt = order.Order_viewAsODT()
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator() odf_validator = Validator()
...@@ -2559,7 +2559,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2559,7 +2559,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
order.confirm() order.confirm()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
odt = order.Order_viewAsODT() odt = order.Order_viewAsODT()
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator() odf_validator = Validator()
...@@ -2586,7 +2586,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2586,7 +2586,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
destination_section_value=client) destination_section_value=client)
line = order.newContent(portal_type=self.order_line_portal_type, line = order.newContent(portal_type=self.order_line_portal_type,
description='Content') description='Content')
if self.order_line_portal_type not in [x.getId() for x in if self.order_line_portal_type not in [x.getId() for x in
line.allowedContentTypes()]: line.allowedContentTypes()]:
return # skip this test if hierarchical orders are not available (eg. return # skip this test if hierarchical orders are not available (eg.
# for Purchase Order) # for Purchase Order)
...@@ -2598,7 +2598,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2598,7 +2598,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
order.confirm() order.confirm()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
odt = order.Order_viewAsODT() odt = order.Order_viewAsODT()
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator() odf_validator = Validator()
......
############################################################################## ##############################################################################
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
# #
# Copyright (c) 2008 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <lukasz.nowak@ventis.com.pl> # Łukasz Nowak <lukasz.nowak@ventis.com.pl>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -65,7 +65,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -65,7 +65,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
max_delay = 0.0 max_delay = 0.0
min_flow = 0.0 min_flow = 0.0
def stepClearActivities(self, sequence=None, sequence_list=None, def stepClearActivities(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
Clear activity tables Clear activity tables
...@@ -73,7 +73,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -73,7 +73,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
activity_tool = self.getPortal().portal_activities activity_tool = self.getPortal().portal_activities
activity_tool.manageClearActivities(keep=0) activity_tool.manageClearActivities(keep=0)
def stepSetMaxDelayOnResource(self, sequence=None, sequence_list=None, def stepSetMaxDelayOnResource(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
Sets max_delay on resource Sets max_delay on resource
...@@ -84,7 +84,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -84,7 +84,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
max_delay = self.max_delay, max_delay = self.max_delay,
) )
def stepSetMinFlowOnResource(self, sequence=None, sequence_list=None, def stepSetMinFlowOnResource(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
Sets min_flow on resource Sets min_flow on resource
...@@ -95,7 +95,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -95,7 +95,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
min_flow = self.min_flow, min_flow = self.min_flow,
) )
def stepFillOrderBuilder(self, sequence=None, sequence_list=None, def stepFillOrderBuilder(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
Fills Order Builder with proper quantites Fills Order Builder with proper quantites
...@@ -118,7 +118,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -118,7 +118,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
resource_portal_type = self.resource_portal_type, resource_portal_type = self.resource_portal_type,
) )
def stepCheckGeneratedDocumentListVariated(self, sequence=None, sequence_list=None, def stepCheckGeneratedDocumentListVariated(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
Checks documents generated by Order Builders with its properties for variated resource Checks documents generated by Order Builders with its properties for variated resource
...@@ -133,9 +133,9 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -133,9 +133,9 @@ class TestOrderBuilderMixin(TestOrderMixin):
1, # XXX 1, # XXX
len(generated_document_list) len(generated_document_list)
) )
order = generated_document_list[0] order = generated_document_list[0]
self.assertEquals( self.assertEquals(
order.getDestinationValue(), order.getDestinationValue(),
organisation organisation
...@@ -174,7 +174,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -174,7 +174,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
len(order_cell_list), len(order_cell_list),
len(self.wanted_quantity_matrix.itervalues()) len(self.wanted_quantity_matrix.itervalues())
) )
for order_cell in order_cell_list: for order_cell in order_cell_list:
self.assertEquals( self.assertEquals(
order_cell.getQuantity(), order_cell.getQuantity(),
...@@ -183,7 +183,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -183,7 +183,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
] ]
) )
def stepCheckGeneratedDocumentList(self, sequence=None, sequence_list=None, def stepCheckGeneratedDocumentList(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
Checks documents generated by Order Builders with its properties Checks documents generated by Order Builders with its properties
...@@ -198,9 +198,9 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -198,9 +198,9 @@ class TestOrderBuilderMixin(TestOrderMixin):
1, # XXX 1, # XXX
len(generated_document_list) len(generated_document_list)
) )
order = generated_document_list[0] order = generated_document_list[0]
self.assertEquals( self.assertEquals(
order.getDestinationValue(), order.getDestinationValue(),
organisation organisation
...@@ -233,8 +233,8 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -233,8 +233,8 @@ class TestOrderBuilderMixin(TestOrderMixin):
order_line.getTotalQuantity(), order_line.getTotalQuantity(),
self.wanted_quantity self.wanted_quantity
) )
def stepBuildOrderBuilder(self, sequence=None, sequence_list=None, def stepBuildOrderBuilder(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
Invokes build method for Order Builder Invokes build method for Order Builder
...@@ -243,7 +243,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -243,7 +243,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
generated_document_list = order_builder.build() generated_document_list = order_builder.build()
sequence.edit(generated_document_list = generated_document_list) sequence.edit(generated_document_list = generated_document_list)
def stepCreateOrderBuilder(self, sequence=None, sequence_list=None, def stepCreateOrderBuilder(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
Creates empty Order Builder Creates empty Order Builder
...@@ -258,7 +258,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -258,7 +258,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
order_builder = order_builder order_builder = order_builder
) )
def stepDecreaseOrganisationResourceQuantityVariated(self, sequence=None, sequence_list=None, def stepDecreaseOrganisationResourceQuantityVariated(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
Creates movement with variation from organisation to None. Creates movement with variation from organisation to None.
...@@ -268,7 +268,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -268,7 +268,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
""" """
organisation = sequence.get('organisation') organisation = sequence.get('organisation')
resource = sequence.get('resource') resource = sequence.get('resource')
packing_list_module = self.portal.getDefaultModule( packing_list_module = self.portal.getDefaultModule(
portal_type = self.packing_list_portal_type portal_type = self.packing_list_portal_type
) )
...@@ -288,7 +288,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -288,7 +288,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
packing_list_line.setVariationCategoryList( packing_list_line.setVariationCategoryList(
list(self.decrease_quantity_matrix.iterkeys()) list(self.decrease_quantity_matrix.iterkeys())
) )
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
...@@ -306,7 +306,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -306,7 +306,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
packing_list.confirm() packing_list.confirm()
def stepDecreaseOrganisationResourceQuantity(self, sequence=None, sequence_list=None, def stepDecreaseOrganisationResourceQuantity(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
Creates movement from organisation to None. Creates movement from organisation to None.
...@@ -316,7 +316,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -316,7 +316,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
""" """
organisation = sequence.get('organisation') organisation = sequence.get('organisation')
resource = sequence.get('resource') resource = sequence.get('resource')
packing_list_module = self.portal.getDefaultModule( packing_list_module = self.portal.getDefaultModule(
portal_type = self.packing_list_portal_type portal_type = self.packing_list_portal_type
) )
...@@ -334,7 +334,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -334,7 +334,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
) )
packing_list.confirm() packing_list.confirm()
class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
""" """
Test Order Builder functionality Test Order Builder functionality
...@@ -369,10 +369,10 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -369,10 +369,10 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
self.wanted_quantity = 1.0 self.wanted_quantity = 1.0
self.wanted_start_date = self.datetime.earliestTime() \ self.wanted_start_date = self.datetime.earliestTime() \
+ self.order_builder_hardcoded_time_diff + self.order_builder_hardcoded_time_diff
self.wanted_stop_date = self.datetime.earliestTime() \ self.wanted_stop_date = self.datetime.earliestTime() \
+ self.order_builder_hardcoded_time_diff + self.order_builder_hardcoded_time_diff
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_list.addSequenceString(self.common_sequence_string) sequence_list.addSequenceString(self.common_sequence_string)
...@@ -403,10 +403,10 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -403,10 +403,10 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
self.wanted_quantity = 1.0 self.wanted_quantity = 1.0
self.wanted_start_date = self.datetime.earliestTime() \ self.wanted_start_date = self.datetime.earliestTime() \
+ self.order_builder_hardcoded_time_diff + self.order_builder_hardcoded_time_diff
self.wanted_stop_date = self.datetime.earliestTime() \ self.wanted_stop_date = self.datetime.earliestTime() \
+ self.order_builder_hardcoded_time_diff + self.order_builder_hardcoded_time_diff
self.decrease_quantity_matrix = { self.decrease_quantity_matrix = {
'size/Man' : 1.0, 'size/Man' : 1.0,
...@@ -430,10 +430,10 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -430,10 +430,10 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
self.wanted_quantity = 1.0 self.wanted_quantity = 1.0
self.wanted_start_date = self.datetime.earliestTime() \ self.wanted_start_date = self.datetime.earliestTime() \
- self.max_delay \ - self.max_delay \
+ self.order_builder_hardcoded_time_diff + self.order_builder_hardcoded_time_diff
self.wanted_stop_date = self.datetime.earliestTime() \ self.wanted_stop_date = self.datetime.earliestTime() \
+ self.order_builder_hardcoded_time_diff + self.order_builder_hardcoded_time_diff
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_list.addSequenceString(self.common_sequence_string) sequence_list.addSequenceString(self.common_sequence_string)
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2004, 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2004-2008 Nexedi SA and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com> # Sebastien Robin <seb@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -35,7 +35,7 @@ from testOrder import TestOrderMixin ...@@ -35,7 +35,7 @@ from testOrder import TestOrderMixin
class TestPackingListMixin(TestOrderMixin): class TestPackingListMixin(TestOrderMixin):
""" """
Test business template erp5_trade Test business template erp5_trade
""" """
container_portal_type = 'Container' container_portal_type = 'Container'
container_line_portal_type = 'Container Line' container_line_portal_type = 'Container Line'
...@@ -126,7 +126,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -126,7 +126,7 @@ class TestPackingListMixin(TestOrderMixin):
def enableLightInstall(self): def enableLightInstall(self):
""" """
You can override this. You can override this.
Return if we should do a light install (1) or not (0) Return if we should do a light install (1) or not (0)
""" """
return 1 return 1
...@@ -160,7 +160,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -160,7 +160,7 @@ class TestPackingListMixin(TestOrderMixin):
self.assertEquals(packing_list.getPriceCurrency(), \ self.assertEquals(packing_list.getPriceCurrency(), \
order.getPriceCurrency()) order.getPriceCurrency())
def stepCheckPackingListIsDivergent(self, sequence=None, sequence_list=None, def stepCheckPackingListIsDivergent(self, sequence=None, sequence_list=None,
packing_list=None,**kw): packing_list=None,**kw):
""" """
Test if packing list is divergent Test if packing list is divergent
...@@ -206,7 +206,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -206,7 +206,7 @@ class TestPackingListMixin(TestOrderMixin):
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
self.assertFalse(packing_list.isDivergent()) self.assertFalse(packing_list.isDivergent())
def stepChangePackingListLineResource(self, sequence=None, def stepChangePackingListLineResource(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Change the resource of the packing list. Change the resource of the packing list.
...@@ -344,7 +344,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -344,7 +344,7 @@ class TestPackingListMixin(TestOrderMixin):
self.assertEquals(self.default_quantity, self.assertEquals(self.default_quantity,
simulation_movement.getCorrectedQuantity()) simulation_movement.getCorrectedQuantity())
def stepChangePackingListDestination(self, sequence=None, def stepChangePackingListDestination(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Test if packing list is divergent Test if packing list is divergent
...@@ -453,7 +453,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -453,7 +453,7 @@ class TestPackingListMixin(TestOrderMixin):
packing_list_line = sequence.get('packing_list_line') packing_list_line = sequence.get('packing_list_line')
for simulation_line in simulation_line_list: for simulation_line in simulation_line_list:
self.assertEquals(simulation_line.getDeliveryValue(),packing_list_line) self.assertEquals(simulation_line.getDeliveryValue(),packing_list_line)
self.assertEquals(packing_list_line.getCausalityValue(), self.assertEquals(packing_list_line.getCausalityValue(),
simulation_line.getOrderValue()) simulation_line.getOrderValue())
def stepCheckSimulationDisconnected(self,sequence=None, sequence_list=None, **kw): def stepCheckSimulationDisconnected(self,sequence=None, sequence_list=None, **kw):
...@@ -497,7 +497,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -497,7 +497,7 @@ class TestPackingListMixin(TestOrderMixin):
for simulation_line in simulation_line_list: for simulation_line in simulation_line_list:
simulation_line.edit(start_date=self.datetime+15) simulation_line.edit(start_date=self.datetime+15)
def stepAdoptPrevision(self,sequence=None, sequence_list=None, def stepAdoptPrevision(self,sequence=None, sequence_list=None,
packing_list=None,**kw): packing_list=None,**kw):
""" """
Check if simulation movement are disconnected Check if simulation movement are disconnected
...@@ -560,7 +560,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -560,7 +560,7 @@ class TestPackingListMixin(TestOrderMixin):
# self.assertNotEquals(new_packing_list.getUid(),packing_list.getUid()) # self.assertNotEquals(new_packing_list.getUid(),packing_list.getUid())
self.assertEquals(len(delivery_value_list),len(resource_list)) self.assertEquals(len(delivery_value_list),len(resource_list))
def stepAddPackingListContainer(self,sequence=None, def stepAddPackingListContainer(self,sequence=None,
packing_list=None,sequence_list=None, **kw): packing_list=None,sequence_list=None, **kw):
""" """
Check if simulation movement are disconnected Check if simulation movement are disconnected
...@@ -596,7 +596,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -596,7 +596,7 @@ class TestPackingListMixin(TestOrderMixin):
container_line = sequence.get('container_line') container_line = sequence.get('container_line')
container_line.edit(quantity=self.default_quantity-1) container_line.edit(quantity=self.default_quantity-1)
def stepSetContainerLineFullQuantity(self,sequence=None, sequence_list=None, def stepSetContainerLineFullQuantity(self,sequence=None, sequence_list=None,
quantity=None,**kw): quantity=None,**kw):
""" """
Check if simulation movement are disconnected Check if simulation movement are disconnected
...@@ -607,7 +607,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -607,7 +607,7 @@ class TestPackingListMixin(TestOrderMixin):
container_line.edit(quantity=quantity) container_line.edit(quantity=quantity)
container_line.immediateReindexObject() container_line.immediateReindexObject()
def stepSetContainerFullQuantity(self,sequence=None, sequence_list=None, def stepSetContainerFullQuantity(self,sequence=None, sequence_list=None,
quantity=None,**kw): quantity=None,**kw):
""" """
Really fills the container Really fills the container
...@@ -657,7 +657,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -657,7 +657,7 @@ class TestPackingListMixin(TestOrderMixin):
self.assertEquals(0,packing_list.isPacked()) self.assertEquals(0,packing_list.isPacked())
self.assertEquals('missing',packing_list.getContainerState()) self.assertEquals('missing',packing_list.getContainerState())
def stepCheckPackingListIsPacked(self,sequence=None, sequence_list=None, def stepCheckPackingListIsPacked(self,sequence=None, sequence_list=None,
packing_list=None,**kw): packing_list=None,**kw):
""" """
Check that the number of objects in containers are Check that the number of objects in containers are
...@@ -690,7 +690,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -690,7 +690,7 @@ class TestPackingListMixin(TestOrderMixin):
else: else:
currency = currency_module._getOb('EUR') currency = currency_module._getOb('EUR')
sequence.edit(currency=currency) sequence.edit(currency=currency)
def stepSetOrderPriceCurrency(self, sequence, **kw) : def stepSetOrderPriceCurrency(self, sequence, **kw) :
"""Set the price currency of the order. """Set the price currency of the order.
...@@ -703,7 +703,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -703,7 +703,7 @@ class TestPackingListMixin(TestOrderMixin):
order.setPriceCurrency(currency.getRelativeUrl()) order.setPriceCurrency(currency.getRelativeUrl())
class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
run_all_test = 1 run_all_test = 1
...@@ -940,7 +940,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -940,7 +940,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
' '
# XXX Check if there is a new packing list created # XXX Check if there is a new packing list created
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def test_10_PackingListIncreaseQuantity(self, quiet=quiet, run=run_all_test): def test_10_PackingListIncreaseQuantity(self, quiet=quiet, run=run_all_test):
...@@ -1037,7 +1037,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -1037,7 +1037,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
pl = self.getPortal().getDefaultModule(self.packing_list_portal_type pl = self.getPortal().getDefaultModule(self.packing_list_portal_type
).newContent(portal_type=self.packing_list_portal_type) ).newContent(portal_type=self.packing_list_portal_type)
self.failUnless(hasattr(pl, 'getPriceCurrency')) self.failUnless(hasattr(pl, 'getPriceCurrency'))
def test_PackingList_viewAsODT(self): def test_PackingList_viewAsODT(self):
# tests packing list printout # tests packing list printout
resource = self.portal.getDefaultModule( resource = self.portal.getDefaultModule(
...@@ -1063,14 +1063,14 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -1063,14 +1063,14 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
packing_list.confirm() packing_list.confirm()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
odt = packing_list.PackingList_viewAsODT() odt = packing_list.PackingList_viewAsODT()
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator() odf_validator = Validator()
err_list = odf_validator.validate(odt) err_list = odf_validator.validate(odt)
if err_list: if err_list:
self.fail(''.join(err_list)) self.fail(''.join(err_list))
class TestPurchasePackingListMixin(TestPackingListMixin): class TestPurchasePackingListMixin(TestPackingListMixin):
"""Mixing class with steps to test purchase packing lists. """Mixing class with steps to test purchase packing lists.
...@@ -1085,7 +1085,7 @@ class TestPurchasePackingListMixin(TestPackingListMixin): ...@@ -1085,7 +1085,7 @@ class TestPurchasePackingListMixin(TestPackingListMixin):
container_portal_type = None container_portal_type = None
container_line_portal_type = None container_line_portal_type = None
container_cell_portal_type = None container_cell_portal_type = None
# all steps related to packing and container does not apply on purchase # all steps related to packing and container does not apply on purchase
def ignored_step(self, **kw): def ignored_step(self, **kw):
return return
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2007 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Fabien Morin <fabien.morin@gmail.com> # Fabien Morin <fabien.morin@gmail.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -30,17 +30,17 @@ ...@@ -30,17 +30,17 @@
TODO: TODO:
- review naming of new methods - review naming of new methods
- in the test test_04_paySheetCalculation, add sub_object (annotation_line, - in the test test_04_paySheetCalculation, add sub_object (annotation_line,
ratio_line and payment conditioni), and verify that before the script ratio_line and payment conditioni), and verify that before the script
'PaySheetTransaction_applyModel' is called, subobjects are not in the 'PaySheetTransaction_applyModel' is called, subobjects are not in the
paysheet, and after that there are copied in. paysheet, and after that there are copied in.
- use ratio settings and test it (there is a method getRatioQuantityList, see - use ratio settings and test it (there is a method getRatioQuantityList, see
the file Document/PaySheetTransaction.py) the file Document/PaySheetTransaction.py)
- test with bonus which participate on the base_salary and see if the - test with bonus which participate on the base_salary and see if the
contribution are applied on the real base_salary or on the base_salary + bonus contribution are applied on the real base_salary or on the base_salary + bonus
(it should). (it should).
WARNING: WARNING:
- current API naming may change although model should be stable. - current API naming may change although model should be stable.
""" """
...@@ -402,7 +402,7 @@ class TestPayrollMixin(ERP5ReportTestCase): ...@@ -402,7 +402,7 @@ class TestPayrollMixin(ERP5ReportTestCase):
values = [[[1000, 1], [1000, 1]], [[2000, None], [None, 0.5]]] values = [[[1000, 1], [1000, 1]], [[2000, None], [None, 0.5]]]
next, two representations to well understand : next, two representations to well understand :
'employee_share', 'employer_share' 'employee_share', 'employer_share'
[[ 1470, None ], [ 2100, None ]] [[ 1470, None ], [ 2100, None ]]
'salary_range/france/forfait' 'salary_range/france/forfait'
...@@ -411,7 +411,7 @@ class TestPayrollMixin(ERP5ReportTestCase): ...@@ -411,7 +411,7 @@ class TestPayrollMixin(ERP5ReportTestCase):
[ [ None, 0.01 ], [ None, 0.02 ],[ None, 0.01 ], [ None, 0.02 ] ] [ [ None, 0.01 ], [ None, 0.02 ],[ None, 0.01 ], [ None, 0.02 ] ]
'salary_range/france/tranche_a''salary_range/france/tranche_b' 'salary_range/france/tranche_a''salary_range/france/tranche_b'
''' '''
# verify if category used in this model line are selected in the resource # verify if category used in this model line are selected in the resource
resource_list = resource.getVariationCategoryList(base=1) resource_list = resource.getVariationCategoryList(base=1)
msg='%r != %r' % (resource_list, variation_category_list) msg='%r != %r' % (resource_list, variation_category_list)
...@@ -517,7 +517,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -517,7 +517,7 @@ class TestPayroll(TestPayrollMixin):
if hasattr(self.paysheet_model_module, self.model_id): if hasattr(self.paysheet_model_module, self.model_id):
self.paysheet_model_module.manage_delObjects([self.model_id]) self.paysheet_model_module.manage_delObjects([self.model_id])
model_count_before_add = \ model_count_before_add = \
len(self.paysheet_model_module.contentValues(portal_type=\ len(self.paysheet_model_module.contentValues(portal_type=\
self.paysheet_model_portal_type)) self.paysheet_model_portal_type))
...@@ -745,7 +745,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -745,7 +745,7 @@ class TestPayroll(TestPayrollMixin):
self.assertEqual(paysheet_line_count_before_calculation, 0) self.assertEqual(paysheet_line_count_before_calculation, 0)
self.assertEqual(paysheet_line_count_after_calculation, self.assertEqual(paysheet_line_count_after_calculation,
pay_sheet_line_count) pay_sheet_line_count)
# check the amount in the cells of the created paysheet lines # check the amount in the cells of the created paysheet lines
for pay_sheet_line in pay_sheet_line_list: for pay_sheet_line in pay_sheet_line_list:
service = pay_sheet_line.getResourceId() service = pay_sheet_line.getResourceId()
...@@ -777,10 +777,10 @@ class TestPayroll(TestPayrollMixin): ...@@ -777,10 +777,10 @@ class TestPayroll(TestPayrollMixin):
- a model can have some DATA's - a model can have some DATA's
- a model can inherite from another, that's mean : - a model can inherite from another, that's mean :
o At the calculation step, each DATA of the parent model will be o At the calculation step, each DATA of the parent model will be
checked : the DATA with a REFERENCE that's already in the child checked : the DATA with a REFERENCE that's already in the child
model will not entered in the calcul. The other will. model will not entered in the calcul. The other will.
o This will be repeated on each parent model and on each parent of o This will be repeated on each parent model and on each parent of
the parent model,... until there is no parent model to inherite the parent model,... until there is no parent model to inherite
(or until a max loop number has been reached). (or until a max loop number has been reached).
''' '''
# create 3 models # create 3 models
...@@ -939,7 +939,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -939,7 +939,7 @@ class TestPayroll(TestPayrollMixin):
self.assertEqual(len(number_of_different_references), 11) # here, there is self.assertEqual(len(number_of_different_references), 11) # here, there is
# 8 differents annotation lines, and with the 3 ones have been had before # 8 differents annotation lines, and with the 3 ones have been had before
# that's make 11 ! # that's make 11 !
# check the model number # check the model number
self.assertEqual(len(model_reference_dict), 6) # there is 7 model, but the self.assertEqual(len(model_reference_dict), 6) # there is 7 model, but the
# model_d is not take into account because it have no annotation line wich # model_d is not take into account because it have no annotation line wich
...@@ -1001,7 +1001,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1001,7 +1001,7 @@ class TestPayroll(TestPayrollMixin):
# get a list of all this subObjects: # get a list of all this subObjects:
sub_object_list = paysheet.getInheritedObjectValueList(portal_type_list) sub_object_list = paysheet.getInheritedObjectValueList(portal_type_list)
self.assertEqual(len(sub_object_list), 11) self.assertEqual(len(sub_object_list), 11)
def test_07_model_getCell(self): def test_07_model_getCell(self):
''' '''
Model objects have a overload method called getCell. This method first Model objects have a overload method called getCell. This method first
...@@ -1049,7 +1049,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1049,7 +1049,7 @@ class TestPayroll(TestPayrollMixin):
self.addSlice(model_country, 'salary_range/%s' % \ self.addSlice(model_country, 'salary_range/%s' % \
self.france_settings_slice_c, 4, 5) self.france_settings_slice_c, 4, 5)
# inherite from each other # inherite from each other
model_employee.setSpecialiseValueList((model_company, model_company_alt)) model_employee.setSpecialiseValueList((model_company, model_company_alt))
model_company.setSpecialiseValue(model_country) model_company.setSpecialiseValue(model_country)
...@@ -1143,7 +1143,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1143,7 +1143,7 @@ class TestPayroll(TestPayrollMixin):
base_id='cell') base_id='cell')
cell.setQuantityRangeMin(1) cell.setQuantityRangeMin(1)
cell.setQuantityRangeMax(2) cell.setQuantityRangeMax(2)
# model 2 gets cell values from model 1 (see test_07_model_getCell) # model 2 gets cell values from model 1 (see test_07_model_getCell)
self.assertEquals(1, self.assertEquals(1,
model_2.getCell('salary_range/france/tranche_a').getQuantityRangeMin()) model_2.getCell('salary_range/france/tranche_a').getQuantityRangeMin())
...@@ -1198,7 +1198,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1198,7 +1198,7 @@ class TestPayroll(TestPayrollMixin):
cell1.setVariationCategoryList(('tax_category/employer_share',)) cell1.setVariationCategoryList(('tax_category/employer_share',))
cell1.setPrice(4) cell1.setPrice(4)
cell1.setQuantity(5) cell1.setQuantity(5)
movement_list = pay_sheet.PaySheetTransaction_getMovementList() movement_list = pay_sheet.PaySheetTransaction_getMovementList()
self.assertEquals(1, len(movement_list)) self.assertEquals(1, len(movement_list))
movement = movement_list[0] movement = movement_list[0]
...@@ -1229,7 +1229,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1229,7 +1229,7 @@ class TestPayroll(TestPayrollMixin):
cell.setPrice(1) cell.setPrice(1)
pay_sheet = self.createPaySheet(self.model) pay_sheet = self.createPaySheet(self.model)
# PaySheetTransaction_getEditableObjectLineList is the script used as list # PaySheetTransaction_getEditableObjectLineList is the script used as list
# method to display editable lines in the dialog listbox # method to display editable lines in the dialog listbox
editable_line_list = pay_sheet\ editable_line_list = pay_sheet\
...@@ -1241,7 +1241,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1241,7 +1241,7 @@ class TestPayroll(TestPayrollMixin):
self.assertEquals('paysheet_model_module/model_one/line', self.assertEquals('paysheet_model_module/model_one/line',
editable_line.model_line) editable_line.model_line)
self.assertEquals(None, editable_line.salary_range_relative_url) self.assertEquals(None, editable_line.salary_range_relative_url)
# PaySheetTransaction_createAllPaySheetLineList is the script used to create line and cells in the # PaySheetTransaction_createAllPaySheetLineList is the script used to create line and cells in the
# paysheet using the listbox input # paysheet using the listbox input
pay_sheet.PaySheetTransaction_createAllPaySheetLineList( pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
...@@ -1259,7 +1259,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1259,7 +1259,7 @@ class TestPayroll(TestPayrollMixin):
self.assertNotEquals(None, cell) self.assertNotEquals(None, cell)
self.assertEquals(1, cell.getPrice()) self.assertEquals(1, cell.getPrice())
self.assertEquals(2, cell.getQuantity()) self.assertEquals(2, cell.getQuantity())
# if the script is called again, previous content is erased. # if the script is called again, previous content is erased.
pay_sheet.PaySheetTransaction_createAllPaySheetLineList( pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
listbox=[dict(listbox_key='0', listbox=[dict(listbox_key='0',
...@@ -1276,7 +1276,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1276,7 +1276,7 @@ class TestPayroll(TestPayrollMixin):
self.assertNotEquals(None, cell) self.assertNotEquals(None, cell)
self.assertEquals(0.5, cell.getPrice()) self.assertEquals(0.5, cell.getPrice())
self.assertEquals(10, cell.getQuantity()) self.assertEquals(10, cell.getQuantity())
# If the user enters a null quantity, the line will not be created # If the user enters a null quantity, the line will not be created
pay_sheet.PaySheetTransaction_createAllPaySheetLineList( pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
listbox=[dict(listbox_key='0', listbox=[dict(listbox_key='0',
...@@ -1326,7 +1326,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1326,7 +1326,7 @@ class TestPayroll(TestPayrollMixin):
cell.setPrice(1) cell.setPrice(1)
pay_sheet = self.createPaySheet(self.model) pay_sheet = self.createPaySheet(self.model)
# PaySheetTransaction_getEditableObjectLineList is the script used as list # PaySheetTransaction_getEditableObjectLineList is the script used as list
# method to display editable lines in the dialog listbox # method to display editable lines in the dialog listbox
editable_line_list = pay_sheet\ editable_line_list = pay_sheet\
...@@ -1338,7 +1338,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1338,7 +1338,7 @@ class TestPayroll(TestPayrollMixin):
self.assertEquals('paysheet_model_module/model_one/line2', self.assertEquals('paysheet_model_module/model_one/line2',
editable_line.model_line) editable_line.model_line)
self.assertEquals(None, editable_line.salary_range_relative_url) self.assertEquals(None, editable_line.salary_range_relative_url)
# PaySheetTransaction_createAllPaySheetLineList is the script used to create line and cells in the # PaySheetTransaction_createAllPaySheetLineList is the script used to create line and cells in the
# paysheet using the listbox input # paysheet using the listbox input
pay_sheet.PaySheetTransaction_createAllPaySheetLineList( pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
...@@ -1357,7 +1357,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1357,7 +1357,7 @@ class TestPayroll(TestPayrollMixin):
self.assertNotEquals(None, cell) self.assertNotEquals(None, cell)
self.assertEquals(1, cell.getPrice()) self.assertEquals(1, cell.getPrice())
self.assertEquals(100, cell.getQuantity()) self.assertEquals(100, cell.getQuantity())
pay_sheet_line2 = [l for l in pay_sheet_line_list pay_sheet_line2 = [l for l in pay_sheet_line_list
if l.getIntIndex() == 2][0] if l.getIntIndex() == 2][0]
self.assertEquals(self.labour, pay_sheet_line2.getResourceValue()) self.assertEquals(self.labour, pay_sheet_line2.getResourceValue())
...@@ -1384,7 +1384,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1384,7 +1384,7 @@ class TestPayroll(TestPayrollMixin):
self.assertNotEquals(None, cell) self.assertNotEquals(None, cell)
self.assertEquals(1, cell.getPrice()) self.assertEquals(1, cell.getPrice())
self.assertEquals(100, cell.getQuantity()) self.assertEquals(100, cell.getQuantity())
pay_sheet_line2 = [l for l in pay_sheet_line_list pay_sheet_line2 = [l for l in pay_sheet_line_list
if l.getIntIndex() == 2][0] if l.getIntIndex() == 2][0]
self.assertEquals(self.labour, pay_sheet_line2.getResourceValue()) self.assertEquals(self.labour, pay_sheet_line2.getResourceValue())
...@@ -1393,7 +1393,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1393,7 +1393,7 @@ class TestPayroll(TestPayrollMixin):
self.assertNotEquals(None, cell) self.assertNotEquals(None, cell)
self.assertEquals(0.6, cell.getPrice()) self.assertEquals(0.6, cell.getPrice())
self.assertEquals(10, cell.getQuantity()) self.assertEquals(10, cell.getQuantity())
# If the user enters a null quantity, the line will not be created # If the user enters a null quantity, the line will not be created
pay_sheet.PaySheetTransaction_createAllPaySheetLineList( pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
listbox=[dict(listbox_key='0', listbox=[dict(listbox_key='0',
...@@ -1429,7 +1429,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1429,7 +1429,7 @@ class TestPayroll(TestPayrollMixin):
cell.setQuantity(5) cell.setQuantity(5)
pay_sheet = self.createPaySheet(self.model) pay_sheet = self.createPaySheet(self.model)
pay_sheet.PaySheetTransaction_createAllPaySheetLineList() pay_sheet.PaySheetTransaction_createAllPaySheetLineList()
pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line') pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(1, len(pay_sheet_line_list)) self.assertEquals(1, len(pay_sheet_line_list))
...@@ -1440,7 +1440,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1440,7 +1440,7 @@ class TestPayroll(TestPayrollMixin):
self.assertNotEquals(None, cell) self.assertNotEquals(None, cell)
self.assertEquals(1, cell.getPrice()) self.assertEquals(1, cell.getPrice())
self.assertEquals(5, cell.getQuantity()) self.assertEquals(5, cell.getQuantity())
def test_createPaySheetLineZeroPrice(self): def test_createPaySheetLineZeroPrice(self):
# test the creation of lines when the price is set to zero: the line should # test the creation of lines when the price is set to zero: the line should
# not be created. # not be created.
...@@ -1459,11 +1459,11 @@ class TestPayroll(TestPayrollMixin): ...@@ -1459,11 +1459,11 @@ class TestPayroll(TestPayrollMixin):
cell.setPrice(0) cell.setPrice(0)
pay_sheet = self.createPaySheet(self.model) pay_sheet = self.createPaySheet(self.model)
pay_sheet.PaySheetTransaction_createAllPaySheetLineList() pay_sheet.PaySheetTransaction_createAllPaySheetLineList()
pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line') pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(0, len(pay_sheet_line_list)) self.assertEquals(0, len(pay_sheet_line_list))
def test_paysheet_consistency(self): def test_paysheet_consistency(self):
# minimal test for checkConsistency on a Pay Sheet Transaction and its # minimal test for checkConsistency on a Pay Sheet Transaction and its
# subdocuments (may have to be updated when we'll add more constraints). # subdocuments (may have to be updated when we'll add more constraints).
...@@ -1475,7 +1475,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1475,7 +1475,7 @@ class TestPayroll(TestPayrollMixin):
paysheet.newContent(portal_type='Pay Sheet Model Ratio Line') paysheet.newContent(portal_type='Pay Sheet Model Ratio Line')
paysheet.newContent(portal_type='Payment Condition') paysheet.newContent(portal_type='Payment Condition')
self.assertEquals([], paysheet.checkConsistency()) self.assertEquals([], paysheet.checkConsistency())
def test_paysheet_model_consistency(self): def test_paysheet_model_consistency(self):
# minimal test for checkConsistency on a Pay Sheet Model and its # minimal test for checkConsistency on a Pay Sheet Model and its
# subdocuments (may have to be updated when we'll add more constraints). # subdocuments (may have to be updated when we'll add more constraints).
...@@ -1520,7 +1520,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1520,7 +1520,7 @@ class TestPayroll(TestPayrollMixin):
paysheet = self.portal.accounting_module.newContent( paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=model) specialise_value=model)
paysheet.PaySheetTransaction_applyModel() paysheet.PaySheetTransaction_applyModel()
self.assertEquals(employee, paysheet.getSourceSectionValue()) self.assertEquals(employee, paysheet.getSourceSectionValue())
self.assertEquals(employer, paysheet.getDestinationSectionValue()) self.assertEquals(employer, paysheet.getDestinationSectionValue())
...@@ -1544,7 +1544,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1544,7 +1544,7 @@ class TestPayroll(TestPayrollMixin):
paysheet = self.portal.accounting_module.newContent( paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=other_model) specialise_value=other_model)
paysheet.PaySheetTransaction_applyModel() paysheet.PaySheetTransaction_applyModel()
self.assertEquals(employee, paysheet.getSourceSectionValue()) self.assertEquals(employee, paysheet.getSourceSectionValue())
self.assertEquals(employer, paysheet.getDestinationSectionValue()) self.assertEquals(employer, paysheet.getDestinationSectionValue())
...@@ -1583,7 +1583,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1583,7 +1583,7 @@ class TestPayroll(TestPayrollMixin):
paysheet = self.portal.accounting_module.newContent( paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=employee_model) specialise_value=employee_model)
paysheet.PaySheetTransaction_applyModel() paysheet.PaySheetTransaction_applyModel()
self.assertEquals(employee, paysheet.getSourceSectionValue()) self.assertEquals(employee, paysheet.getSourceSectionValue())
self.assertEquals(employer, paysheet.getDestinationSectionValue()) self.assertEquals(employer, paysheet.getDestinationSectionValue())
...@@ -1639,7 +1639,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1639,7 +1639,7 @@ class TestPayroll(TestPayrollMixin):
paysheet = self.portal.accounting_module.newContent( paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=model) specialise_value=model)
paysheet.PaySheetTransaction_applyModel() paysheet.PaySheetTransaction_applyModel()
paysheet.createPaySheetLineList() paysheet.createPaySheetLineList()
paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line') paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
...@@ -1653,7 +1653,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1653,7 +1653,7 @@ class TestPayroll(TestPayrollMixin):
self.assertEquals(['tax_category/employee_share'], self.assertEquals(['tax_category/employee_share'],
paysheet_line.getVariationCategoryList()) paysheet_line.getVariationCategoryList())
def test_PayrollTaxesReport(self): def test_PayrollTaxesReport(self):
eur = self.portal.currency_module.EUR eur = self.portal.currency_module.EUR
payroll_service = self.portal.payroll_service_module.newContent( payroll_service = self.portal.payroll_service_module.newContent(
...@@ -1760,19 +1760,19 @@ class TestPayroll(TestPayrollMixin): ...@@ -1760,19 +1760,19 @@ class TestPayroll(TestPayrollMixin):
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
# set request variables and render # set request variables and render
request_form = self.portal.REQUEST request_form = self.portal.REQUEST
request_form['at_date'] = DateTime(2006, 2, 2) request_form['at_date'] = DateTime(2006, 2, 2)
request_form['section_category'] = 'group/demo_group' request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['draft', 'planned'] request_form['simulation_state'] = ['draft', 'planned']
request_form['resource'] = payroll_service.getRelativeUrl() request_form['resource'] = payroll_service.getRelativeUrl()
request_form['mirror_section'] = provider.getRelativeUrl() request_form['mirror_section'] = provider.getRelativeUrl()
report_section_list = self.getReportSectionList( report_section_list = self.getReportSectionList(
self.portal.accounting_module, self.portal.accounting_module,
'AccountingTransactionModule_viewPaySheetLineReport') 'AccountingTransactionModule_viewPaySheetLineReport')
self.assertEquals(1, len(report_section_list)) self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0]) line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()] data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(2, len(data_line_list)) self.assertEquals(2, len(data_line_list))
...@@ -1781,7 +1781,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1781,7 +1781,7 @@ class TestPayroll(TestPayrollMixin):
# precision is 3 # precision is 3
precision = self.portal.REQUEST.get('precision') precision = self.portal.REQUEST.get('precision')
self.assertEquals(3, precision) self.assertEquals(3, precision)
self.checkLineProperties(data_line_list[0], self.checkLineProperties(data_line_list[0],
id=1, id=1,
employee_career_reference='E1', employee_career_reference='E1',
...@@ -1798,14 +1798,14 @@ class TestPayroll(TestPayrollMixin): ...@@ -1798,14 +1798,14 @@ class TestPayroll(TestPayrollMixin):
employee_share=3000 * .50, employee_share=3000 * .50,
employer_share=3000 * .40, employer_share=3000 * .40,
total=(3000 * .50 + 3000 * .40)) total=(3000 * .50 + 3000 * .40))
# stat line # stat line
self.checkLineProperties(line_list[-1], self.checkLineProperties(line_list[-1],
base=3000 + 2000, base=3000 + 2000,
employee_share=(3000 + 2000) * .50, employee_share=(3000 + 2000) * .50,
employer_share=(3000 + 2000) * .40, employer_share=(3000 + 2000) * .40,
total=((3000 + 2000) * .50 + (3000 + 2000) * .40)) total=((3000 + 2000) * .50 + (3000 + 2000) * .40))
def test_PayrollTaxesReportDifferentSalaryRange(self): def test_PayrollTaxesReportDifferentSalaryRange(self):
eur = self.portal.currency_module.EUR eur = self.portal.currency_module.EUR
payroll_service = self.portal.payroll_service_module.newContent( payroll_service = self.portal.payroll_service_module.newContent(
...@@ -1949,23 +1949,23 @@ class TestPayroll(TestPayrollMixin): ...@@ -1949,23 +1949,23 @@ class TestPayroll(TestPayrollMixin):
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
# set request variables and render # set request variables and render
request_form = self.portal.REQUEST request_form = self.portal.REQUEST
request_form['at_date'] = DateTime(2006, 2, 2) request_form['at_date'] = DateTime(2006, 2, 2)
request_form['section_category'] = 'group/demo_group' request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['draft', 'planned'] request_form['simulation_state'] = ['draft', 'planned']
request_form['resource'] = payroll_service.getRelativeUrl() request_form['resource'] = payroll_service.getRelativeUrl()
request_form['mirror_section'] = provider.getRelativeUrl() request_form['mirror_section'] = provider.getRelativeUrl()
report_section_list = self.getReportSectionList( report_section_list = self.getReportSectionList(
self.portal.accounting_module, self.portal.accounting_module,
'AccountingTransactionModule_viewPaySheetLineReport') 'AccountingTransactionModule_viewPaySheetLineReport')
self.assertEquals(1, len(report_section_list)) self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0]) line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()] data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(6, len(data_line_list)) self.assertEquals(6, len(data_line_list))
self.checkLineProperties(data_line_list[0], self.checkLineProperties(data_line_list[0],
id=1, id=1,
employee_career_reference='E1', employee_career_reference='E1',
...@@ -2014,7 +2014,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2014,7 +2014,7 @@ class TestPayroll(TestPayrollMixin):
#total=(3500 * .20 + 3500 * .32), #total=(3500 * .20 + 3500 * .32),
) )
# stat line # stat line
self.checkLineProperties(line_list[-1], self.checkLineProperties(line_list[-1],
base=2000 + 3500, base=2000 + 3500,
employee_share=(2000 * .50 + 3500 * .20), employee_share=(2000 * .50 + 3500 * .20),
...@@ -2147,17 +2147,17 @@ class TestPayroll(TestPayrollMixin): ...@@ -2147,17 +2147,17 @@ class TestPayroll(TestPayrollMixin):
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
# set request variables and render # set request variables and render
request_form = self.portal.REQUEST request_form = self.portal.REQUEST
request_form['at_date'] = DateTime(2006, 2, 2) request_form['at_date'] = DateTime(2006, 2, 2)
request_form['section_category'] = 'group/demo_group' request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['draft', 'planned'] request_form['simulation_state'] = ['draft', 'planned']
report_section_list = self.getReportSectionList( report_section_list = self.getReportSectionList(
self.portal.accounting_module, self.portal.accounting_module,
'AccountingTransactionModule_viewNetSalaryReport') 'AccountingTransactionModule_viewNetSalaryReport')
self.assertEquals(1, len(report_section_list)) self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0]) line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()] data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(2, len(data_line_list)) self.assertEquals(2, len(data_line_list))
...@@ -2166,7 +2166,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2166,7 +2166,7 @@ class TestPayroll(TestPayrollMixin):
# precision is 3 # precision is 3
precision = self.portal.REQUEST.get('precision') precision = self.portal.REQUEST.get('precision')
self.assertEquals(3, precision) self.assertEquals(3, precision)
self.checkLineProperties(data_line_list[0], self.checkLineProperties(data_line_list[0],
employee_career_reference='E1', employee_career_reference='E1',
employee_title='Employee One', employee_title='Employee One',
...@@ -2177,7 +2177,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2177,7 +2177,7 @@ class TestPayroll(TestPayrollMixin):
employee_title='Employee Two', employee_title='Employee Two',
employee_bank_account='Bank 2', employee_bank_account='Bank 2',
total_price=3000 - (3000 * .5),) total_price=3000 - (3000 * .5),)
# stat line # stat line
self.checkLineProperties( self.checkLineProperties(
line_list[-1], line_list[-1],
total_price=3000 + 2000 - (2000 * .5) - (3000 * .5)) total_price=3000 + 2000 - (2000 * .5) - (3000 * .5))
...@@ -2333,7 +2333,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2333,7 +2333,7 @@ class TestPayroll(TestPayrollMixin):
destination_section_value=employer, destination_section_value=employer,
source_section_value=employee, source_section_value=employee,
start_date=DateTime(2006, 1, 1),) start_date=DateTime(2006, 1, 1),)
# base salary = 2000 # base salary = 2000
line = ps.newContent(portal_type='Pay Sheet Line', line = ps.newContent(portal_type='Pay Sheet Line',
title='Base salary', title='Base salary',
...@@ -2354,7 +2354,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2354,7 +2354,7 @@ class TestPayroll(TestPayrollMixin):
mapped_value_property_list=('price', mapped_value_property_list=('price',
'quantity'),) 'quantity'),)
cell_employer.edit(price=1, quantity=2000, tax_category='employer_share') cell_employer.edit(price=1, quantity=2000, tax_category='employer_share')
# base_salary += 100 (bonus) # base_salary += 100 (bonus)
line = ps.newContent(portal_type='Pay Sheet Line', line = ps.newContent(portal_type='Pay Sheet Line',
title='Bonus', title='Bonus',
...@@ -2397,7 +2397,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2397,7 +2397,7 @@ class TestPayroll(TestPayrollMixin):
'quantity'),) 'quantity'),)
cell_employer.edit(price=-1, quantity=50, tax_category='employer_share') cell_employer.edit(price=-1, quantity=50, tax_category='employer_share')
# tax1 = 10% for employee ( 205 ) # tax1 = 10% for employee ( 205 )
# 20% for employer ( 410 ) # 20% for employer ( 410 )
line = ps.newContent(portal_type='Pay Sheet Line', line = ps.newContent(portal_type='Pay Sheet Line',
title='Tax 1', title='Tax 1',
...@@ -2424,11 +2424,11 @@ class TestPayroll(TestPayrollMixin): ...@@ -2424,11 +2424,11 @@ class TestPayroll(TestPayrollMixin):
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
related_applied_rule = ps.getCausalityRelatedValue( related_applied_rule = ps.getCausalityRelatedValue(
portal_type='Applied Rule') portal_type='Applied Rule')
self.assertNotEquals(related_applied_rule, None) self.assertNotEquals(related_applied_rule, None)
# build accounting lines # build accounting lines
ps.confirm() ps.confirm()
ps.start() ps.start()
...@@ -2438,7 +2438,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2438,7 +2438,7 @@ class TestPayroll(TestPayrollMixin):
accounting_line_list = ps.contentValues( accounting_line_list = ps.contentValues(
portal_type='Pay Sheet Transaction Line') portal_type='Pay Sheet Transaction Line')
self.assertEquals(len(accounting_line_list), 4) self.assertEquals(len(accounting_line_list), 4)
line = [l for l in accounting_line_list line = [l for l in accounting_line_list
if l.getDestinationValue() == account_payroll_wages_expense][0] if l.getDestinationValue() == account_payroll_wages_expense][0]
self.assertEquals(2050, line.getDestinationDebit()) self.assertEquals(2050, line.getDestinationDebit())
...@@ -2449,7 +2449,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2449,7 +2449,7 @@ class TestPayroll(TestPayrollMixin):
self.assertEquals(2050 - 205, line.getDestinationCredit()) self.assertEquals(2050 - 205, line.getDestinationCredit())
self.assertEquals(employer, line.getDestinationSectionValue()) self.assertEquals(employer, line.getDestinationSectionValue())
self.assertEquals(employee, line.getSourceSectionValue()) self.assertEquals(employee, line.getSourceSectionValue())
line = [l for l in accounting_line_list line = [l for l in accounting_line_list
if l.getDestinationValue() == account_payroll_taxes_expense][0] if l.getDestinationValue() == account_payroll_taxes_expense][0]
self.assertEquals(410, line.getDestinationDebit()) self.assertEquals(410, line.getDestinationDebit())
...@@ -2460,7 +2460,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2460,7 +2460,7 @@ class TestPayroll(TestPayrollMixin):
self.assertEquals(410 + 205, line.getDestinationCredit()) self.assertEquals(410 + 205, line.getDestinationCredit())
self.assertEquals(employer, line.getDestinationSectionValue()) self.assertEquals(employer, line.getDestinationSectionValue())
self.assertEquals(provider, line.getSourceSectionValue()) self.assertEquals(provider, line.getSourceSectionValue())
import unittest import unittest
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2008 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <lukasz.nowak@ventis.com.pl> # Łukasz Nowak <lukasz.nowak@ventis.com.pl>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -153,7 +153,7 @@ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPacking ...@@ -153,7 +153,7 @@ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPacking
def stepDecreaseProducedDeliveryPackingListQuantity(self, sequence=None, sequence_list=None, **kw): def stepDecreaseProducedDeliveryPackingListQuantity(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('produced_delivery_packing_list') packing_list = sequence.get('produced_delivery_packing_list')
for line in packing_list.getMovementList(): for line in packing_list.getMovementList():
line.edit( line.edit(
quantity = line.getQuantity() - 1.0 quantity = line.getQuantity() - 1.0
...@@ -161,7 +161,7 @@ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPacking ...@@ -161,7 +161,7 @@ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPacking
def stepDecreaseSupplyDeliveryPackingListQuantity(self, sequence=None, sequence_list=None, **kw): def stepDecreaseSupplyDeliveryPackingListQuantity(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('supply_delivery_packing_list') packing_list = sequence.get('supply_delivery_packing_list')
for line in packing_list.getMovementList(): for line in packing_list.getMovementList():
line.edit( line.edit(
quantity = line.getQuantity() - 1.0 quantity = line.getQuantity() - 1.0
...@@ -208,7 +208,7 @@ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPacking ...@@ -208,7 +208,7 @@ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPacking
supply_movement.getSimulationState(), supply_movement.getSimulationState(),
supply_delivery_packing_list.getSimulationState() supply_delivery_packing_list.getSimulationState()
) )
self.assertEquals( self.assertEquals(
produced_movement.getSimulationState(), produced_movement.getSimulationState(),
produced_report.getSimulationState() produced_report.getSimulationState()
...@@ -403,7 +403,7 @@ class TestProductionDelivery(TestProductionPackingReportListMixin): ...@@ -403,7 +403,7 @@ class TestProductionDelivery(TestProductionPackingReportListMixin):
self.transformation_portal_type, self.transformation_portal_type,
self.resource_portal_type,) self.resource_portal_type,)
def test_01_sourcingDelivery(self, quiet=0, def test_01_sourcingDelivery(self, quiet=0,
run=run_all_test): run=run_all_test):
""" """
Test for sourcing type of delivery (Production Report and Production Packing Lists). Test for sourcing type of delivery (Production Report and Production Packing Lists).
......
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