diff --git a/base_import_async/models/base_import_import.py b/base_import_async/models/base_import_import.py index de08c5efb1..dba862b531 100644 --- a/base_import_async/models/base_import_import.py +++ b/base_import_async/models/base_import_import.py @@ -88,9 +88,14 @@ 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( + attachment = self.env["ir.attachment"].with_context(context_copy).create( {"name": file_name, "datas": datas} ) return attachment