Browse Source

avoid multi call to the server in case of view list editable + quick edition

fix context on view list for quick edition
pull/236/head
Pierre Verkest 9 years ago
parent
commit
924756ba8a
  1. 7
      web_widget_boolean_switch/static/src/js/web_widget_boolean_switch.js

7
web_widget_boolean_switch/static/src/js/web_widget_boolean_switch.js

@ -63,7 +63,7 @@ openerp.web_widget_boolean_switch = function(instance){
// and we are not in edit mode. // and we are not in edit mode.
// We could use this.view.get('actual_mode') which sons // We could use this.view.get('actual_mode') which sons
// semantically better, possible values are // semantically better, possible values are
// at least `view`, `edit`, `create`, ...? to avoid doupt
// at least `view`, `edit`, `create`... ? to avoid doupt
// using bool seems safer! // using bool seems safer!
if(!this.get('effective_readonly')){ if(!this.get('effective_readonly')){
this.internal_set_value(state); this.internal_set_value(state);
@ -76,6 +76,9 @@ openerp.web_widget_boolean_switch = function(instance){
this.switcher = new openerp.instances.instance0.web.BooleanSwitchWidget( this.switcher = new openerp.instances.instance0.web.BooleanSwitchWidget(
this.$checkbox, options, _.bind(function(event, state) { this.$checkbox, options, _.bind(function(event, state) {
// get in mind that in case of view list editable
// actual_mode is undefined...
if(this.view.get('actual_mode') === 'view'){
var id = this.view.dataset.ids[this.view.dataset.index]; var id = this.view.dataset.ids[this.view.dataset.index];
var values = {}; var values = {};
values[this.name] = state; values[this.name] = state;
@ -85,6 +88,7 @@ openerp.web_widget_boolean_switch = function(instance){
model.call('write', [[id], values], model.call('write', [[id], values],
{'context': this.build_context()}); {'context': this.build_context()});
this.internal_set_value(state, {'silent': true}); this.internal_set_value(state, {'silent': true});
}
}, this)); }, this));
this.on("change:effective_readonly", this, this.switcher_states); this.on("change:effective_readonly", this, this.switcher_states);
this._super(); this._super();
@ -130,6 +134,7 @@ openerp.web_widget_boolean_switch = function(instance){
var values = {}; var values = {};
values[this.field.name] = state; values[this.field.name] = state;
var context = py.eval(field.context); var context = py.eval(field.context);
_.extend(context, view.session.user_context)
var model = new openerp.instances.instance0.web.Model(this.view.model); var model = new openerp.instances.instance0.web.Model(this.view.model);
model.call('write', [[id], values], model.call('write', [[id], values],
{'context': context}); {'context': context});

Loading…
Cancel
Save