Skip to content

Commit

Permalink
[FIX] automatic transitions on create
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Dec 16, 2023
1 parent 7f0f51a commit ba72638
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion statechart/models/statechart_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _compute_sc_interpreter(self):
config = json.loads(rec.sc_state)
interpreter.restore_configuration(config)
else:
interpreter.execute_once()
interpreter.execute()
rec.sc_interpreter = interpreter

@api.depends("sc_state")
Expand Down
2 changes: 2 additions & 0 deletions test_statechart/models/test_statechart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ statechart:
transitions:
- event: confirm1
target: confirmed1
- target: confirmed1
guard: o.amount < 1
- name: confirmed1
transitions:
- target: confirmed2
Expand Down
6 changes: 6 additions & 0 deletions test_statechart/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ def test_automatic_transition(self):
record.confirm1()
# small amount, step 2 done automatically
self.assertScState(record.sc_state, ["confirmed2", "root"])

def test_automatic_transition_on_create(self):
model = self.env["scobidoo.test.model"]
record = model.create({"amount": 0.5})
# very small amount, step 1 and 2 done automatically
self.assertScState(record.sc_state, ["confirmed2", "root"])

0 comments on commit ba72638

Please sign in to comment.