Commit a8396514 authored by George Daramouskas's avatar George Daramouskas Committed by Jairo Llopis
Browse files

[MIG] Migration from 9.0 to 10.0 web_access_rule_buttons (#628)

* [MIG] Migration from 9.0 to 10.0

* Refactoring javascript code
parent 10f1b9be
......@@ -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
<https://github.com/OCA/
web/issues/new?body=module:%20
web_access_rule_buttons%0Aversion:%20
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
10.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
......
......@@ -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,
}
......@@ -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
......
......@@ -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);
}
}
}
});
});
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="assets_backend" name="web_access_rule_buttons assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_access_rule_buttons/static/src/js/web_access_rule_buttons.js"></script>
</xpath>
</template>
</data>
</openerp>
<odoo>
<template id="assets_backend" name="web_access_rule_buttons assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_access_rule_buttons/static/src/js/web_access_rule_buttons.js"></script>
</xpath>
</template>
</odoo>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment