Remove id to on_change calls that are cached

issue8234
review275131002
This commit is contained in:
Cédric Krier
2019-04-08 10:14:39 +02:00
parent 0fbf5cecd2
commit 722db3252a
3 changed files with 16 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
* Do not set id for on_change calls if cached
* Add cache on RPC
* Remove support for Python 3.4
* Allow to update record when importing data
+9
View File
@@ -435,6 +435,15 @@ class Field(object):
'sortable': hasattr(model, 'search'),
}
# Add id to on_change's if they are not cached
# Not having the id increase the efficiency of the cache
for method in ['on_change', 'on_change_with']:
changes = definition[method]
if changes:
method_name = method + '_' + self.name
if not model.__rpc__[method_name].cache:
changes.append('id')
name = '%s,%s' % (model.__name__, self.name)
for attr, ttype in [('string', 'field'), ('help', 'help')]:
definition[attr] = ''
+6 -1
View File
@@ -603,7 +603,12 @@ class ModelView(Model):
change = cls.__change_buttons[button_name]
if change:
element.set('change', encoder.encode(list(change)))
change = list(change)
# Add id to change if the button is not cached
# Not having the id increase the efficiency of the cache
if cls.__rpc__[button_name].cache:
change.append('id')
element.set('change', encoder.encode(change))
if not is_instance_method(cls, button_name):
element.set('type', 'class')
else: