[FIX] FieldMany2One: always_reload option should not prevent from
displaying the field original value that is a valid name_get. The always_reload perform an additional name_get that may crash due to access rights. Keeping the original value (coming from the fields view get) in a backup variable allows to fall back on this value when having issues with access rights. bzr revid: tde@openerp.com-20130530080218-0kvr36vwqki05rrw
This commit is contained in:
parent
4ab8585c57
commit
10807026ea
|
@ -3146,6 +3146,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
|||
instance.web.form.CompletionFieldMixin.init.call(this);
|
||||
this.set({'value': false});
|
||||
this.display_value = {};
|
||||
this.display_value_backup = {};
|
||||
this.last_search = [];
|
||||
this.floating = false;
|
||||
this.current_display = null;
|
||||
|
@ -3229,6 +3230,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
|||
);
|
||||
pop.on('write_completed', self, function(){
|
||||
self.display_value = {};
|
||||
self.display_value_backup = {};
|
||||
self.render_value();
|
||||
self.focus();
|
||||
});
|
||||
|
@ -3279,6 +3281,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
|||
if (self.last_search.length > 0) {
|
||||
if (self.last_search[0][0] != self.get("value")) {
|
||||
self.display_value = {};
|
||||
self.display_value_backup = {};
|
||||
self.display_value["" + self.last_search[0][0]] = self.last_search[0][1];
|
||||
self.reinit_value(self.last_search[0][0]);
|
||||
} else {
|
||||
|
@ -3344,6 +3347,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
|||
var item = ui.item;
|
||||
if (item.id) {
|
||||
self.display_value = {};
|
||||
self.display_value_backup = {};
|
||||
self.display_value["" + item.id] = item.name;
|
||||
self.reinit_value(item.id);
|
||||
} else if (item.action) {
|
||||
|
@ -3390,10 +3394,10 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
|||
self.display_value["" + self.get("value")] = data[0][1];
|
||||
self.render_value(true);
|
||||
}).fail( function (data, event) {
|
||||
// avoid displaying crash errors when having an invisible field
|
||||
if (self.get('effective_invisible')) {
|
||||
event.preventDefault();
|
||||
}
|
||||
// avoid displaying crash errors as many2One should be name_get compliant
|
||||
event.preventDefault();
|
||||
self.display_value["" + self.get("value")] = self.display_value_backup["" + self.get("value")];
|
||||
self.render_value(true);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -3437,9 +3441,13 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
|||
var self = this;
|
||||
if (value_ instanceof Array) {
|
||||
this.display_value = {};
|
||||
this.display_value_backup = {}
|
||||
if (! this.options.always_reload) {
|
||||
this.display_value["" + value_[0]] = value_[1];
|
||||
}
|
||||
else {
|
||||
this.display_value_backup["" + value_[0]] = value_[1];
|
||||
}
|
||||
value_ = value_[0];
|
||||
}
|
||||
value_ = value_ || false;
|
||||
|
@ -3450,6 +3458,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
|||
},
|
||||
add_id: function(id) {
|
||||
this.display_value = {};
|
||||
this.display_value_backup = {};
|
||||
this.reinit_value(id);
|
||||
},
|
||||
is_false: function() {
|
||||
|
|
Loading…
Reference in New Issue