diff --git a/product/ERP5/Document/PaySheetModel.py b/product/ERP5/Document/PaySheetModel.py index 70740caa726f2c0c7a12171793e939989b0efaaa..42dbbaa568b9cc68753135dea04d1d85d886f0b1 100644 --- a/product/ERP5/Document/PaySheetModel.py +++ b/product/ERP5/Document/PaySheetModel.py @@ -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 diff --git a/product/ERP5/Document/PaySheetTransaction.py b/product/ERP5/Document/PaySheetTransaction.py index aa3064e8e7aab06622f322b0133a10cb11ab4804..60e0f4b5b398f1a7cdcb72480866a3bb357a32d5 100644 --- a/product/ERP5/Document/PaySheetTransaction.py +++ b/product/ERP5/Document/PaySheetTransaction.py @@ -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)