diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py index a4590df883..8b1f2fac0a 100644 --- a/base_export_async/models/delay_export.py +++ b/base_export_async/models/delay_export.py @@ -90,14 +90,18 @@ def export(self, params): export_record = self.sudo().create({"user_ids": [(6, 0, users.ids)]}) name = "{}.{}".format(model_name, export_format) - attachment = self.env["ir.attachment"].create( - { - "name": name, - "datas": base64.b64encode(content), - "type": "binary", - "res_model": self._name, - "res_id": export_record.id, - } + attachment = ( + self.env["ir.attachment"] + .sudo() + .create( + { + "name": name, + "datas": base64.b64encode(content), + "type": "binary", + "res_model": self._name, + "res_id": export_record.id, + } + ) ) url = "{}/web/content/ir.attachment/{}/datas/{}?download=true".format( diff --git a/base_export_async/tests/test_base_export_async.py b/base_export_async/tests/test_base_export_async.py index e1b5c3579a..c6909ebbd0 100644 --- a/base_export_async/tests/test_base_export_async.py +++ b/base_export_async/tests/test_base_export_async.py @@ -21,7 +21,7 @@ "domain": [], "context": {"lang": "en_US", "tz": "Europe/Brussels", "uid": 2}, "import_compat": false, - "user_ids": [2] + "user_ids": [6] }""" } @@ -35,7 +35,7 @@ "domain": [], "context": {"lang": "en_US", "tz": "Europe/Brussels", "uid": 2}, "import_compat": false, - "user_ids": [2] + "user_ids": [6] }""" }