Skip to Content
Menu
Dette spørgsmål er blevet anmeldt

In the recruitment module, when a job applicant submits the job form with file attachments, the odoobot attaches the files to the new applicant. How can I achieve the same thing via the Odoo External API?

version 13.0

Avatar
Kassér
Forfatter Bedste svar
# I solved this problem this way:

from base64 import b64encode

data = file.read()

self.models.execute_kw(
db,
uid,
password,
"ir.attachment",
"create",
[
{
"res_model": model_name,
"res_id": model_id,
"type": "binary",
"name": name,
"display_name": name,
"mimetype": mimetype,
"datas": b64encode(data).decode("utf-8"),
},
],
)
Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
1
aug. 24
4571
2
maj 22
10335
0
mar. 15
3261
1
okt. 24
2578
3
feb. 23
6855