diff --git a/web_access_rule_buttons/README.rst b/web_access_rule_buttons/README.rst index 85d08853..671b1609 100644 --- a/web_access_rule_buttons/README.rst +++ b/web_access_rule_buttons/README.rst @@ -19,7 +19,7 @@ Now, the user won't be able to click on the Edit button. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/162/9.0 + :target: https://runbot.odoo-community.org/runbot/162/10.0 Known issues / Roadmap ====================== @@ -37,7 +37,7 @@ help us smashing it by providing a detailed and welcomed `feedback `_. +10.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. Credits ======= diff --git a/web_access_rule_buttons/__manifest__.py b/web_access_rule_buttons/__manifest__.py index 5e3d06c5..3867cce0 100644 --- a/web_access_rule_buttons/__manifest__.py +++ b/web_access_rule_buttons/__manifest__.py @@ -4,7 +4,7 @@ {'name': 'Web Access Rules Buttons', 'summary': 'Disable Edit button if access rules prevent this action', - 'version': '9.0.1.0.0', + 'version': '10.0.1.0.0', 'author': 'Camptocamp,Odoo Community Association (OCA)', 'license': 'AGPL-3', 'category': 'Web', @@ -13,5 +13,5 @@ 'website': 'http://www.camptocamp.com', 'data': ['views/web_access_rule_buttons.xml', ], - 'installable': False, + 'installable': True, } diff --git a/web_access_rule_buttons/models.py b/web_access_rule_buttons/models.py index 3817f648..dc782feb 100644 --- a/web_access_rule_buttons/models.py +++ b/web_access_rule_buttons/models.py @@ -2,7 +2,7 @@ # © 2016 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) -from openerp import models, api, exceptions +from odoo import models, api, exceptions @api.multi diff --git a/web_access_rule_buttons/static/src/js/web_access_rule_buttons.js b/web_access_rule_buttons/static/src/js/web_access_rule_buttons.js index 4d31aeb4..d5fc53b7 100644 --- a/web_access_rule_buttons/static/src/js/web_access_rule_buttons.js +++ b/web_access_rule_buttons/static/src/js/web_access_rule_buttons.js @@ -2,43 +2,30 @@ * © 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 core = require('web.core'); - - var FormView = require('web.FormView'); - var ListView = require('web.ListView'); - - FormView.include({ - - load_record: function() { - var self = this; - return this._super.apply(this, arguments) - .then(function() { - self.show_hide_buttons() - }); - }, - - 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('.oe_form_button_edit'); - if(button) { - button.prop('disabled', !access); - } - } - } - - }); - +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); + } + } + } + }); }); diff --git a/web_access_rule_buttons/views/web_access_rule_buttons.xml b/web_access_rule_buttons/views/web_access_rule_buttons.xml index 98e03de8..de7a0189 100644 --- a/web_access_rule_buttons/views/web_access_rule_buttons.xml +++ b/web_access_rule_buttons/views/web_access_rule_buttons.xml @@ -1,10 +1,8 @@ - - - - - + + +