diff --git a/partner_edit_restrict/__manifest__.py b/partner_edit_restrict/__manifest__.py index 3a4024df..fae61a65 100644 --- a/partner_edit_restrict/__manifest__.py +++ b/partner_edit_restrict/__manifest__.py @@ -1,12 +1,12 @@ # Copyright 2023 Quartile Limited -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Partner Edit Restrict", "category": "Partner", - "version": "15.0.1.0.0", + "version": "11.0.1.0.0", "author": "Quartile Limited", "website": "https://www.quartile.co", - "license": "LGPL-3", + "license": "AGPL-3", "depends": ["base"], "data": [ "views/res_partner_views.xml", diff --git a/partner_edit_restrict/models/res_partner.py b/partner_edit_restrict/models/res_partner.py index 9896a974..724b0d97 100644 --- a/partner_edit_restrict/models/res_partner.py +++ b/partner_edit_restrict/models/res_partner.py @@ -1,5 +1,5 @@ # Copyright 2023 Quartile Limited -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import _, fields, models from odoo.exceptions import UserError @@ -13,11 +13,15 @@ class ResPartner(models.Model): ) def write(self, values): - if self.env.user.has_group("base.group_system"): - return super(ResPartner, self).write(values) - if self.env.is_superuser(): - return super(ResPartner, self).write(values) - for record in self: - if record.restrict_edit: - raise UserError(_("You are not allowed to modify this partner record.")) - return super(ResPartner, self).write(values) + if ( + self.env.user.has_group("base.group_system") + or self.env.user._is_superuser() + ): + return super().write(values) + restricted_recs = self.filtered(lambda x: x.restrict_edit) + if restricted_recs: + names = ", ".join(restricted_recs.mapped("name")) + raise UserError( + _("You are not allowed to modify following partner(s): %s", names) + ) + return super().write(values)