Commit 8f832c45 authored by Jérome Perrin's avatar Jérome Perrin

Use start_date / stop_date for lifetime of Entities. Be sure to run:

[pers.setStartDate(pers.birthday) for pers in context.person_module.objectValues() if getattr(pers, 'birthday', None) is not None]
and 
[org.setStartDate(pers.creation_date) for org in context.organisation_module.objectValues() if getattr(org, 'creation_date', None) is not None]
to update existing documents.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10664 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ae4fc106
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_creation_date</string> </value>
<value> <string>my_start_date</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -66,6 +66,7 @@ class Organisation(MetaNode, XMLObject):
, PropertySheet.DublinCore
, PropertySheet.Organisation
, PropertySheet.Mapping
, PropertySheet.Task
)
......@@ -83,6 +83,7 @@ class Person(Node, XMLObject):
, PropertySheet.Reference
, PropertySheet.Person
, PropertySheet.Mapping
, PropertySheet.Task
)
def _setTitle(self, value):
......
......@@ -88,10 +88,6 @@ class Organisation:
'description' : 'The social code of this organisation',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'creation_date',
'description' : 'The date of the creation of this organisation',
'type' : 'date',
'mode' : 'w' },
# (Kev) This property is too banking-centric to appear here as a general organisation property. The following must be renamed to something more abstract like "business_code", "domain_uid", "business_domain_special_organisation_id" or something like that.
{ 'id' : 'bic_code',
'description' : 'The Bank Identifier Code is a unique code that identifies individual banking and financial institution offices around the world.',
......
......@@ -74,6 +74,7 @@ class Person:
},
{ 'id' : 'birthday'
, 'description': 'Date of birth.'
, 'storage_id' : 'start_date'
, 'type' : 'date'
, 'mode' : 'w'
},
......
......@@ -778,6 +778,35 @@ class TestHR(ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def test_05_DatesOnPerson(self, quiet=QUIET, run=RUN_ALL_TEST):
"""Tests dates on Person objects.
"""
pers = self.getPersonModule().newContent(portal_type='Person')
birthday = DateTime(1999, 01, 01)
now = DateTime()
pers.edit(birthday = birthday)
self.assertEquals(birthday, pers.getBirthday())
self.assertEquals(birthday, pers.getStartDate())
for slot in ['year', 'month', 'day', 'hour', 'minute']:
self.assertEquals(getattr(now, slot)(),
getattr(pers.getCreationDate(), slot)(),
'Wrong creation date %s' % pers.getCreationDate())
def test_06_DatesOnOrganisation(self, quiet=QUIET, run=RUN_ALL_TEST):
"""Tests dates on Organisation objects.
"""
org = self.getOrganisationModule().newContent(portal_type='Organisation')
start_date = DateTime(1999, 01, 01)
now = DateTime()
org.edit(start_date = start_date)
self.assertEquals(start_date, org.getStartDate())
for slot in ['year', 'month', 'day', 'hour', 'minute']:
self.assertEquals(getattr(now, slot)(),
getattr(org.getCreationDate(), slot)(),
'Wrong creation date %s' % org.getCreationDate())
if __name__ == '__main__':
framework()
else:
......
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