Ivan Tyagov
2007-01-08 12:16:56 UTC
Hi,
I encountered the following bug:
When a 'Person' object is contained inside a business template file and
this Person object has set an username ('reference' property) after
installing this bt5 file this properly is set to 'None' and thus it's
not a valid ERP5 user. What happens is that in business template
installation 'manage_afterClone()' is applied to every installed object
including 'Person' which is fine.
But the default behavior for 'Person' is to reset reference in
'Person_afteClone()'.
Because manage_afterClone() --> Person_afterClone() chain is normally
called when a Person object is copied/pasted and by exception when a
business template is installed I would like to introduce this patch that
will restore 'reference' when a 'Person' objects is installed from bt5
file.
Any ideas how this can be done in a more elegant way/place are welcome.
Ivan
Index: Document/BusinessTemplate.py
===================================================================
--- Document/BusinessTemplate.py (revision 11920)
+++ Document/BusinessTemplate.py (working copy)
@@ -646,8 +646,14 @@
obj = obj._getCopy(container)
container._setObject(object_id, obj)
obj = container._getOb(object_id)
+ default_reference = getattr(obj, 'default_reference', None)
obj.manage_afterClone(obj)
- obj.wl_clearLocks()
+ if obj.meta_type in ('ERP5 Person',) and default_reference is
not None:
+ # when copying 'Person' objects 'Person_afterClone' scriptis
+ # called which will reset to None reference propeprty but it
will
+ # loose username which is not acceptable thus restore it.
+ obj.setReference(default_reference)
+ obj.wl_clearLocks()
# if portal types upgrade, set backup properties
I encountered the following bug:
When a 'Person' object is contained inside a business template file and
this Person object has set an username ('reference' property) after
installing this bt5 file this properly is set to 'None' and thus it's
not a valid ERP5 user. What happens is that in business template
installation 'manage_afterClone()' is applied to every installed object
including 'Person' which is fine.
But the default behavior for 'Person' is to reset reference in
'Person_afteClone()'.
Because manage_afterClone() --> Person_afterClone() chain is normally
called when a Person object is copied/pasted and by exception when a
business template is installed I would like to introduce this patch that
will restore 'reference' when a 'Person' objects is installed from bt5
file.
Any ideas how this can be done in a more elegant way/place are welcome.
Ivan
Index: Document/BusinessTemplate.py
===================================================================
--- Document/BusinessTemplate.py (revision 11920)
+++ Document/BusinessTemplate.py (working copy)
@@ -646,8 +646,14 @@
obj = obj._getCopy(container)
container._setObject(object_id, obj)
obj = container._getOb(object_id)
+ default_reference = getattr(obj, 'default_reference', None)
obj.manage_afterClone(obj)
- obj.wl_clearLocks()
+ if obj.meta_type in ('ERP5 Person',) and default_reference is
not None:
+ # when copying 'Person' objects 'Person_afterClone' scriptis
+ # called which will reset to None reference propeprty but it
will
+ # loose username which is not acceptable thus restore it.
+ obj.setReference(default_reference)
+ obj.wl_clearLocks()
# if portal types upgrade, set backup properties