diff --git a/CHANGELOG b/CHANGELOG index c48209a03d..1d3af965f0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/trytond/model/fields/field.py b/trytond/model/fields/field.py index a2809916bd..b0a68b20b2 100644 --- a/trytond/model/fields/field.py +++ b/trytond/model/fields/field.py @@ -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] = '' diff --git a/trytond/model/modelview.py b/trytond/model/modelview.py index d0b9c5786c..36238457c2 100644 --- a/trytond/model/modelview.py +++ b/trytond/model/modelview.py @@ -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: