Skip to content

Commit f4475d7

Browse files
[IMP] export_async_schedule: Migration to 15.0
1 parent 4bf39bd commit f4475d7

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

export_async_schedule/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Scheduled Asynchronous Export",
66
"summary": "Generate and send exports by emails on a schedule",
7-
"version": "12.0.1.0.0",
7+
"version": "15.0.1.0.0",
88
"author": "Camptocamp, Odoo Community Association (OCA)",
99
"license": "AGPL-3",
1010
"website": "https://github.com/OCA/queue",

export_async_schedule/models/export_async_schedule.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,15 @@ def run_schedule(self):
7777
record.next_execution = record._compute_next_date()
7878

7979
def _compute_next_date(self):
80+
next_execution = self.next_execution
81+
if next_execution < datetime.now():
82+
next_execution = datetime.now()
8083
args = {self.interval_unit: self.interval}
8184
if self.interval_unit == "months" and self.end_of_month:
8285
# dateutil knows how to deal with variable days of months,
8386
# it will put the latest possible day
8487
args.update({"day": 31, "hour": 23, "minute": 59, "second": 59})
85-
return self.next_execution + relativedelta(**args)
88+
return next_execution + relativedelta(**args)
8689

8790
@api.onchange("end_of_month")
8891
def onchange_end_of_month(self):
@@ -131,8 +134,9 @@ def _prepare_export_params(self):
131134
[export_field for export_field in export_fields],
132135
)
133136

137+
export_format = self.export_format == "excel" and "xlsx" or self.export_format
134138
return {
135-
"format": self.export_format,
139+
"format": export_format,
136140
"model": self.model_name,
137141
"fields": export_fields,
138142
"ids": False,

export_async_schedule/tests/test_export_async_schedule.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from odoo.addons.queue_job.tests.common import mock_with_delay
1111

1212

13-
class TestExportAsyncSchedule(common.SavepointCase):
13+
class TestExportAsyncSchedule(common.TransactionCase):
1414
@classmethod
1515
def setUpClass(cls):
1616
super().setUpClass()
@@ -51,7 +51,6 @@ def test_fields_with_labels(self):
5151
"email",
5252
"phone",
5353
"title/shortcut",
54-
"parent_id/customer",
5554
"parent_id/company_id/name",
5655
]
5756
result = self.env["export.async.schedule"]._get_fields_with_labels(
@@ -62,10 +61,6 @@ def test_fields_with_labels(self):
6261
{"label": "Email", "name": "email"},
6362
{"label": "Phone", "name": "phone"},
6463
{"label": "Title/Abbreviation", "name": "title/shortcut"},
65-
{
66-
"label": "Related Company/Is a Customer",
67-
"name": "parent_id/customer",
68-
},
6964
{
7065
"label": "Related Company/Company/Company Name",
7166
"name": "parent_id/company_id/name",

export_async_schedule/views/export_async_schedule_views.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<field name="name">export.async.schedule.tree</field>
66
<field name="model">export.async.schedule</field>
77
<field name="arch" type="xml">
8-
<tree string="Scheduled Exports">
8+
<tree>
99
<field name="model_id" />
1010
<field name="ir_export_id" />
1111
<field name="interval" />
@@ -115,7 +115,6 @@
115115
<field name="name">Scheduled Exports</field>
116116
<field name="type">ir.actions.act_window</field>
117117
<field name="res_model">export.async.schedule</field>
118-
<field name="view_type">form</field>
119118
<field name="help">Schedule Exports to send by email</field>
120119
</record>
121120

0 commit comments

Comments
 (0)