diff --git a/report_async/README.rst b/report_async/README.rst deleted file mode 100644 index 075627f87..000000000 --- a/report_async/README.rst +++ /dev/null @@ -1,120 +0,0 @@ -============ -Report Async -============ - -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! This file is generated by oca-gen-addon-readme !! - !! changes will be overwritten. !! - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png - :target: https://odoo-community.org/page/development-status - :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github - :target: https://github.com/OCA/reporting-engine/tree/13.0/report_async - :alt: OCA/reporting-engine -.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/reporting-engine-13-0/reporting-engine-13-0-report_async - :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/143/13.0 - :alt: Try me on Runbot - -|badge1| |badge2| |badge3| |badge4| |badge5| - -The new menu "Report Center" is the central place to host your reports in one place. -From here, there are 2 ways to launch the report, - -1. Run Now - run report immediately as per normal. -2. Run Background - put the report execution to queue job. - -By using the queue job, option 2 is great for long running report. -The report file will be saved for later use, with the option to send report -by email as soon as it is ready. - -Notes: - -* Only user with Technical Feature rights can manage the report. -* Every internal user will have right to execute the report allowed for his/her groups. -* The files created are owned and viewable only by the person who run the report. -* Job queue manager can also see all jobs for each reports. - -**Table of contents** - -.. contents:: - :local: - -Usage -===== - -Menu: Dashboard > Report Center - -As Technical Feature users, you can manage reports for Report Center. - -- **Report:** choose the report (a window action). Although the option show all window actions - it only make sense for window actions that launch reports. -- **Allow Async:** check this, if you want the report to run in background too, suitable for - report that return file as result, i.e., pdf/xlsx/csv/txt. -- **Email Notification:** if checked, once the background process is completed, email with link to download - report will be sent. -- **Groups:** select user groups allowed to use this report. If left blank, all user can use. - -As normal user, you can run your reports from Report Center - -- **Run Now button:** to run report immediately as per normal. -- **Run Background button:** to run report asynchronously. Fall back to run now, if not report that produce file. -- **Job Status:** show status of the latest run job. If job fail, exception error will also shown -- **Files:** show all files being produced by the job as run by the user. -- **Jobs:** show all jobs triggered by this report as run by the user. Only job queue manager have access to this button. - -Bug Tracker -=========== - -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. - -Do not contact contributors directly about support or help with technical issues. - -Credits -======= - -Authors -~~~~~~~ - -* Ecosoft - -Contributors -~~~~~~~~~~~~ - -* Kitti U. -* Saran Lim. - -Maintainers -~~~~~~~~~~~ - -This module is maintained by the OCA. - -.. image:: https://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: https://odoo-community.org - -OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use. - -.. |maintainer-kittiu| image:: https://github.com/kittiu.png?size=40px - :target: https://github.com/kittiu - :alt: kittiu - -Current `maintainer `__: - -|maintainer-kittiu| - -This module is part of the `OCA/reporting-engine `_ project on GitHub. - -You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/report_async/__manifest__.py b/report_async/__manifest__.py index e861171a1..88a720170 100644 --- a/report_async/__manifest__.py +++ b/report_async/__manifest__.py @@ -13,6 +13,7 @@ "security/ir.model.access.csv", "security/ir_rule.xml", "data/mail_template.xml", + "data/queue_job_function_data.xml", "views/report_async.xml", "wizard/print_report_wizard.xml", ], diff --git a/report_async/data/mail_template.xml b/report_async/data/mail_template.xml index 77411dc14..bf1d29aa0 100644 --- a/report_async/data/mail_template.xml +++ b/report_async/data/mail_template.xml @@ -67,7 +67,6 @@ - diff --git a/report_async/data/queue_job_function_data.xml b/report_async/data/queue_job_function_data.xml new file mode 100644 index 000000000..e5b2a23fa --- /dev/null +++ b/report_async/data/queue_job_function_data.xml @@ -0,0 +1,6 @@ + + + + run_report + + diff --git a/report_async/i18n/report_async.pot b/report_async/i18n/report_async.pot deleted file mode 100644 index 482e2533f..000000000 --- a/report_async/i18n/report_async.pot +++ /dev/null @@ -1,318 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * report_async -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: report_async -#: model:mail.template,body_html:report_async.async_report_delivery -msgid "\n" -" \n" -" \n" -" \n" -"
\n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -"
\n" -" \n" -" \n" -" \n" -" \n" -"
\n" -" % set base_url = object.env['ir.config_parameter'].sudo().get_param('web.base.url')\n" -" % set download_url = '%s/web/content/ir.attachment/%s/datas/%s?download=true' % (base_url, object.id, object.name, )\n" -"
\n" -" Dear ${object.create_uid.partner_id.name or ''},\n" -"

