Hello Guys!!!
I have a computed field One2Many.
I have defined it like this:
attachment_ids = fields.One2many('ir.attachment', 'attachment_case_id', string="Attachement", compute=_computed_field)
And the function is:
def _compute_attachment_case(self):
for attachment in self :
mail_ids = self.env['callim.mail'].search([('dossier_id','=',attachment.id)])
if mail_ids :
for mail in mail_ids :
attachment_ids = self.env['ir.attachment'].search([('res_id','=', mail.id),('res_model','=','callim.mail')])
current_case_id = self.id
current_case_type = self.type_id.id
if attachment_ids :
for attach in attachment_ids[-1:]:
attachment.write({'attachment_ids': [(0,0, {
'attachment_case_id' : current_case_id,
'datas' : attach.datas,
'description' : attach.description,
'type_id' : attach.type_id.id,
'type_case' : current_case_type,
})]})
The function is called and functionning well but the result does not Write in the field!!! Even if i tried to add it as default values :/
Can anyone help please. Need Help please