Hi there,
I'm having an issue with m2m attachment in Odoo 16 CE. I've created a custom module that includes an m2m attachment field. The creator of the record can access the document, while other users cannot and receive an error message that says "Sorry, you are not allowed to access this document." If I save the record first and attach it, no issues are found. However, there are no record rules or access rules defined. I tested this in multiple environments including fresh odoo16 instant. When I searched for a solution to this issue, I found a similar bug with mail_template and fixed it with a _fix_attachment_ownership function in the creation of the record. (addons/mail/models/mail_template.py)
Does anyone else have this issue with m2m attachment in other models, or did I do something wrong?
Any help is highly appreciated.
my class is :
class EmployeeApproval(models.Model):
_name = 'employee.approval.info'
_rec_name = 'employee_id'
_inherit = ['mail.thread']
_description = 'Employee Approval Info'
employee_id = fields.Many2one(comodel_name='hr.employee', string="Employee", ondelete='cascade',help='Select corresponding Employee')
attachment_id = fields.Many2many('ir.attachment', 'approval_attachment_rel', 'approval_ref',
'attach_ref1',
string="Attachment(pdf)",
help='Attach any documents if required.')