1 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"
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"