diff --git a/report_async/__manifest__.py b/report_async/__manifest__.py
index 0f770f701..d6b2147ad 100644
--- a/report_async/__manifest__.py
+++ b/report_async/__manifest__.py
@@ -8,7 +8,7 @@
"license": "AGPL-3",
"website": "https://github.com/OCA/reporting-engine",
"category": "Generic Modules",
- "depends": ["queue_job"],
+ "depends": ["queue_job", "spreadsheet_dashboard"],
"data": [
"security/ir.model.access.csv",
"security/ir_rule.xml",
diff --git a/report_async/models/ir_actions.py b/report_async/models/ir_actions.py
index ec97c81be..67fda4793 100644
--- a/report_async/models/ir_actions.py
+++ b/report_async/models/ir_actions.py
@@ -1,7 +1,7 @@
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
-from odoo import api, models
+from odoo import SUPERUSER_ID, api, models
class IrActionsActWindow(models.Model):
@@ -10,17 +10,17 @@ class IrActionsActWindow(models.Model):
@api.model
def name_search(self, name, args=None, operator="ilike", limit=100):
if self._context.get("access_sudo", False):
- self = self.sudo()
+ self = self.with_user(SUPERUSER_ID)
return super().name_search(name, args, operator, limit)
@api.model
- def search(self, args, offset=0, limit=None, order=None, count=False):
+ def search(self, args, offset=0, limit=None, order=None):
if self._context.get("access_sudo", False):
- self = self.sudo()
- return super().search(args, offset, limit, order, count)
+ self = self.with_user(SUPERUSER_ID)
+ return super().search(args, offset, limit, order)
- def _read(self, fields):
+ def fetch(self, field_names):
"""Add permission to read analytic account for do something."""
if self._context.get("access_sudo", False):
- self = self.sudo()
- return super()._read(fields)
+ self = self.with_user(SUPERUSER_ID)
+ return super().fetch(field_names)
diff --git a/report_async/models/report_async.py b/report_async/models/report_async.py
index 365f61439..183e2ddb6 100644
--- a/report_async/models/report_async.py
+++ b/report_async/models/report_async.py
@@ -3,7 +3,7 @@
import base64
-from odoo import _, api, fields, models
+from odoo import SUPERUSER_ID, _, api, fields, models
from odoo.exceptions import UserError
from odoo.tools.safe_eval import safe_eval
@@ -102,8 +102,7 @@ class ReportAsync(models.Model):
def run_now(self):
self.ensure_one()
- action = self.env.ref(self.action_id.xml_id)
- result = action.sudo().read()[0]
+ result = self.env[self.action_id.type]._for_xml_id(self.action_id.xml_id)
ctx = safe_eval(result.get("context", {}))
ctx.update({"async_process": False})
result["context"] = ctx
@@ -113,8 +112,7 @@ class ReportAsync(models.Model):
self.ensure_one()
if not self.allow_async:
raise UserError(_("Background process not allowed."))
- action = self.env.ref(self.action_id.xml_id)
- result = action.sudo().read()[0]
+ result = self.env[self.action_id.type]._for_xml_id(self.action_id.xml_id)
ctx = safe_eval(result.get("context", {}))
ctx.update({"async_process": True})
result["context"] = ctx
@@ -122,15 +120,17 @@ class ReportAsync(models.Model):
def view_files(self):
self.ensure_one()
- action = self.env.ref("report_async.action_view_files")
- result = action.sudo().read()[0]
+ result = self.env["ir.actions.act_window"]._for_xml_id(
+ "report_async.action_view_files"
+ )
result["domain"] = [("id", "in", self.file_ids.ids)]
return result
def view_jobs(self):
self.ensure_one()
- action = self.env.ref("queue_job.action_queue_job")
- result = action.sudo().read()[0]
+ result = self.env["ir.actions.act_window"]._for_xml_id(
+ "queue_job.action_queue_job"
+ )
result["domain"] = [("id", "in", self.job_ids.ids)]
result["context"] = {}
return result
@@ -146,7 +146,7 @@ class ReportAsync(models.Model):
# Save report to attachment
attachment = (
self.env["ir.attachment"]
- .sudo()
+ .with_user(SUPERUSER_ID)
.create(
{
"name": out_name,
diff --git a/report_async/views/report_async.xml b/report_async/views/report_async.xml
index a0b7400e8..b2ce077df 100644
--- a/report_async/views/report_async.xml
+++ b/report_async/views/report_async.xml
@@ -12,20 +12,17 @@
name="run_async"
string="Run Background"
icon="fa-cogs"
- attrs="{'invisible': [('allow_async', '=', False)]}"
+ invisible="not allow_async"
/>
-
@@ -51,8 +47,7 @@
@@ -63,8 +58,7 @@
@@ -75,7 +69,7 @@