From 25a3c4bc306609c76d439116b1dce6bd4979e42b Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 17 Jan 2017 14:07:27 +0100 Subject: [PATCH] [FIX] mass_editing: Allow to remove sidebar action As 65a1579 did for the creation, this commit does for the unlink, allowing to non admin users to remove the sidebar action. --- mass_editing/models/mass_object.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/mass_editing/models/mass_object.py b/mass_editing/models/mass_object.py index 94abce72a..f9ff47ef2 100644 --- a/mass_editing/models/mass_object.py +++ b/mass_editing/models/mass_object.py @@ -2,7 +2,6 @@ # © 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp.exceptions import UserError from openerp import api, fields, models, _ @@ -81,14 +80,10 @@ class MassObject(models.Model): @api.multi def unlink_action(self): - for mass in self: - try: - if mass.ref_ir_act_window_id: - mass.ref_ir_act_window_id.unlink() - if mass.ref_ir_value_id: - mass.ref_ir_value_id.unlink() - except: - raise UserError(_("Deletion of the action record failed.")) + # We make sudo as any user with rights in this model should be able + # to delete the action, not only admin + self.mapped('ref_ir_act_window_id').sudo().unlink() + self.mapped('ref_ir_value_id').sudo().unlink() return True @api.multi