\n" -" Your requested report, ${object.name}, is available for download.\n" -"

\n" -" Have a nice day!
\n" -" --
${object.company_id.name}\n" -"
\n" -"
\n" -"
\n" -"
\n" -" " -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_report_async__allow_async -msgid "Allow Async" -msgstr "" - -#. module: report_async -#: code:addons/report_async/models/report_async.py:108 -#, python-format -msgid "Background process not allowed." -msgstr "" - -#. module: report_async -#: model_terms:ir.ui.view,arch_db:report_async.print_report_wizard -msgid "Cancel" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_print_report_wizard__create_uid -#: model:ir.model.fields,field_description:report_async.field_report_async__create_uid -msgid "Created by" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_print_report_wizard__create_date -#: model:ir.model.fields,field_description:report_async.field_report_async__create_date -msgid "Created on" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_print_report_wizard__display_name -#: model:ir.model.fields,field_description:report_async.field_report_async__display_name -msgid "Display Name" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_print_report_wizard__reference -msgid "Document" -msgstr "" - -#. module: report_async -#: selection:report.async,job_status:0 -msgid "Done" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_report_async__email_notify -msgid "Email Notification" -msgstr "" - -#. module: report_async -#: selection:report.async,job_status:0 -msgid "Enqueued" -msgstr "" - -#. module: report_async -#: model_terms:ir.ui.view,arch_db:report_async.print_report_wizard -msgid "Execute" -msgstr "" - -#. module: report_async -#: selection:report.async,job_status:0 -msgid "Failed" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_report_async__file_ids -msgid "File" -msgstr "" - -#. module: report_async -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_form -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_tree -msgid "Files" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_report_async__group_ids -msgid "Groups" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_print_report_wizard__id -#: model:ir.model.fields,field_description:report_async.field_report_async__id -msgid "ID" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_report_async__job_ids -msgid "Job" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_report_async__job_info -msgid "Job Info" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_report_async__job_status -msgid "Job Status" -msgstr "" - -#. module: report_async -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_form -msgid "Jobs" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_print_report_wizard____last_update -#: model:ir.model.fields,field_description:report_async.field_report_async____last_update -msgid "Last Modified on" -msgstr "" - -#. module: report_async -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_form -msgid "Last Run Job Error" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_print_report_wizard__write_uid -#: model:ir.model.fields,field_description:report_async.field_report_async__write_uid -msgid "Last Updated by" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_print_report_wizard__write_date -#: model:ir.model.fields,field_description:report_async.field_report_async__write_date -msgid "Last Updated on" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,help:report_async.field_report_async__job_info -msgid "Latest Job Error Message" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,help:report_async.field_report_async__job_status -msgid "Latest Job Status" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,help:report_async.field_report_async__file_ids -msgid "List all files created by this report background process" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,help:report_async.field_report_async__job_ids -msgid "List all jobs related to this running report" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_report_async__name -msgid "Name" -msgstr "" - -#. module: report_async -#: model_terms:ir.actions.act_window,help:report_async.action_view_files -msgid "No files found" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,help:report_async.field_report_async__group_ids -msgid "Only user in selected groups can use this report.If left blank, everyone can use" -msgstr "" - -#. module: report_async -#: selection:report.async,job_status:0 -msgid "Pending" -msgstr "" - -#. module: report_async -#: model:ir.actions.act_window,name:report_async.action_print_report_wizard -msgid "Print Document" -msgstr "" - -#. module: report_async -#: model:ir.model,name:report_async.model_print_report_wizard -msgid "Print Report Wizard" -msgstr "" - -#. module: report_async -#: model:ir.model,name:report_async.model_ir_actions_report -msgid "Report Action" -msgstr "" - -#. module: report_async -#: model:ir.model,name:report_async.model_report_async -msgid "Report Async" -msgstr "" - -#. module: report_async -#: model:ir.actions.act_window,name:report_async.action_report_async -#: model:ir.ui.menu,name:report_async.menu_report_async -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_search -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_tree -msgid "Report Center" -msgstr "" - -#. module: report_async -#: model:ir.actions.act_window,name:report_async.action_view_files -msgid "Report Files" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_print_report_wizard__action_report_id -msgid "Report Template" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,field_description:report_async.field_report_async__action_id -msgid "Reports" -msgstr "" - -#. module: report_async -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_form -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_tree -msgid "Run Background" -msgstr "" - -#. module: report_async -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_form -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_tree -msgid "Run Now" -msgstr "" - -#. module: report_async -#: model_terms:ir.actions.act_window,help:report_async.action_report_async -msgid "Run reports asyncronously" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,help:report_async.field_report_async__email_notify -msgid "Send email with link to report, when it is ready" -msgstr "" - -#. module: report_async -#: selection:report.async,job_status:0 -msgid "Started" -msgstr "" - -#. module: report_async -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_form -msgid "The last running job was failed.\n" -" Please contact your system administrator." -msgstr "" - -#. module: report_async -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_form -msgid "The last running job was succeed.\n" -" You can check the result in Files" -msgstr "" - -#. module: report_async -#: model_terms:ir.ui.view,arch_db:report_async.view_report_async_form -msgid "The report will be running by \n" -" job, and will be available at\n" -" Files" -msgstr "" - -#. module: report_async -#: model:ir.model.fields,help:report_async.field_report_async__allow_async -msgid "This is not automatic field, please check if you want to allow this report in background process" -msgstr "" - -#. module: report_async -#: model:mail.template,subject:report_async.async_report_delivery -msgid "Your report is available, ${object.name}" -msgstr "" - diff --git a/report_async/models/__init__.py b/report_async/models/__init__.py index 2e6988867..d0e92de8d 100644 --- a/report_async/models/__init__.py +++ b/report_async/models/__init__.py @@ -3,3 +3,4 @@ from . import report_async from . import ir_report +from . import ir_actions diff --git a/report_async/models/ir_actions.py b/report_async/models/ir_actions.py new file mode 100644 index 000000000..ec97c81be --- /dev/null +++ b/report_async/models/ir_actions.py @@ -0,0 +1,26 @@ +# 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 + + +class IrActionsActWindow(models.Model): + _inherit = "ir.actions.act_window" + + @api.model + def name_search(self, name, args=None, operator="ilike", limit=100): + if self._context.get("access_sudo", False): + self = self.sudo() + return super().name_search(name, args, operator, limit) + + @api.model + def search(self, args, offset=0, limit=None, order=None, count=False): + if self._context.get("access_sudo", False): + self = self.sudo() + return super().search(args, offset, limit, order, count) + + def _read(self, fields): + """Add permission to read analytic account for do something.""" + if self._context.get("access_sudo", False): + self = self.sudo() + return super()._read(fields) diff --git a/report_async/models/report_async.py b/report_async/models/report_async.py index ad362a166..7b43bb8f9 100644 --- a/report_async/models/report_async.py +++ b/report_async/models/report_async.py @@ -7,16 +7,14 @@ from odoo import _, api, fields, models from odoo.exceptions import UserError from odoo.tools.safe_eval import safe_eval -from odoo.addons.queue_job.job import job - # Define all supported report_type REPORT_TYPES_FUNC = { - "qweb-pdf": "render_qweb_pdf", - "qweb-text": "render_qweb_text", - "qweb-xml": "render_qweb_xml", - "csv": "render_csv", + "qweb-pdf": "_render_qweb_pdf", + "qweb-text": "_render_qweb_text", + "qweb-xml": "_render_qweb_xml", + "csv": "_render_csv", "excel": "render_excel", - "xlsx": "render_xlsx", + "xlsx": "_render_xlsx", } @@ -106,7 +104,7 @@ class ReportAsync(models.Model): def run_now(self): self.ensure_one() action = self.env.ref(self.action_id.xml_id) - result = action.read()[0] + result = action.sudo().read()[0] ctx = safe_eval(result.get("context", {})) ctx.update({"async_process": False}) result["context"] = ctx @@ -117,7 +115,7 @@ class ReportAsync(models.Model): if not self.allow_async: raise UserError(_("Background process not allowed.")) action = self.env.ref(self.action_id.xml_id) - result = action.read()[0] + result = action.sudo().read()[0] ctx = safe_eval(result.get("context", {})) ctx.update({"async_process": True}) result["context"] = ctx @@ -126,20 +124,19 @@ class ReportAsync(models.Model): def view_files(self): self.ensure_one() action = self.env.ref("report_async.action_view_files") - result = action.read()[0] + result = action.sudo().read()[0] 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.read()[0] + result = action.sudo().read()[0] result["domain"] = [("id", "in", self.job_ids.ids)] result["context"] = {} return result @api.model - @job def run_report(self, docids, data, report_id, user_id): report = self.env["ir.actions.report"].browse(report_id) func = REPORT_TYPES_FUNC[report.report_type] diff --git a/report_async/readme/CONTRIBUTORS.rst b/report_async/readme/CONTRIBUTORS.rst index b8832b9e7..d391cb73d 100644 --- a/report_async/readme/CONTRIBUTORS.rst +++ b/report_async/readme/CONTRIBUTORS.rst @@ -1,2 +1,5 @@ -* Kitti U. -* Saran Lim. +* `Ecosoft `__: + + * Kitti U. + * Saran Lim. + * Tharathip Chaweewongphan diff --git a/report_async/security/ir.model.access.csv b/report_async/security/ir.model.access.csv index ba490c037..6e8408676 100644 --- a/report_async/security/ir.model.access.csv +++ b/report_async/security/ir.model.access.csv @@ -1,3 +1,4 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" access_report_async,report.async.user,model_report_async,base.group_user,1,0,0,0 access_report_async_sudo,report.async.sudo,model_report_async,base.group_no_one,1,1,1,1 +access_print_report_wizard,print.report.wizard,model_print_report_wizard,base.group_user,1,1,1,1 diff --git a/report_async/static/description/index.html b/report_async/static/description/index.html deleted file mode 100644 index f31d1515c..000000000 --- a/report_async/static/description/index.html +++ /dev/null @@ -1,460 +0,0 @@ - - - - - - -Report Async - - - -
-

Report Async

- - -

Beta License: AGPL-3 OCA/reporting-engine Translate me on Weblate Try me on Runbot

-

The new menu “Report Center” is the central place to host your reports in one place. -From here, there are 2 ways to launch the report,

-
    -
  1. Run Now - run report immediately as per normal.
  2. -
  3. Run Background - put the report execution to queue job.
  4. -
-

By using the queue job, option 2 is great for long running report. -The report file will be saved for later use, with the option to send report -by email as soon as it is ready.

-

Notes:

-
    -
  • Only user with Technical Feature rights can manage the report.
  • -
  • Every internal user will have right to execute the report allowed for his/her groups.
  • -
  • The files created are owned and viewable only by the person who run the report.
  • -
  • Job queue manager can also see all jobs for each reports.
  • -
-

Table of contents

- -
-

Usage

-

Menu: Dashboard > Report Center

-

As Technical Feature users, you can manage reports for Report Center.

-
    -
  • Report: choose the report (a window action). Although the option show all window actions -it only make sense for window actions that launch reports.
  • -
  • Allow Async: check this, if you want the report to run in background too, suitable for -report that return file as result, i.e., pdf/xlsx/csv/txt.
  • -
  • Email Notification: if checked, once the background process is completed, email with link to download -report will be sent.
  • -
  • Groups: select user groups allowed to use this report. If left blank, all user can use.
  • -
-

As normal user, you can run your reports from Report Center

-
    -
  • Run Now button: to run report immediately as per normal.
  • -
  • Run Background button: to run report asynchronously. Fall back to run now, if not report that produce file.
  • -
  • Job Status: show status of the latest run job. If job fail, exception error will also shown
  • -
  • Files: show all files being produced by the job as run by the user.
  • -
  • Jobs: show all jobs triggered by this report as run by the user. Only job queue manager have access to this button.
  • -
-
-
-

Bug Tracker

-

Bugs are tracked on GitHub Issues. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

-

Do not contact contributors directly about support or help with technical issues.

-
-
-

Credits

-
-

Authors

-
    -
  • Ecosoft
  • -
-
-
-

Contributors

- -
-
-

Maintainers

-

This module is maintained by the OCA.

-Odoo Community Association -

OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use.

-

Current maintainer:

-

kittiu

-

This module is part of the OCA/reporting-engine project on GitHub.

-

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

-
-
-
- - diff --git a/report_async/tests/test_report_async.py b/report_async/tests/test_report_async.py index a1f1e8bd0..545a36360 100644 --- a/report_async/tests/test_report_async.py +++ b/report_async/tests/test_report_async.py @@ -8,7 +8,7 @@ from odoo.tests.common import Form class TestJobChannel(common.TransactionCase): def setUp(self): super(TestJobChannel, self).setUp() - self.print_doc = self.env.ref("report_async." "report_async_print_document") + self.print_doc = self.env.ref("report_async.report_async_print_document") self.test_rec = self.env.ref("base.module_mail") self.test_rpt = self.env.ref("base.ir_module_reference_print") diff --git a/report_async/views/report_async.xml b/report_async/views/report_async.xml index 5b833029f..406856543 100644 --- a/report_async/views/report_async.xml +++ b/report_async/views/report_async.xml @@ -5,7 +5,7 @@ report.async - +