diff --git a/CHANGELOG b/CHANGELOG index 37dadb577d..096f22d627 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Remove implicit field names in ModelStorage.search_read + Version 5.4.0 - 2019-11-04 * Bug fixes (see mercurial logs for details) * Improve tests on depends diff --git a/trytond/ir/action.py b/trytond/ir/action.py index a6d6ec3275..698af45967 100644 --- a/trytond/ir/action.py +++ b/trytond/ir/action.py @@ -276,6 +276,9 @@ class ActionMixin(ModelSQL): if getattr(Action, default_func, None): setattr(cls, default_func, partial(ActionMixin._default_action, name)) + cls.__rpc__.update({ + 'fetch_action': RPC(cache=dict(days=1)), + }) @staticmethod def _default_action(name): @@ -406,6 +409,11 @@ class ActionMixin(ModelSQL): groups = {g.id for a in actions for g in a.groups} return groups + @classmethod + def fetch_action(cls, action_id): + fields = list(cls._fields.keys()) + return cls.search_read([('action', '=', action_id)], fields, limit=1) + class ActionReport(ActionMixin, ModelSQL, ModelView): "Action report" diff --git a/trytond/model/modelstorage.py b/trytond/model/modelstorage.py index 744104ee2b..713e1872e7 100644 --- a/trytond/model/modelstorage.py +++ b/trytond/model/modelstorage.py @@ -508,8 +508,8 @@ class ModelStorage(Model): ''' records = cls.search(domain, offset=offset, limit=limit, order=order) - if not fields_names: - fields_names = list(cls._fields.keys()) + if fields_names is None: + fields_names = ['id'] if 'id' not in fields_names: fields_names.append('id') rows = cls.read(list(map(int, records)), fields_names) diff --git a/trytond/tests/test_modelstorage.py b/trytond/tests/test_modelstorage.py index 6e686b3b5b..13fbe6b46b 100644 --- a/trytond/tests/test_modelstorage.py +++ b/trytond/tests/test_modelstorage.py @@ -29,11 +29,13 @@ class ModelStorageTestCase(unittest.TestCase): self.assertTrue( all(x['id'] < y['id'] for x, y in zip(rows, rows[1:]))) - rows = ModelStorage.search_read([], order=[('name', 'ASC')]) + rows = ModelStorage.search_read( + [], order=[('name', 'ASC')], fields_names=['name']) self.assertTrue( all(x['name'] <= y['name'] for x, y in zip(rows, rows[1:]))) - rows = ModelStorage.search_read([], order=[('name', 'DESC')]) + rows = ModelStorage.search_read( + [], order=[('name', 'DESC')], fields_names=['name']) self.assertTrue( all(x['name'] >= y['name'] for x, y in zip(rows, rows[1:])))