Commit 8fbbe182 authored by Nicolas Delaby's avatar Nicolas Delaby

Cosmetics modifications

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19701 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 996644fe
...@@ -111,7 +111,7 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -111,7 +111,7 @@ class ImmobilisableItem(XMLObject, Amount):
immo_and_owner_list = [] immo_and_owner_list = []
if immobilisation_movement_list is None: if immobilisation_movement_list is None:
# First build the SQL query # First build the SQL query
sql_dict = self.getCleanSqlDict(kw) sql_dict = self._getCleanSqlDict(**kw)
sql_dict['aggregate_uid'] = self.getUid() sql_dict['aggregate_uid'] = self.getUid()
if filter_valid: if filter_valid:
sql_dict['immobilisation_state'] = ['calculating','valid'] sql_dict['immobilisation_state'] = ['calculating','valid']
...@@ -749,7 +749,6 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -749,7 +749,6 @@ class ImmobilisableItem(XMLObject, Amount):
If with_currency is set, returns a string containing the value and the If with_currency is set, returns a string containing the value and the
corresponding currency. corresponding currency.
""" """
if at_date is None: if at_date is None:
at_date = DateTime() at_date = DateTime()
kw_key_list = kw.keys() kw_key_list = kw.keys()
...@@ -789,13 +788,13 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -789,13 +788,13 @@ class ImmobilisableItem(XMLObject, Amount):
owner = immo_period['owner'] owner = immo_period['owner']
# Calculate data if not found # Calculate data if not found
if start_price is None: if start_price is None:
start_price = self.getAmortisationPrice(at_date = start_date, start_price = self.getAmortisationPrice(at_date=start_date,
immo_cache_dict=immo_cache_dict) immo_cache_dict=immo_cache_dict)
if start_duration is None: if start_duration is None:
start_duration = self.getRemainingAmortisationDuration(at_date = start_date, start_duration = self.getRemainingAmortisationDuration(at_date=start_date,
immo_cache_dict=immo_cache_dict) immo_cache_dict=immo_cache_dict)
if start_durability is None: if start_durability is None:
start_durability = self.getRemainingDurability(at_date = start_date, start_durability = self.getRemainingDurability(at_date=start_date,
immo_cache_dict=immo_cache_dict) immo_cache_dict=immo_cache_dict)
# Get the current period stop date, duration and durability # Get the current period stop date, duration and durability
if immo_period.has_key('stop_date'): if immo_period.has_key('stop_date'):
...@@ -803,7 +802,7 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -803,7 +802,7 @@ class ImmobilisableItem(XMLObject, Amount):
period_stop_date = stop_date period_stop_date = stop_date
else: else:
stop_date = at_date stop_date = at_date
next_movement = self.getNextImmobilisationMovementValue(at_date = at_date, **kw) next_movement = self.getNextImmobilisationMovementValue(at_date=at_date, **kw)
if next_movement is not None: if next_movement is not None:
period_stop_date = next_movement.getStopDate() period_stop_date = next_movement.getStopDate()
else: else:
...@@ -927,7 +926,6 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -927,7 +926,6 @@ class ImmobilisableItem(XMLObject, Amount):
LOG("ERP5 Warning :",0, LOG("ERP5 Warning :",0,
"Unable to calculate the ratio during the amortisation calculation on item %s at date %s : script %s returned None" % ( "Unable to calculate the ratio during the amortisation calculation on item %s at date %s : script %s returned None" % (
self.getRelativeUrl(), repr(at_date), '%s/ratioCalculation' % amortisation_method)) self.getRelativeUrl(), repr(at_date), '%s/ratioCalculation' % amortisation_method))
LOG('params were ', 0, ratio_params)
raise ImmobilisationCalculationError, \ raise ImmobilisationCalculationError, \
"Unable to calculate the ratio during the amortisation calculation on item %s at date %s" % ( "Unable to calculate the ratio during the amortisation calculation on item %s at date %s" % (
repr(self), repr(at_date)) repr(self), repr(at_date))
...@@ -1070,16 +1068,14 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -1070,16 +1068,14 @@ class ImmobilisableItem(XMLObject, Amount):
self.activate().expandAmortisation(activate_kw=activate_kw) self.activate().expandAmortisation(activate_kw=activate_kw)
security.declareProtected(Permissions.View, 'getSectionMovementValueList') security.declareProtected(Permissions.View, 'getSectionMovementValueList')
def getSectionMovementValueList(self, def getSectionMovementValueList(self, include_to_date=0, **kw):
include_to_date=0,
**kw):
""" """
Return the list of successive movements affecting Return the list of successive movements affecting
owners of the item. If at_date is None, return the result all the time owners of the item. If at_date is None, return the result all the time
Only the movements in current_inventory_state are taken into account Only the movements in current_inventory_state are taken into account
""" """
# Get tracking list # Get tracking list
sql_kw = self.getCleanSqlDict(kw) sql_kw = self._getCleanSqlDict(**kw)
sql_kw['item'] = self.getRelativeUrl() sql_kw['item'] = self.getRelativeUrl()
sql_kw['sort-on'] = 'item.date' sql_kw['sort-on'] = 'item.date'
sql_kw['sort-order'] = 'ascending' sql_kw['sort-order'] = 'ascending'
...@@ -1102,7 +1098,7 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -1102,7 +1098,7 @@ class ImmobilisableItem(XMLObject, Amount):
movement_uid = last_movement[-1]['delivery_uid'] movement_uid = last_movement[-1]['delivery_uid']
if movement_uid is not None: if movement_uid is not None:
movement = self.portal_catalog.getObject(movement_uid) movement = self.portal_catalog.getObject(movement_uid)
if len(movement_list)==0 or movement_list[-1] != movement: if len(movement_list) == 0 or movement_list[-1] != movement:
movement_list.append(movement) movement_list.append(movement)
return movement_list return movement_list
...@@ -1113,7 +1109,7 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -1113,7 +1109,7 @@ class ImmobilisableItem(XMLObject, Amount):
the corresponding ownership change dates the corresponding ownership change dates
If at_date is None, return the result all the time If at_date is None, return the result all the time
""" """
new_kw = self.getCleanSqlDict(kw) new_kw = self._getCleanSqlDict(**kw)
new_kw['to_date'] = at_date new_kw['to_date'] = at_date
movement_list = self.getSectionMovementValueList(**new_kw) movement_list = self.getSectionMovementValueList(**new_kw)
# Find ownership changes # Find ownership changes
...@@ -1121,7 +1117,7 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -1121,7 +1117,7 @@ class ImmobilisableItem(XMLObject, Amount):
if from_date is None: if from_date is None:
previous_section = None previous_section = None
else: else:
previous_section = self.getSectionValue(at_date = from_date) previous_section = self.getSectionValue(at_date=from_date)
owner_change_list = [] owner_change_list = []
for movement in movement_list: for movement in movement_list:
new_section = movement.getDestinationSectionValue() new_section = movement.getDestinationSectionValue()
...@@ -1144,7 +1140,7 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -1144,7 +1140,7 @@ class ImmobilisableItem(XMLObject, Amount):
Return the owner of the item at the given date Return the owner of the item at the given date
If at_date is None, return the last owner without time limit If at_date is None, return the last owner without time limit
""" """
owner_list = self.getSectionChangeList(at_date = at_date, **kw) owner_list = self.getSectionChangeList(at_date=at_date, **kw)
if len(owner_list) > 0: if len(owner_list) > 0:
return owner_list[-1]['owner'] return owner_list[-1]['owner']
return None return None
...@@ -1154,16 +1150,14 @@ class ImmobilisableItem(XMLObject, Amount): ...@@ -1154,16 +1150,14 @@ class ImmobilisableItem(XMLObject, Amount):
""" """
Return the current owner of the item Return the current owner of the item
""" """
return self.getSectionValue(at_date = DateTime(), **kw) return self.getSectionValue(at_date=DateTime(), **kw)
security.declareProtected(Permissions.View, 'getCleanSqlDict') def _getCleanSqlDict(self, **kw):
def getCleanSqlDict(self, kw): no_key_list = ('immo_cache_dict',)
no_sql_list = ['immo_cache_dict'] for key in no_key_list:
sql_dict = {} if key in kw:
for k,v in kw.items(): del kw[key]
if k not in no_sql_list: return kw
sql_dict[k] = v
return sql_dict
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