mirror of https://github.com/OCA/web.git
[MIG] Migration from 9.0 to 10.0 web_access_rule_buttons (#628)
* [MIG] Migration from 9.0 to 10.0 * Refactoring javascript codepull/1243/head
parent
e990de59a2
commit
77b6001a98
|
@ -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
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||||
:alt: Try me on Runbot
|
: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
|
Known issues / Roadmap
|
||||||
======================
|
======================
|
||||||
|
@ -37,7 +37,7 @@ help us smashing it by providing a detailed and welcomed `feedback
|
||||||
<https://github.com/OCA/
|
<https://github.com/OCA/
|
||||||
web/issues/new?body=module:%20
|
web/issues/new?body=module:%20
|
||||||
web_access_rule_buttons%0Aversion:%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
|
Credits
|
||||||
=======
|
=======
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
{'name': 'Web Access Rules Buttons',
|
{'name': 'Web Access Rules Buttons',
|
||||||
'summary': 'Disable Edit button if access rules prevent this action',
|
'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)',
|
'author': 'Camptocamp,Odoo Community Association (OCA)',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'Web',
|
'category': 'Web',
|
||||||
|
@ -13,5 +13,5 @@
|
||||||
'website': 'http://www.camptocamp.com',
|
'website': 'http://www.camptocamp.com',
|
||||||
'data': ['views/web_access_rule_buttons.xml',
|
'data': ['views/web_access_rule_buttons.xml',
|
||||||
],
|
],
|
||||||
'installable': False,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# © 2016 Camptocamp SA
|
# © 2016 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
# 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
|
@api.multi
|
||||||
|
|
|
@ -2,43 +2,30 @@
|
||||||
* © 2016 Camptocamp SA
|
* © 2016 Camptocamp SA
|
||||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
*/
|
*/
|
||||||
odoo.define('web_access_rule_buttons.main', function (require) {
|
odoo.define("web_access_rule_buttons.main", function(require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var core = require('web.core');
|
var FormView = require("web.FormView");
|
||||||
|
|
||||||
var FormView = require('web.FormView');
|
|
||||||
var ListView = require('web.ListView');
|
|
||||||
|
|
||||||
FormView.include({
|
FormView.include({
|
||||||
|
|
||||||
load_record : function() {
|
load_record : function() {
|
||||||
var self = this;
|
return this._super.apply(this, arguments).then($.proxy(this.show_hide_buttons, this));
|
||||||
return this._super.apply(this, arguments)
|
|
||||||
.then(function() {
|
|
||||||
self.show_hide_buttons()
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
show_hide_buttons : function() {
|
show_hide_buttons : function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.dataset.call('check_access_rule_all',
|
this.dataset.call("check_access_rule_all", [ [ this.datarecord.id ], [ "write" ] ]).then(function(accesses) {
|
||||||
[[this.datarecord.id],
|
|
||||||
['write']])
|
|
||||||
.then(function(accesses) {
|
|
||||||
self.show_hide_edit_button(accesses.write);
|
self.show_hide_edit_button(accesses.write);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
show_hide_edit_button : function(access) {
|
show_hide_edit_button : function(access) {
|
||||||
if (this.$buttons) {
|
if (this.$buttons) {
|
||||||
var button = this.$buttons.find('.oe_form_button_edit');
|
var button = this.$buttons.find(".o_form_button_edit");
|
||||||
if (button) {
|
if (button) {
|
||||||
button.prop('disabled', !access);
|
button.prop("disabled", !access);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<openerp>
|
<odoo>
|
||||||
<data>
|
|
||||||
<template id="assets_backend" name="web_access_rule_buttons assets" inherit_id="web.assets_backend">
|
<template id="assets_backend" name="web_access_rule_buttons assets" inherit_id="web.assets_backend">
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<script type="text/javascript" src="/web_access_rule_buttons/static/src/js/web_access_rule_buttons.js"></script>
|
<script type="text/javascript" src="/web_access_rule_buttons/static/src/js/web_access_rule_buttons.js"></script>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
</data>
|
</odoo>
|
||||||
</openerp>
|
|
||||||
|
|
Loading…
Reference in New Issue