You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
807 B

  1. /*
  2. * © 2016 Camptocamp SA
  3. * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
  4. */
  5. odoo.define("web_access_rule_buttons.main", function(require) {
  6. "use strict";
  7. var FormView = require("web.FormView");
  8. FormView.include({
  9. load_record : function() {
  10. return this._super.apply(this, arguments).then($.proxy(this.show_hide_buttons, this));
  11. },
  12. show_hide_buttons : function() {
  13. var self = this;
  14. this.dataset.call("check_access_rule_all", [ [ this.datarecord.id ], [ "write" ] ]).then(function(accesses) {
  15. self.show_hide_edit_button(accesses.write);
  16. });
  17. },
  18. show_hide_edit_button : function(access) {
  19. if (this.$buttons) {
  20. var button = this.$buttons.find(".o_form_button_edit");
  21. if (button) {
  22. button.prop("disabled", !access);
  23. }
  24. }
  25. }
  26. });
  27. });