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

getReferenceDict uses ID if object does not have a reference.

drop get_none_reference parameter, it does not seem to be needed.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20130 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b30dddd0
......@@ -31,7 +31,7 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.TradeCondition import TradeCondition
from Products.ERP5Type.XMLMatrix import XMLMatrix
from zLOG import LOG, WARNING, DEBUG
from zLOG import LOG
#XXX TODO: review naming of new methods
#XXX WARNING: current API naming may change although model should be stable.
......@@ -85,32 +85,17 @@ class PaySheetModel(TradeCondition, XMLMatrix):
return cell
def getReferenceDict(self, portal_type_list, get_none_reference=0):
'''
return all objects reference and id of the model wich portal_type is in the
portal_type_list
- parameters :
o get_none_reference : permit to get a dict with all references
not defined. This is usefull to get all object on the model paysheet
inherite from.
def getReferenceDict(self, portal_type_list):
'''Return all objects reference and id of the model wich portal_type is in
the portal_type_list. If type does not have a reference, it's ID is used.
'''
reference_dict={}
object_list = self.contentValues(portal_type=portal_type_list,
sort_on='id')
for object in object_list:
reference_method = getattr(object, 'getReference', None)
if reference_method is None:
LOG('PaySheetModel getReferenceList', 0, '%s have not '
'getReference method' % object.getTitle() or
object.getRelativeUrl())
else:
reference = reference_method()
if reference is not None and not get_none_reference:
reference_dict[reference]=object.getId()
elif reference is None and get_none_reference:
reference_dict[object.getId()]=object.getId()
sort_on='id')
for obj in object_list:
reference_dict[obj.getProperty('reference', obj.getId())] = obj.getId()
return reference_dict
......
......@@ -513,10 +513,7 @@ class PaySheetTransaction(Invoice):
model_reference_dict = model.getInheritanceModelReferenceDict(
portal_type_list=portal_type_list)
# add line of base model without reference
model_dict = model.getReferenceDict(\
portal_type_list=portal_type_list,
get_none_reference=1)
model_dict = model.getReferenceDict(portal_type_list=portal_type_list)
id_list = model_dict.values()
if model_reference_dict.has_key(model.getRelativeUrl()):
model_reference_dict[model.getRelativeUrl()].extend(id_list)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment