Browse Source

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

* [MIG] Migration from 9.0 to 10.0

* Refactoring javascript code
pull/1243/head
George Daramouskas 8 years ago
committed by antonio
parent
commit
77b6001a98
  1. 4
      web_access_rule_buttons/README.rst
  2. 4
      web_access_rule_buttons/__manifest__.py
  3. 2
      web_access_rule_buttons/models.py
  4. 65
      web_access_rule_buttons/static/src/js/web_access_rule_buttons.js
  5. 16
      web_access_rule_buttons/views/web_access_rule_buttons.xml

4
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
<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
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,
}

2
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

65
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);
}
}
}
});
});

16
web_access_rule_buttons/views/web_access_rule_buttons.xml

@ -1,10 +1,8 @@
<?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>
Loading…
Cancel
Save