summaryrefslogtreecommitdiff
path: root/odoo/models.py
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-03-06 11:11:29 +0000
committerSébastien Theys <seb@odoo.com>2020-03-06 16:15:44 +0000
commite3afe4d067e9e4eec54e0f0eadfd7316ae57dc99 (patch)
tree3708b51994a37a48bd9df04ffbbf78a6ce7a78f1 /odoo/models.py
parent2490676e16964eaaf5a7c5ecb2525883c15dc6ab (diff)
[IMP] models, (test_)mail, portal(_rating): remove `message_tree`
from `message_format` and from `_message_read_dict_postprocess`. The reading and initial formatting is done by `_message_read_dict_postprocess`, which has been renamed more simply to `_message_format` due to its new goal. This makes the methods easier to follow and does not increase the query count. It actually reduces it when the data were already in the cache, by not always reading them again. Part of task-2180311 PR: #43841
Diffstat (limited to 'odoo/models.py')
-rw-r--r--odoo/models.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/odoo/models.py b/odoo/models.py
index bbec718b5a3..a5d8ddb7900 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -2932,11 +2932,20 @@ Fields:
stored_fields.add(f.name)
self._read(stored_fields)
- # retrieve results from records; this takes values from the cache and
- # computes remaining fields
+ return self._read_format(fnames=fields, load=load)
+
+ def _read_format(self, fnames, load='_classic_read'):
+ """Returns a list of dictionaries mapping field names to their values,
+ with one dictionary per record that exists.
+
+ The output format is similar to the one expected from the `read` method.
+
+ The current method is different from `read` because it retrieves its
+ values from the cache without doing a query when it is avoidable.
+ """
data = [(record, {'id': record._ids[0]}) for record in self]
use_name_get = (load == '_classic_read')
- for name in fields:
+ for name in fnames:
convert = self._fields[name].convert_to_read
for record, vals in data:
# missing records have their vals empty