changeset 785226ceb80e in proteus:5.2
details: https://hg.tryton.org/proteus?cmd=changeset;node=785226ceb80e
description:
        Ensure on_change arguments are loaded

        As proteus is lazy about field it read, after a save call there is no 
field
        read. But if the next on_change need the value of a field no loaded, it 
will
        send an empty value because Eval accessors do not trigger a read. So to 
behave
        like other client (which load displayed fields), we ensure to load the 
needed
        arguments.

        issue8450
        review264411005
        (grafted from 983a7c8286f19dcbac2cf5a50d999f36bc82f389)
diffstat:

 proteus/__init__.py |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (20 lines):

diff -r b17edeb050f5 -r 785226ceb80e proteus/__init__.py
--- a/proteus/__init__.py       Thu Oct 24 19:00:37 2019 +0200
+++ b/proteus/__init__.py       Thu Oct 24 19:02:31 2019 +0200
@@ -1007,6 +1007,16 @@
         return values
 
     def _on_change_args(self, args):
+        # Ensure arguments has been read
+        for arg in args:
+            record = self
+            for i in arg.split('.'):
+                if i in record._fields:
+                    getattr(record, i)
+                elif i == '_parent_' + record._parent_name:
+                    getattr(record, record._parent_name)
+                    record = record._parent
+
         res = {}
         values = _EvalEnvironment(self, 'on_change')
         for arg in args:

Reply via email to