changeset 5733f5ca617d in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=5733f5ca617d
description:
Check access on target only if related field has a target
The Dict field can use the relate syntax to access keys but it does not
have
any target model to check.
issue8298
review251291002
diffstat:
trytond/model/modelstorage.py | 6 ++++--
trytond/tests/access.py | 1 +
trytond/tests/test_access.py | 2 ++
3 files changed, 7 insertions(+), 2 deletions(-)
diffs (48 lines):
diff -r e2026d80eced -r 5733f5ca617d trytond/model/modelstorage.py
--- a/trytond/model/modelstorage.py Wed Apr 24 23:40:46 2019 +0200
+++ b/trytond/model/modelstorage.py Wed Apr 24 23:46:59 2019 +0200
@@ -445,8 +445,10 @@
if relate:
if len(domain) >= 4:
target = pool.get(domain[3])
+ elif hasattr(cls._fields[local], 'get_target'):
+ target = cls._fields[local].get_target()
else:
- target = cls._fields[local].get_target()
+ return
target_domain = [(relate,) + tuple(domain[1:])]
check_domain(target_domain, target, to_check)
elif not domain:
@@ -462,7 +464,7 @@
for oexpr, otype in order:
local, _, relate = oexpr.partition('.')
to_check[cls.__name__].add(local)
- if relate:
+ if relate and hasattr(cls._fields[local], 'get_target'):
target = cls._fields[local].get_target()
target_order = [(relate, otype)]
check_order(target_order, target, to_check)
diff -r e2026d80eced -r 5733f5ca617d trytond/tests/access.py
--- a/trytond/tests/access.py Wed Apr 24 23:40:46 2019 +0200
+++ b/trytond/tests/access.py Wed Apr 24 23:46:59 2019 +0200
@@ -14,6 +14,7 @@
(None, ""),
('test.access.relate', "Reference"),
])
+ dict_ = fields.Dict(None, "Dict")
class TestAccessRelate(ModelSQL):
diff -r e2026d80eced -r 5733f5ca617d trytond/tests/test_access.py
--- a/trytond/tests/test_access.py Wed Apr 24 23:40:46 2019 +0200
+++ b/trytond/tests/test_access.py Wed Apr 24 23:46:59 2019 +0200
@@ -299,7 +299,9 @@
TestAccess.read([record.id], ['relate.value'])
TestAccess.search([('relate.value', '=', 42)])
TestAccess.search([('reference.value', '=', 42, 'test.access.relate')])
+ TestAccess.search([('dict_.key', '=', 42)])
TestAccess.search([], order=[('relate.value', 'ASC')])
+ TestAccess.search([], order=[('dict_.key', 'ASC')])
@with_transaction(context=_context)
def test_no_access_relate(self):