Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Tryton
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tryton
Tryton
Commits
4171dae3
Commit
4171dae3
authored
4 months ago
by
Cédric Krier
Browse files
Options
Downloads
Patches
Plain Diff
Fill wizard state view instance with default value
Closes
#13693
parent
aa4ad9d6
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
trytond/CHANGELOG
+1
-0
1 addition, 0 deletions
trytond/CHANGELOG
trytond/trytond/tests/test_wizard.py
+2
-4
2 additions, 4 deletions
trytond/trytond/tests/test_wizard.py
trytond/trytond/wizard/wizard.py
+11
-4
11 additions, 4 deletions
trytond/trytond/wizard/wizard.py
with
14 additions
and
8 deletions
trytond/CHANGELOG
+
1
−
0
View file @
4171dae3
* Fill wizard state view instance with default value
* Add metadata columns to ModelSQL with table query
* Add report data to header_key
* Validate integer digits
...
...
This diff is collapsed.
Click to expand it.
trytond/trytond/tests/test_wizard.py
+
2
−
4
View file @
4171dae3
...
...
@@ -46,6 +46,5 @@
session
,
=
Session
.
create
([{}])
wizard
=
Wizard
(
session
.
id
)
self
.
assertEqual
(
wizard
.
start
.
id
,
None
)
self
.
assertRaises
(
AttributeError
,
getattr
,
wizard
.
start
,
'
name
'
)
self
.
assertEqual
(
hasattr
(
wizard
.
start
,
'
name
'
),
False
)
self
.
assertEqual
(
wizard
.
start
.
name
,
None
)
wizard
.
start
.
name
=
'
Test
'
...
...
@@ -51,6 +50,5 @@
wizard
.
start
.
name
=
'
Test
'
self
.
assertRaises
(
AttributeError
,
getattr
,
wizard
.
start
,
'
user
'
)
self
.
assertEqual
(
hasattr
(
wizard
.
start
,
'
user
'
),
False
)
self
.
assertEqual
(
wizard
.
start
.
user
.
id
,
Transaction
().
user
)
wizard
.
start
.
user
=
transaction
.
user
group_a
,
=
Group
.
create
([{
'
name
'
:
'
Group A
'
,
...
...
This diff is collapsed.
Click to expand it.
trytond/trytond/wizard/wizard.py
+
11
−
4
View file @
4171dae3
...
...
@@ -7,6 +7,7 @@
import
copy
import
json
from
collections
import
defaultdict
from
trytond.i18n
import
gettext
from
trytond.model
import
ModelSQL
...
...
@@ -398,6 +399,7 @@
Session
=
pool
.
get
(
'
ir.session.wizard
'
)
self
.
_session_id
=
session_id
session
=
Session
(
session_id
)
data
=
json
.
loads
(
session
.
data
,
object_hook
=
JSONDecoder
())
data
=
defaultdict
(
dict
)
data
.
update
(
json
.
loads
(
session
.
data
,
object_hook
=
JSONDecoder
()))
for
state_name
,
state
in
self
.
states
.
items
():
if
isinstance
(
state
,
StateView
):
...
...
@@ -402,8 +404,13 @@
for
state_name
,
state
in
self
.
states
.
items
():
if
isinstance
(
state
,
StateView
):
Target
=
pool
.
get
(
state
.
model_name
)
data
.
setdefault
(
state_name
,
{})
setattr
(
self
,
state_name
,
Target
(
**
data
[
state_name
]))
View
=
pool
.
get
(
state
.
model_name
)
view_data
=
data
[
state_name
]
default_values
=
View
.
default_get
(
View
.
_fields
.
keys
(),
with_rec_name
=
False
)
for
field_name
in
View
.
_fields
:
view_data
.
setdefault
(
field_name
,
default_values
.
get
(
field_name
))
setattr
(
self
,
state_name
,
View
(
**
view_data
))
def
_save
(
self
):
"
Save the session in database
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment