Skip to content

Commit

Permalink
[IMP] report_async: Add eta when async reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
HviorForgeFlow committed Feb 16, 2023
1 parent 14d0f42 commit c769dc1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion report_async/models/ir_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def report_action(self, docids, data=None, config=True):
rpt_async_id = res['context']['active_id']
report_async = self.env['report.async'].browse(rpt_async_id)
if res['report_type'] in REPORT_TYPES:
report_async.with_delay().run_report(
report_async.with_delay(eta=res['context'].get('eta', False)).run_report(
res['context'].get('active_ids', []), data,
self.id, self._uid)
return {}
Expand Down
4 changes: 3 additions & 1 deletion report_async/models/report_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class ReportAsync(models.Model):
help="List all files created by this report background process",
)

eta = fields.Datetime(string='Execute only after')

@api.multi
def _compute_job(self):
for rec in self:
Expand Down Expand Up @@ -109,7 +111,7 @@ def run_async(self):
action = self.env.ref(self.action_id.xml_id)
result = action.read()[0]
ctx = safe_eval(result.get('context', {}))
ctx.update({'async_process': True})
ctx.update({'async_process': True, 'eta': self.eta})
result['context'] = ctx
return result

Expand Down
2 changes: 2 additions & 0 deletions report_async/views/report_async.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
<field name="allow_async"/>
<field name="email_notify"
attrs="{'invisible': [('allow_async', '=', False)]}"/>
<field name="eta"
attrs="{'invisible': [('allow_async', '=', False)]}"/>
</group>
<group>
<field name="job_status"
Expand Down

0 comments on commit c769dc1

Please sign in to comment.