World_Peace
Forum Expert
can somebody help me sa model code na ilalagay dito to not permit specific users on downloading and deleting the file
from odoo import models, api, exceptions
class Document(models.Model):
_inherit = 'ir.attachment'
@api.model
def create(self, values):
# Add your logic here to restrict specific users from creating files
if self.env.user.has_group('your_module.group_name'):
raise exceptions.UserError("You are not allowed to create files.")
return super(Document, self).create(values)
def write(self, values):
# Add your logic here to restrict specific users from updating files
if self.env.user.has_group('your_module.group_name'):
raise exceptions.UserError("You are not allowed to update files.")
return super(Document, self).write(values)
def unlink(self):
# Add your logic here to restrict specific users from deleting files
if self.env.user.has_group('your_module.group_name'):
raise exceptions.UserError("You are not allowed to delete files.")
return super(Document, self).unlink()
ir.attachment model to customize the behavior of file attachments in Odoo.create, write, and unlink methods to include custom logic for restricting specific users from creating, updating, and deleting files.'your_module.group_name' with the actual group name that you want to restrict from downloading and deleting files.'your_module.group_name' with the actual group name that you want to use for permission control. Additionally, you may need to adjust the logic based on your specific requirements and implementation details.