Merge pull request #967 from xmo-odoo/master-id-type-xmo

Raise exception when a DB request fetches ids it was not asked for
This commit is contained in:
xmo-odoo 2014-07-07 13:23:50 +02:00
commit cd7e9a98d4
2 changed files with 14 additions and 6 deletions

View File

@ -86,14 +86,14 @@ instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
// add input
if (!self.$el.find(".oe_justgage_edit").size()) {
$div = $('<div class="oe_justgage_edit" style="z-index:1"/>');
var $div = $('<div class="oe_justgage_edit" style="z-index:1"/>');
$div.css({
'text-align': 'center',
'position': 'absolute',
'width': self.$el.outerWidth() + 'px',
'top': (self.$el.outerHeight()/2-5) + 'px'
});
$input = $('<input/>').val(gauge_value);
var $input = $('<input/>').val(gauge_value);
$input.css({
'text-align': 'center',
'margin': 'auto',
@ -101,10 +101,10 @@ instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
});
$div.append($input);
if (self.options.on_click_label) {
$post_input = $('<span style="color: #000000;">' + self.options.on_click_label + '</span>');
var $post_input = $('<span style="color: #000000;">' + self.options.on_click_label + '</span>');
$div.append($post_input);
}
self.$el.prepend($div)
self.$el.prepend($div);
$input.focus()
.keydown(function (event) {
@ -148,7 +148,7 @@ instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
if (this.options.force_set && !+input_value) {
$svg.fadeTo(0, 0.3);
$div = $('<div/>').text(_t("Click to change value"));
var $div = $('<div/>').text(_t("Click to change value"));
$div.css(css);
this.$el.append($div);
}

View File

@ -3231,8 +3231,16 @@ class BaseModel(object):
record._cache.update(record._convert_to_cache(vals))
# store failed values in cache for the records that could not be read
missing = self - self.browse(ids)
fetched = self.browse(ids)
missing = self - fetched
if missing:
extras = fetched - self
if extras:
raise AccessError(
_("Database fetch misses ids ({}) and has extra ids ({}), may be caused by a type incoherence in a previous request").format(
', '.join(map(repr, missing._ids)),
', '.join(map(repr, extras._ids)),
))
# store an access error exception in existing records
exc = AccessError(
_('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % \