diff --git a/base_import_async/models/base_import_import.py b/base_import_async/models/base_import_import.py index f208fb7888..29ccfe296c 100644 --- a/base_import_async/models/base_import_import.py +++ b/base_import_async/models/base_import_import.py @@ -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