|
3 | 3 |
|
4 | 4 | import base64 |
5 | 5 |
|
6 | | -from odoo import SUPERUSER_ID, _, api, fields, models |
| 6 | +from odoo import SUPERUSER_ID, api, fields, models |
7 | 7 | from odoo.exceptions import UserError |
| 8 | +from odoo.tools import SQL |
8 | 9 | from odoo.tools.safe_eval import safe_eval |
9 | 10 |
|
10 | 11 | # Define all supported report_type |
|
13 | 14 | "qweb-text": "_render_qweb_text", |
14 | 15 | "qweb-xml": "_render_qweb_xml", |
15 | 16 | "csv": "_render_csv", |
16 | | - "excel": "render_excel", |
| 17 | + "excel": "_render_excel", |
17 | 18 | "xlsx": "_render_xlsx", |
18 | 19 | } |
19 | 20 |
|
@@ -79,7 +80,7 @@ def _compute_job(self): |
79 | 80 | .env["queue.job"] |
80 | 81 | .search( |
81 | 82 | [ |
82 | | - ("func_string", "like", "report.async(%s,)" % rec.id), |
| 83 | + ("func_string", "like", f"report.async({rec.id},)"), |
83 | 84 | ("user_id", "=", self._uid), |
84 | 85 | ], |
85 | 86 | order="id desc", |
@@ -111,7 +112,7 @@ def run_now(self): |
111 | 112 | def run_async(self): |
112 | 113 | self.ensure_one() |
113 | 114 | if not self.allow_async: |
114 | | - raise UserError(_("Background process not allowed.")) |
| 115 | + raise UserError(self.env._("Background process not allowed.")) |
115 | 116 | result = self.env[self.action_id.type]._for_xml_id(self.action_id.xml_id) |
116 | 117 | ctx = safe_eval(result.get("context", {})) |
117 | 118 | ctx.update({"async_process": True}) |
@@ -157,11 +158,16 @@ def run_report(self, docids, data, report_id, user_id): |
157 | 158 | } |
158 | 159 | ) |
159 | 160 | ) |
160 | | - self._cr.execute( |
161 | | - """ |
162 | | - UPDATE ir_attachment SET create_uid = %s, write_uid = %s |
163 | | - WHERE id = %s""", |
164 | | - (self._uid, self._uid, attachment.id), |
| 161 | + self.env.execute_query( |
| 162 | + SQL( |
| 163 | + """ |
| 164 | + UPDATE ir_attachment |
| 165 | + SET create_uid = %(create_uid)s, write_uid = %(write_uid)s |
| 166 | + WHERE id = %(attachment_id)s""", |
| 167 | + create_uid=self._uid, |
| 168 | + write_uid=self._uid, |
| 169 | + attachment_id=attachment.id, |
| 170 | + ) |
165 | 171 | ) |
166 | 172 | # Send email |
167 | 173 | if self.email_notify: |
|
0 commit comments