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 @@ ...@@ -14,7 +14,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_creation_date</string> </value> <value> <string>my_start_date</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
......
...@@ -66,6 +66,7 @@ class Organisation(MetaNode, XMLObject): ...@@ -66,6 +66,7 @@ class Organisation(MetaNode, XMLObject):
, PropertySheet.DublinCore , PropertySheet.DublinCore
, PropertySheet.Organisation , PropertySheet.Organisation
, PropertySheet.Mapping , PropertySheet.Mapping
, PropertySheet.Task
) )
...@@ -83,6 +83,7 @@ class Person(Node, XMLObject): ...@@ -83,6 +83,7 @@ class Person(Node, XMLObject):
, PropertySheet.Reference , PropertySheet.Reference
, PropertySheet.Person , PropertySheet.Person
, PropertySheet.Mapping , PropertySheet.Mapping
, PropertySheet.Task
) )
def _setTitle(self, value): def _setTitle(self, value):
......
...@@ -88,10 +88,6 @@ class Organisation: ...@@ -88,10 +88,6 @@ class Organisation:
'description' : 'The social code of this organisation', 'description' : 'The social code of this organisation',
'type' : 'string', 'type' : 'string',
'mode' : 'w' }, '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. # (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', { 'id' : 'bic_code',
'description' : 'The Bank Identifier Code is a unique code that identifies individual banking and financial institution offices around the world.', '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: ...@@ -74,6 +74,7 @@ class Person:
}, },
{ 'id' : 'birthday' { 'id' : 'birthday'
, 'description': 'Date of birth.' , 'description': 'Date of birth.'
, 'storage_id' : 'start_date'
, 'type' : 'date' , 'type' : 'date'
, 'mode' : 'w' , 'mode' : 'w'
}, },
......
...@@ -778,6 +778,35 @@ class TestHR(ERP5TypeTestCase): ...@@ -778,6 +778,35 @@ class TestHR(ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) 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__': if __name__ == '__main__':
framework() framework()
else: 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