From 598053bd3564d4422edcc953b5aa59f8f9efc5fa Mon Sep 17 00:00:00 2001 From: Samir Ladoui Date: Sun, 16 Mar 2025 15:52:18 +0100 Subject: [PATCH] [UPD] dms: add permission to delete files in dms --- odex25_dms/dms/i18n/ar_001.po | 11 +++++++++++ odex25_dms/dms/models/document.py | 7 +++++++ odex25_dms/dms/security/security.xml | 3 +++ 3 files changed, 21 insertions(+) diff --git a/odex25_dms/dms/i18n/ar_001.po b/odex25_dms/dms/i18n/ar_001.po index 6848ec65c..098d9ebd6 100644 --- a/odex25_dms/dms/i18n/ar_001.po +++ b/odex25_dms/dms/i18n/ar_001.po @@ -2694,6 +2694,11 @@ msgstr "مسار جيسون" msgid "Path Names" msgstr "اسم المسار" +#. module: dms +#: model:res.groups,name:dms.group_dms_delete_file +msgid "Permission to delete Files" +msgstr "صلاحية حذف الملفات" + #. module: dms #: model:res.groups,name:dms.group_dms_delete_directory msgid "Permission to delete Folders/Directories" @@ -3571,6 +3576,12 @@ msgstr "امكانية التعديل " msgid "Write a tooltip for the action here" msgstr "اكتب تلميحًا للإجراء هنا" +#. module: dms +#: code:addons/dms/models/document.py:0 +#, python-format +msgid "You are not allowed to delete a file!" +msgstr "ليس مسموح لك بحذف ملف!" + #. module: dms #: code:addons/dms/models/directory.py:0 #, python-format diff --git a/odex25_dms/dms/models/document.py b/odex25_dms/dms/models/document.py index 7b653dff4..980612f4d 100644 --- a/odex25_dms/dms/models/document.py +++ b/odex25_dms/dms/models/document.py @@ -695,6 +695,13 @@ class Document(models.Model): self.mapped('attachment_id').write(attachment_dict) return write_result + + def unlink(self): + if not self.env.user.has_group("dms.group_dms_delete_file") and not self.env.user.id == 1: + raise ValidationError( + _("You are not allowed to delete a file!") + ) + return super(Document, self).unlink() def _process_activities(self, attachment_id): self.ensure_one() diff --git a/odex25_dms/dms/security/security.xml b/odex25_dms/dms/security/security.xml index e68f81189..d8996f41e 100644 --- a/odex25_dms/dms/security/security.xml +++ b/odex25_dms/dms/security/security.xml @@ -33,6 +33,9 @@ + + Permission to delete Files + Permission to delete Folders/Directories