diff --git a/odex25_dms/dms_security_inherit/__init__.py b/odex25_dms/dms_security_inherit/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/odex25_dms/dms_security_inherit/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/odex25_dms/dms_security_inherit/__manifest__.py b/odex25_dms/dms_security_inherit/__manifest__.py new file mode 100644 index 000000000..f344d70ed --- /dev/null +++ b/odex25_dms/dms_security_inherit/__manifest__.py @@ -0,0 +1,16 @@ +{ + 'name': 'DMS Security Inherit', + 'version': '1.0', + 'author': '', + 'website': '', + 'license': 'LGPL-3', + 'depends': ['dms','documents','base'], + 'data': [ + 'security/security.xml', + + ], + + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/odex25_dms/dms_security_inherit/models/__init__.py b/odex25_dms/dms_security_inherit/models/__init__.py new file mode 100644 index 000000000..9186ee3ad --- /dev/null +++ b/odex25_dms/dms_security_inherit/models/__init__.py @@ -0,0 +1 @@ +from . import model diff --git a/odex25_dms/dms_security_inherit/models/model.py b/odex25_dms/dms_security_inherit/models/model.py new file mode 100644 index 000000000..fad13397e --- /dev/null +++ b/odex25_dms/dms_security_inherit/models/model.py @@ -0,0 +1,15 @@ +from odoo import models, api, _ +from odoo.exceptions import AccessError + + +class DocumentsDocument(models.Model): + _inherit = 'documents.document' + + @api.model_create_multi + def create(self, vals_list): + if not self.env.su: + if not self.env.user.has_group('dms.group_dms_manager'): + raise AccessError( + _("You don't have permission to create new documents. Only DMS Managers can upload new files.") + ) + return super(DocumentsDocument, self).create(vals_list) \ No newline at end of file diff --git a/odex25_dms/dms_security_inherit/security/security.xml b/odex25_dms/dms_security_inherit/security/security.xml new file mode 100644 index 000000000..f91a4b60c --- /dev/null +++ b/odex25_dms/dms_security_inherit/security/security.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file