Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Acces Error "Sorry, you are not allowed to access this document." ir.attachment

Avatar
odoo
1 Comment
Avatar
Discard
Avatar
odoo
-

Theres an issue about this:
https://github.com/odoo/odoo/pull/82111
This is the cause:
"Attachments that are uploaded on a record that isn't saved yet are
created with res_id set to 0. In the case of attachments linked through
a m2m rather than the usual (res_model, res_id), it means they may not
be readable afer the creation of the record, except by their creator.

Re-attaching them to the mailing / template at the end of the create()
call fixes the ownership."

I solved adding this in my custom module:
" @api.model
def create(self, vals):
templates = super(RoomsReservation,self).create(vals)
# fix attachment ownership
for template in templates:
if template.attachment_ids:
template.attachment_ids.write({'res_model': self._name, 'res_id': template.id})
return templates"

1 Answer
0
Avatar
odoo
Best Answer

Theres an issue about this:
https://github.com/odoo/odoo/pull/82111
This is the cause:
"Attachments that are uploaded on a record that isn't saved yet are
created with res_id set to 0. In the case of attachments linked through
a m2m rather than the usual (res_model, res_id), it means they may not
be readable afer the creation of the record, except by their creator.

Re-attaching them to the mailing / template at the end of the create()
call fixes the ownership."

I solved adding this in my custom module:
" @api.model
def create(self, vals):
templates = super(RoomsReservation,self).create(vals)
# fix attachment ownership
for template in templates:
if template.attachment_ids:
template.attachment_ids.write({'res_model': self._name, 'res_id': template.id})
return templates"

Avatar
Discard