Skip to content

Commit ccd4e0f

Browse files
[MIG] base_export_async: Migration to 17.0
1 parent 3faab6c commit ccd4e0f

17 files changed

Lines changed: 135 additions & 68 deletions

base_export_async/README.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ Contributors
6868

6969
- Arnaud Pineux (ACSONE SA/NV) authored the initial prototype.
7070
- Guewen Baconnier (Camptocamp)
71+
- Stéphane Mangin (ACSONE SA/NV)
72+
73+
Other credits
74+
-------------
75+
76+
The migration of this module from 16.0 to 17.0 was financially supported
77+
by:
78+
79+
- ACSONE SA/NV (https://www.acsone.eu/)
7180

7281
Maintainers
7382
-----------

base_export_async/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Base Export Async",
66
"summary": "Asynchronous export with job queue",
7-
"version": "16.0.1.2.0",
7+
"version": "17.0.1.0.0",
88
"license": "AGPL-3",
99
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",
1010
"website": "https://github.com/OCA/queue",
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo noupdate="1">
3-
<record id="attachment_ttl" model="ir.config_parameter">
4-
<field name="key">attachment.ttl</field>
5-
<field name="value">7</field>
6-
</record>
3+
<record id="attachment_ttl" model="ir.config_parameter">
4+
<field name="key">attachment.ttl</field>
5+
<field name="value">7</field>
6+
</record>
77
</odoo>

base_export_async/data/cron.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo>
3-
<record id="to_delete_attachment" model="ir.cron">
4-
<field name="name">Delete Generated Exports</field>
5-
<field name="model_id" ref="model_delay_export" />
6-
<field name="state">code</field>
7-
<field name="code">model.cron_delete()</field>
8-
<field name='interval_number'>1</field>
9-
<field name='interval_type'>days</field>
10-
<field name="numbercall">-1</field>
11-
</record>
3+
<record id="to_delete_attachment" model="ir.cron">
4+
<field name="name">Delete Generated Exports</field>
5+
<field name="model_id" ref="model_delay_export" />
6+
<field name="state">code</field>
7+
<field name="code">model.cron_delete()</field>
8+
<field name='interval_number'>1</field>
9+
<field name='interval_type'>days</field>
10+
<field name="numbercall">-1</field>
11+
</record>
1212
</odoo>
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo noupdate="1">
3-
<record id="delay_export_mail_template" model="mail.template">
4-
<field name="name">Delay Export</field>
5-
<field
3+
<record id="delay_export_mail_template" model="mail.template">
4+
<field name="name">Delay Export</field>
5+
<field
66
name="subject"
77
>Export {{ object.model_description }} {{ datetime.date.today() }}</field>
8-
<field name="model_id" ref="base_export_async.model_delay_export" />
9-
<field name="auto_delete" eval="True" />
10-
<field name="body_html" type="html">
11-
<p>Your export is available <a
8+
<field name="model_id" ref="base_export_async.model_delay_export" />
9+
<field name="auto_delete" eval="True" />
10+
<field name="body_html" type="html">
11+
<p>Your export is available <a
1212
t-attf-href="{{ object.url }}"
1313
target="_blank"
1414
>here</a>.</p>
15-
<p>It will be automatically deleted the <t
16-
t-out="object.expiration_date"
17-
/>.</p>
18-
<br />
19-
<p>
20-
<span
15+
<p>It will be automatically deleted the <t t-out="object.expiration_date" />.</p>
16+
<br />
17+
<p>
18+
<span
2119
style="color: #808080;"
2220
>This is an automated message please do not reply.</span>
23-
</p>
24-
</field>
25-
</record>
21+
</p>
22+
</field>
23+
</record>
2624
</odoo>

base_export_async/export.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2026 ACSONE SA/NV
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
"""These classes are a response to the use of initial export controllers
5+
in the export async job.
6+
7+
It is used to avoid an issue when the export async job is executed
8+
without a proper inbound object.
9+
"""
10+
11+
from odoo.addons.web.controllers.export import CSVExport as CSVExportController
12+
from odoo.addons.web.controllers.export import ExcelExport as ExcelExportController
13+
from odoo.addons.web.controllers.export import ExportFormat
14+
15+
16+
class CSVExport(ExportFormat):
17+
@property
18+
def content_type(self):
19+
return CSVExportController.content_type.fget(self)
20+
21+
@property
22+
def extension(self):
23+
return CSVExportController.extension.fget(self)
24+
25+
def from_data(self, fields, rows):
26+
return CSVExportController.from_data(self, fields, rows)
27+
28+
29+
class ExcelExport(ExportFormat):
30+
@property
31+
def content_type(self):
32+
return ExcelExportController.content_type.fget(self)
33+
34+
@property
35+
def extension(self):
36+
return ExcelExportController.extension.fget(self)
37+
38+
def from_group_data(self, fields, groups):
39+
return ExcelExportController.from_group_data(self, fields, groups)
40+
41+
def from_data(self, fields, rows):
42+
return ExcelExportController.from_data(self, fields, rows)

base_export_async/models/delay_export.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from odoo import _, api, fields, models
1111
from odoo.exceptions import UserError
1212

13-
from odoo.addons.web.controllers.export import CSVExport, ExcelExport
13+
from ..export import CSVExport, ExcelExport
1414

1515

1616
class DelayExport(models.Model):
@@ -80,7 +80,13 @@ def export(self, params):
8080
* import_compat: if the export is export/import compatible (boolean)
8181
* user_ids: optional list of user ids who receive the file
8282
"""
83-
content = self._get_file_content(params)
83+
# Use a user context to avoid permission errors when accessing system models
84+
# (e.g., res.currency) during export generation
85+
if self.env.user and self.env.user.id:
86+
user = self.env.user
87+
else:
88+
user = self.env.ref("base.user_admin")
89+
content = self.with_user(user)._get_file_content(params)
8490

8591
items = operator.itemgetter("model", "context", "format", "user_ids")(params)
8692
model_name, context, export_format, user_ids = items
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
- Arnaud Pineux (ACSONE SA/NV) authored the initial prototype.
22
- Guewen Baconnier (Camptocamp)
3+
- Stéphane Mangin (ACSONE SA/NV)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The migration of this module from 16.0 to 17.0 was financially supported by:
2+
3+
- ACSONE SA/NV (<https://www.acsone.eu/>)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Standard Export can be delayed in asynchronous jobs executed in the
2-
background and then send by email to the user.
1+
Standard Export can be delayed in asynchronous jobs executed in the background and then
2+
send by email to the user.

0 commit comments

Comments
 (0)