mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[11.0][MIG] web_access_rule_buttons: Migration to 11.0
This commit is contained in:
32
web_access_rule_buttons/static/src/js/form_controller.js
Normal file
32
web_access_rule_buttons/static/src/js/form_controller.js
Normal 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);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user