Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
5a6b0eef by Cédric Krier at 2023-01-22T01:41:52+01:00
Copy original state of wizard to avoid side effect

Closes #4948
- - - - -


1 changed file:

- trytond/trytond/wizard/wizard.py


Changes:

=====================================
trytond/trytond/wizard/wizard.py
=====================================
@@ -214,8 +214,18 @@
 
         # Copy states
         for attr in dir(cls):
-            if isinstance(getattr(cls, attr), State):
-                setattr(cls, attr, copy.deepcopy(getattr(cls, attr)))
+            if not isinstance(getattr(cls, attr), State):
+                continue
+            state_name = attr
+            state = getattr(cls, state_name)
+            # Copy the original state definition to prevent side-effect with
+            # the mutable attributes
+            for parent_cls in cls.__mro__:
+                parent_state = getattr(parent_cls, state_name, None)
+                if isinstance(parent_state, State):
+                    state = parent_state
+            state = copy.deepcopy(state)
+            setattr(cls, attr, state)
 
     @classmethod
     def __post_setup__(cls):



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/5a6b0eef7b8902c955b44c8bda6cc53f84da6804

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/5a6b0eef7b8902c955b44c8bda6cc53f84da6804
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to