Merge pull request #2683 from expsa/samir-aladawi-add-permission-to-delete-folders

[UPD] dms: add permission to delete files in dms
This commit is contained in:
SamirLADOUI-sa 2025-03-16 15:53:35 +01:00 committed by GitHub
commit 4826682a59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 0 deletions

View File

@ -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

View File

@ -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()

View File

@ -33,6 +33,9 @@
<field name="category_id" ref="dms.category_dms_security"/>
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]" />
</record>
<record id="group_dms_delete_file" model="res.groups">
<field name="name">Permission to delete Files</field>
</record>
<record id="group_dms_delete_directory" model="res.groups">
<field name="name">Permission to delete Folders/Directories</field>
</record>