[11.0][MIG] web_access_rule_buttons: Migration to 11.0

This commit is contained in:
antonio
2019-04-10 09:20:12 +02:00
parent b5d1447ae8
commit 1afc15bd5c
14 changed files with 105 additions and 172 deletions

View File

@@ -0,0 +1,32 @@
/* Copyright 2016 Camptocamp SA
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
odoo.define("web_access_rule_buttons.main", function (require) {
"use strict";
var FormController = require("web.FormController");
FormController.include({
_update: function (state) {
return this._super(state).then(this.show_hide_buttons(state));
},
show_hide_buttons : function (state) {
var self = this;
return self._rpc({
model: this.modelName,
method: 'check_access_rule_all',
args: [[state.data.id], ["write"]],
}).then(function (accesses) {
self.show_hide_edit_button(accesses.write);
});
},
show_hide_edit_button : function (access) {
if (this.$buttons) {
var button = this.$buttons.find(".o_form_button_edit");
if (button) {
button.prop("disabled", !access);
}
}
},
});
});

View File

@@ -1,31 +0,0 @@
/*
* © 2016 Camptocamp SA
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
*/
odoo.define("web_access_rule_buttons.main", function(require) {
"use strict";
var FormView = require("web.FormView");
FormView.include({
load_record : function() {
return this._super.apply(this, arguments).then($.proxy(this.show_hide_buttons, this));
},
show_hide_buttons : function() {
var self = this;
this.dataset.call("check_access_rule_all", [ [ this.datarecord.id ], [ "write" ] ]).then(function(accesses) {
self.show_hide_edit_button(accesses.write);
});
},
show_hide_edit_button : function(access) {
if (this.$buttons) {
var button = this.$buttons.find(".o_form_button_edit");
if (button) {
button.prop("disabled", !access);
}
}
}
});
});