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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alain Takoudjou
erp5
Commits
323627b1
Commit
323627b1
authored
May 16, 2019
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIX decentralised id generator
parent
c63ae8e3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
4 deletions
+41
-4
product/ERP5/interfaces/id_generator.py
product/ERP5/interfaces/id_generator.py
+15
-2
product/ERP5/interfaces/id_tool.py
product/ERP5/interfaces/id_tool.py
+16
-2
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+10
-0
No files found.
product/ERP5/interfaces/id_generator.py
View file @
323627b1
...
...
@@ -34,7 +34,7 @@ class IIdGenerator(Interface):
Rounding tool interface
"""
def
generateNewId
(
id_group
=
None
,
default
=
None
):
def
generateNewId
(
id_group
=
None
,
default
=
None
,
poison
=
False
):
"""
Generate the next id in the sequence of ids of a particular group
...
...
@@ -51,9 +51,15 @@ class IIdGenerator(Interface):
If the default value is incompatible with the generator,
ValueError will be raised.
poison (bool)
If True, return the next id in requested sequence, and permanently break
that sequence's state, so that no new id may be successfuly generated
from it. Useful to ensure seamless migration away from this generator,
without risking a (few) late generation from happening after migration
code already moved sequence's state elsewhere.
"""
def
generateNewIdList
(
id_group
=
None
,
default
=
None
,
id_count
=
1
):
def
generateNewIdList
(
id_group
=
None
,
default
=
None
,
id_count
=
1
,
poison
=
False
):
"""
Generate a list of next ids in the sequence of ids of a particular group
...
...
@@ -75,6 +81,13 @@ class IIdGenerator(Interface):
method should take as parameter the previously generated
id (optional). By default, ids are managed like integers and
are increased one by one
poison (bool)
If True, return the next id in requested sequence, and permanently break
that sequence's state, so that no new id may be successfuly generated
from it. Useful to ensure seamless migration away from this generator,
without risking a (few) late generation from happening after migration
code already moved sequence's state elsewhere.
"""
def
initializeGenerator
():
...
...
product/ERP5/interfaces/id_tool.py
View file @
323627b1
...
...
@@ -34,7 +34,7 @@ class IIdTool(Interface):
Id Tool interface
"""
def
generateNewId
(
id_group
=
None
,
default
=
None
,
id_generator
=
None
):
def
generateNewId
(
id_group
=
None
,
default
=
None
,
id_generator
=
None
,
poison
=
False
):
"""
Generate the next id in the sequence of ids of a particular group
...
...
@@ -56,6 +56,13 @@ class IIdTool(Interface):
reference. This is not mandatory, a default generator will exist.
Only id generator of type application can be selected.
poison (bool)
If True, return the next id in requested sequence, and permanently break
that sequence's state, so that no new id may be successfuly generated
from it. Useful to ensure seamless migration away from this generator,
without risking a (few) late generation from happening after migration
code already moved sequence's state elsewhere.
Example :
my_new_id = portal_ids.generateNewId(id_group='sale_invoice',
default=100)
...
...
@@ -63,7 +70,7 @@ class IIdTool(Interface):
"""
def
generateNewIdList
(
id_group
=
None
,
default
=
None
,
id_count
=
1
,
id_generator
=
None
):
id_generator
=
None
,
poison
=
False
):
"""
Generate a list of next ids in the sequence of ids of a particular group
...
...
@@ -85,6 +92,13 @@ class IIdTool(Interface):
reference. This is not mandatory, a default generator will exist.
Only id generator of type application can be selected.
poison (bool)
If True, return the next id in requested sequence, and permanently break
that sequence's state, so that no new id may be successfuly generated
from it. Useful to ensure seamless migration away from this generator,
without risking a (few) late generation from happening after migration
code already moved sequence's state elsewhere.
Example :
my_new_id_list = portal_ids.generateNewIdList(id_group='sale_invoice',
default=100, id_count=3)
...
...
product/ERP5Type/Base.py
View file @
323627b1
...
...
@@ -3480,6 +3480,16 @@ class Base( CopyContainer,
return
new_document
def
_postCopy
(
self
,
container
,
op
=
0
):
super
(
Base
,
self
).
_postCopy
(
container
,
op
=
op
)
if
op
==
0
:
# copy (not cut)
# We are the copy of another document (either cloned or copy/pasted),
# forget id generator state.
try
:
del
self
.
_id_generator_state
except
AttributeError
:
pass
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'generateIdList'
)
def
generateIdList
(
self
,
group
,
count
=
1
,
default
=
1
,
onMissing
=
None
,
poison
=
False
):
"""
...
...
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