Open shameemalim opened 1 year ago
Are you setting bin_size=True
in the context? Which field of ir.attachment
are you reading?
i m reading 'datas' field.. i tried with bin_size=True and bin_size=False both
any hope?
List
final attachmentData = attachmentInfo.bytes ??
await File(attachmentInfo.path!).readAsBytes();
print('Read attachmentData: $attachmentData');
if (attachmentData != null) {
final attachment = await orpc?.callKw({
'model': 'ir.attachment',
'method': 'create',
'args': [
{
'name': attachmentInfo.name,
'type': 'binary',
'datas': base64Encode(attachmentData),
'res_model': 'crm.lead',
'res_id': widget.messageId,
'mimetype': attachmentInfo.extension != null
? 'application/${attachmentInfo.extension}'
: 'application/octet-stream',
}
],
'kwargs': {
'context': {'bin_size': true}
},
});
print('Created attachment with ID: $attachment');
attachmentIds.add(attachment);
} else {
print('Failed to read attachment data.');
}
} else {
print('No attachment selected.');
}
print('Creating message...');
final message = await orpc?.callKw({
'model': 'mail.message',
'method': 'create',
'args': [
{
'model': 'crm.lead',
'body': _responseController.text,
'res_id': widget.messageId,
'message_type': 'comment',
'subtype_id': 1,
'attachment_ids': attachmentIds.isNotEmpty
? [
[6, 0, attachmentIds]
]
: [],
}
],
'kwargs': {
'context': {'bin_size': true}
},
});
if (message != null) {
print('Created message with ID: $message');
_responseController.clear();
setState(() {
_attachmentResult = null;
});
fetchResponse(); // Refresh the messages list
}
check this one use filepicker for this
any hope?
once check the code i mentioned
i am trying to get datas from ir.attachment but instead of base64 i'm getting only size of the file