Skip to content

Commit

Permalink
Merge PR #528 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by guewen
  • Loading branch information
OCA-git-bot committed Sep 18, 2023
2 parents bcd89a6 + db24c87 commit 0c950fc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions base_import_async/models/base_import_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,17 @@ def _create_csv_attachment(self, fields, data, options, file_name):
writer.writerow(fields)
for row in data:
writer.writerow(row)
# create attachment
# create attachment. Remove default values from context
context = self.env.context
context_copy = {}
for key in context.keys():
if not key.startswith("default_"):
context_copy[key] = context[key]
datas = base64.encodebytes(f.getvalue().encode(encoding))
attachment = self.env["ir.attachment"].create(
{"name": file_name, "datas": datas}
attachment = (
self.env["ir.attachment"]
.with_context(**context_copy)
.create({"name": file_name, "datas": datas})
)
return attachment

Expand Down

0 comments on commit 0c950fc

Please sign in to comment.