Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
8577cb2c
Commit
8577cb2c
authored
Apr 09, 2019
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BusinessTemplate: Remove user_id when a document that is ERP5User is exported and
re-generate on installation
parent
e9cc6f29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletion
+61
-1
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+20
-1
product/ERP5/tests/testBusinessTemplate.py
product/ERP5/tests/testBusinessTemplate.py
+41
-0
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
8577cb2c
...
...
@@ -642,7 +642,13 @@ class BaseTemplateItem(Implicit, Persistent):
for
attr
in
obj
.
__dict__
.
keys
():
if
attr
in
attr_set
or
attr
.
startswith
(
'_cache_cookie_'
):
delattr
(
obj
,
attr
)
portal_type
=
getattr
(
obj
,
'portal_type'
,
None
)
if
portal_type
is
not
None
:
portal_type_value
=
self
.
getPortalObject
().
portal_types
.
get
(
portal_type
,
None
)
if
portal_type_value
is
not
None
\
and
'ERP5User'
in
portal_type_value
.
getTypePropertySheetList
()
\
and
'user_id'
in
obj
.
__dict__
.
keys
():
delattr
(
obj
,
'user_id'
)
if
classname
==
'PDFForm'
:
if
not
obj
.
getProperty
(
'business_template_include_content'
,
1
):
obj
.
deletePdfContent
()
...
...
@@ -1464,6 +1470,19 @@ class ObjectTemplateItem(BaseTemplateItem):
l
=
local_role_dict
.
setdefault
(
userid
,
[])
l
.
append
(
'Owner'
)
# END:part of ERP5Type.CopySupport.manage_afterClone
# Reset user_id if needed
portal_type
=
getattr
(
obj
,
'portal_type'
,
None
)
if
portal_type
is
not
None
:
portal_type_value
=
portal
.
portal_types
.
get
(
portal_type
,
None
)
if
portal_type_value
is
not
None
\
and
'ERP5User'
in
portal_type_value
.
getTypePropertySheetList
():
aq_base
(
obj
).
user_id
=
'%s%i'
%
(
portal_type
[
0
],
portal
.
portal_ids
.
generateNewId
(
id_group
=
'user_id'
,
id_generator
=
'non_continuous_integer_increasing'
,
),
)
del
obj
.
isIndexable
if
getattr
(
aq_base
(
obj
),
'reindexObject'
,
None
)
is
not
None
:
obj
.
reindexObject
()
...
...
product/ERP5/tests/testBusinessTemplate.py
View file @
8577cb2c
...
...
@@ -7324,6 +7324,47 @@ class TestBusinessTemplate(BusinessTemplateMixin):
self
.
assertEqual
(
True
,
method
(
"aa/bb"
))
self
.
assertEqual
(
True
,
method
(
"aa/bb/cc"
))
def
testRemovalOfUserIdOfPersonInExport
(
self
):
'''
Checks that when a Business Template with a Person path is exported
the user_id is stripped and when it is installed a new one is created
'''
export_dir
=
tempfile
.
mkdtemp
()
try
:
sequence
=
Sequence
()
self
.
stepCreateNewBusinessTemplate
(
sequence
=
sequence
)
business_template
=
sequence
.
get
(
"export_bt"
)
person_id
=
'test_person'
person
=
self
.
portal
.
person_module
.
newContent
(
id
=
person_id
,
portal_type
=
'Person'
)
self
.
assertTrue
(
person
.
hasUserId
())
original_user_id
=
person
.
getUserId
()
business_template
.
edit
(
template_path_list
=
[
'person_module/'
+
person
.
getId
()])
business_template
.
build
()
business_template
.
export
(
path
=
export_dir
,
local
=
True
)
template_tool
=
self
.
portal
.
portal_templates
template_tool
.
manage_delObjects
(
business_template
.
getId
())
self
.
portal
.
person_module
.
manage_delObjects
(
person_id
)
person_xml_file
=
open
(
export_dir
+
'/PathTemplateItem/person_module/%s.xml'
%
person_id
,
mode
=
'r'
)
person_xml
=
person_xml_file
.
read
()
person_xml_file
.
close
()
# Check that user_id is not exported
self
.
assertNotIn
(
'>user_id<'
,
person_xml
)
self
.
assertNotIn
(
'>%s<'
%
original_user_id
,
person_xml
)
import_template
=
template_tool
.
download
(
url
=
'file:'
+
export_dir
)
self
.
assertEqual
(
import_template
.
getPortalType
(),
'Business Template'
)
# Check that in installation a new user_id is created
import_template
.
install
()
person_value
=
self
.
portal
.
person_module
[
person_id
]
self
.
assertTrue
(
person_value
.
hasUserId
())
new_user_id
=
person_value
.
getUserId
()
self
.
assertNotEqual
(
new_user_id
,
original_user_id
)
self
.
assertEqual
(
new_user_id
[
0
],
'P'
)
finally
:
shutil
.
rmtree
(
export_dir
)
def
stepCreateDocumentComponentWhichTriggersAnOperationWhenSubDocumentIsAdded
(
self
,
sequence
=
None
,
**
kw
):
from
textwrap
import
dedent
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment