details: https://code.tryton.org/tryton/commit/9d5d21d76b46
branch: default
user: Nicolas Évrard <[email protected]>
date: Thu Sep 03 12:24:29 2026 +0200
description:
Check the existence of a getter before adding it to a field depends
Closes #15055
diffstat:
trytond/trytond/model/modelview.py | 1 +
trytond/trytond/tests/test_field_depends.py | 10 ++++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diffs (39 lines):
diff -r dc0a158ea439 -r 9d5d21d76b46 trytond/trytond/model/modelview.py
--- a/trytond/trytond/model/modelview.py Wed Aug 26 10:26:45 2026 +0200
+++ b/trytond/trytond/model/modelview.py Thu Sep 03 12:24:29 2026 +0200
@@ -170,6 +170,7 @@
depend = depend[len('_parent_'):]
if dep_field := getattr(cls, depend, None):
if (isinstance(dep_field, fields.Function)
+ and dep_field.getter
and dep_field.getter.startswith('on_change_with')):
meth_names.append(dep_field.getter)
diff -r dc0a158ea439 -r 9d5d21d76b46 trytond/trytond/tests/test_field_depends.py
--- a/trytond/trytond/tests/test_field_depends.py Wed Aug 26 10:26:45
2026 +0200
+++ b/trytond/trytond/tests/test_field_depends.py Thu Sep 03 12:24:29
2026 +0200
@@ -273,8 +273,9 @@
test = fields.Char("Test")
foo = fields.Function(fields.Char("Foo"), 'on_change_with_foo')
bar = fields.Char("Bar")
+ baz = fields.Function(fields.Char("Baz"))
- @fields.depends('foo')
+ @fields.depends('foo', 'baz')
def on_change_test(self):
pass
@@ -282,7 +283,12 @@
def on_change_with_foo(self, name=None):
pass
+ @classmethod
+ def column_baz(cls, tables):
+ t, _ = tables[None]
+ return t.bar
+
Model.__setup__()
Model.__post_setup__()
- self.assertEqual(Model.test.on_change, {'foo', 'bar'})
+ self.assertEqual(Model.test.on_change, {'foo', 'bar', 'baz'})