update all kept modules to OCA 19.0 versions

bi_sql_editor 19.0.1.0.1, report_csv 19.0.1.0.0,
report_qweb_element_page_visibility 19.0.1.0.0,
report_xlsx_helper 19.0.1.0.0, report_xml 19.0.1.0.0,
sql_request_abstract 19.0.1.0.0

🤖 assisted by claude
This commit is contained in:
Ernad Husremovic 2026-03-09 22:24:48 +01:00
parent 05df50b41d
commit c18e7fd4c7
258 changed files with 8677 additions and 6341 deletions

View file

@ -11,23 +11,23 @@ Base report csv
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ea7a062b40320443bdb91ba5319c9f79630439080c9ad3b7919abdbda5a6b294
!! source digest: sha256:d1c3c4d459b6b087099930f6fa7a1626300259aa06098906b5e428b9e556dd28
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/license-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/16.0/report_csv
:target: https://github.com/OCA/reporting-engine/tree/19.0/report_csv
: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-16-0/reporting-engine-16-0-report_csv
:target: https://translation.odoo-community.org/projects/reporting-engine-19-0/reporting-engine-19-0-report_csv
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=19.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -42,57 +42,65 @@ This module provides a basic report class to generate csv report.
Configuration
=============
In case the exported CSV report should be encoded in another system than UTF-8, following
fields of the report record (*Settings > Technical > Reports*) should be populated accordingly.
In case the exported CSV report should be encoded in another system than
UTF-8, following fields of the report record (*Settings > Technical >
Reports*) should be populated accordingly.
* Encoding: set an encoding system (such as cp932)
* Encode Error Handling: select 'Ignore' or 'Replace' as necessary.
- Encoding: set an encoding system (such as cp932)
- Encode Error Handling: select 'Ignore' or 'Replace' as necessary.
* 'Ignore': in case of an encoding error, the problematic character will be removed from the exported file.
* 'Replace': in case of an encoding error, the problematic character will be replaced with '?' symbol.
* Leaving the field blank: in case of an encoding error, the report generation fails with an error message.
- 'Ignore': in case of an encoding error, the problematic character
will be removed from the exported file.
- 'Replace': in case of an encoding error, the problematic character
will be replaced with '?' symbol.
- Leaving the field blank: in case of an encoding error, the report
generation fails with an error message.
Usage
=====
An example of CSV report for partners on a module called `module_name`:
An example of CSV report for partners on a module called
\`module_name\`:
A python class ::
A python class :
from odoo import models
::
class PartnerCSV(models.AbstractModel):
_name = 'report.report_csv.partner_csv'
_inherit = 'report.report_csv.abstract'
from odoo import models
def generate_csv_report(self, writer, data, partners):
writer.writeheader()
for obj in partners:
writer.writerow({
'name': obj.name,
'email': obj.email,
})
class PartnerCSV(models.AbstractModel):
_name = 'report.report_csv.partner_csv'
_inherit = 'report.report_csv.abstract'
def csv_report_options(self):
res = super().csv_report_options()
res['fieldnames'].append('name')
res['fieldnames'].append('email')
res['delimiter'] = ';'
res['quoting'] = csv.QUOTE_ALL
return res
def generate_csv_report(self, writer, data, partners):
writer.writeheader()
for obj in partners:
writer.writerow({
'name': obj.name,
'email': obj.email,
})
def csv_report_options(self):
res = super().csv_report_options()
res['fieldnames'].append('name')
res['fieldnames'].append('email')
res['delimiter'] = ';'
res['quoting'] = csv.QUOTE_ALL
return res
A report XML record ::
A report XML record :
<report
id="partner_csv"
model="res.partner"
string="Print to CSV"
report_type="csv"
name="module_name.report_name"
file="res_partner"
attachment_use="False"
/>
::
<report
id="partner_csv"
model="res.partner"
string="Print to CSV"
report_type="csv"
name="module_name.report_name"
file="res_partner"
attachment_use="False"
/>
Update encoding with an appropriate value (e.g. cp932) as necessary.
@ -102,7 +110,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_csv%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_csv%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -110,22 +118,22 @@ Credits
=======
Authors
~~~~~~~
-------
* Creu Blanca
Contributors
~~~~~~~~~~~~
------------
* Enric Tobella <etobella@creublanca.es>
* Jaime Arroyo <jaime.arroyo@creublanca.es>
* Rattapong Chokmasermkul <rattapongc@ecosoft.co.th>
* `Quartile <https://www.quartile.co>`__:
- Enric Tobella <etobella@creublanca.es>
- Jaime Arroyo <jaime.arroyo@creublanca.es>
- Rattapong Chokmasermkul <rattapongc@ecosoft.co.th>
- `Quartile <https://www.quartile.co>`__:
* Aung Ko Ko Lin
- Aung Ko Ko Lin
Maintainers
~~~~~~~~~~~
-----------
This module is maintained by the OCA.
@ -137,6 +145,6 @@ 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.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/16.0/report_csv>`_ project on GitHub.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/19.0/report_csv>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View file

@ -6,7 +6,7 @@
"author": "Creu Blanca, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"category": "Reporting",
"version": "16.0.2.1.1",
"version": "19.0.1.0.0",
"license": "AGPL-3",
"depends": ["base", "web"],
"demo": ["demo/report.xml"],
@ -16,5 +16,6 @@
"report_csv/static/src/js/report/qwebactionmanager.esm.js"
]
},
"development_status": "Production/Stable",
"installable": True,
}

View file

@ -11,6 +11,8 @@ from odoo.http import (
content_disposition,
request,
route,
)
from odoo.http import (
serialize_exception as _serialize_exception,
)
from odoo.tools import html_escape
@ -47,12 +49,10 @@ class ReportController(report.ReportController):
("Content-Length", len(csv)),
]
return request.make_response(csv, headers=csvhttpheaders)
return super(ReportController, self).report_routes(
reportname, docids, converter, **data
)
return super().report_routes(reportname, docids, converter, **data)
@route()
def report_download(self, data, context=None):
def report_download(self, data, context=None, token=None, readonly=True):
requestcontent = json.loads(data)
url, report_type = requestcontent[0], requestcontent[1]
reportname = ""
@ -73,8 +73,9 @@ class ReportController(report.ReportController):
url_decode(url.split("?")[1]).items()
) # decoding the args represented in JSON
if "context" in data:
context, data_context = json.loads(context or "{}"), json.loads(
data.pop("context")
context, data_context = (
json.loads(context or "{}"),
json.loads(data.pop("context")),
)
context = json.dumps({**context, **data_context})
response = self.report_routes(
@ -84,7 +85,7 @@ class ReportController(report.ReportController):
report = request.env["ir.actions.report"]._get_report_from_name(
reportname
)
filename = "%s.%s" % (report.name, "csv")
filename = f"{report.name}.csv"
if docids:
ids = [int(x) for x in docids.split(",")]
@ -93,13 +94,15 @@ class ReportController(report.ReportController):
report_name = safe_eval(
report.print_report_name, {"object": obj, "time": time}
)
filename = "%s.%s" % (report_name, "csv")
filename = f"{report_name}.csv"
response.headers.add(
"Content-Disposition", content_disposition(filename)
)
return response
else:
return super(ReportController, self).report_download(data, context)
return super().report_download(
data, context, token=token, readonly=readonly
)
except Exception as e:
_logger.exception("Error while generating report %s", reportname)
se = _serialize_exception(e)

View file

@ -4,41 +4,41 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
#. module: report_csv
#: model:ir.model,name:report_csv.model_report_report_csv_abstract
msgid "Abstract Model for CSV reports"
msgstr "Apstraktni model za CSV izvještaje"
msgstr ""
#. module: report_csv
#: model:ir.model.fields,field_description:report_csv.field_ir_actions_report__encode_error_handling
msgid "Encode Error Handling"
msgstr "Rukovanje greškom kodiranja"
msgstr ""
#. module: report_csv
#: model:ir.model.fields,field_description:report_csv.field_ir_actions_report__encoding
msgid "Encoding"
msgstr "Kodna stranica:"
msgstr ""
#. module: report_csv
#: model:ir.model.fields,help:report_csv.field_ir_actions_report__encoding
msgid "Encoding to be applied to the generated CSV file. e.g. cp932"
msgstr "Kodiranje koje će se primijeniti na generisanu CSV datoteku. npr. cp932"
msgstr ""
#. module: report_csv
#. odoo-python
#: code:addons/report_csv/report/report_csv.py:0
#, python-format
msgid "Failed to encode the data with the encoding set in the report."
msgstr "Neuspjeh kodiranja podataka s kodiranjem postavljenim u izvještaju."
msgstr ""
#. module: report_csv
#: model:ir.model.fields,help:report_csv.field_ir_actions_report__encode_error_handling
@ -50,32 +50,32 @@ msgstr ""
#. module: report_csv
#: model:ir.model.fields.selection,name:report_csv.selection__ir_actions_report__encode_error_handling__ignore
msgid "Ignore"
msgstr "Ignoriši"
msgstr ""
#. module: report_csv
#: model:ir.actions.report,name:report_csv.partner_csv
msgid "Print to CSV"
msgstr "Ispiši u CSV"
msgstr ""
#. module: report_csv
#: model:ir.model.fields.selection,name:report_csv.selection__ir_actions_report__encode_error_handling__replace
msgid "Replace"
msgstr "Zamijeni"
msgstr ""
#. module: report_csv
#: model:ir.model,name:report_csv.model_ir_actions_report
msgid "Report Action"
msgstr "Akcija izvještaja"
msgstr ""
#. module: report_csv
#: model:ir.model,name:report_csv.model_report_report_csv_partner_csv
msgid "Report Partner to CSV"
msgstr "Izvještaj partner u CSV"
msgstr ""
#. module: report_csv
#: model:ir.model.fields,field_description:report_csv.field_ir_actions_report__report_type
msgid "Report Type"
msgstr "Tip izvještaja"
msgstr ""
#. module: report_csv
#: model:ir.model.fields,help:report_csv.field_ir_actions_report__report_type
@ -89,4 +89,4 @@ msgstr ""
#. module: report_csv
#: model:ir.model.fields.selection,name:report_csv.selection__ir_actions_report__report_type__csv
msgid "csv"
msgstr "csv"
msgstr ""

View file

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@ -18,6 +18,13 @@ msgstr ""
msgid "Abstract Model for CSV reports"
msgstr ""
#. module: report_csv
#: model:ir.model.fields,field_description:report_csv.field_ir_actions_report__display_name
#: model:ir.model.fields,field_description:report_csv.field_report_report_csv_abstract__display_name
#: model:ir.model.fields,field_description:report_csv.field_report_report_csv_partner_csv__display_name
msgid "Display Name"
msgstr ""
#. module: report_csv
#: model:ir.model.fields,field_description:report_csv.field_ir_actions_report__encode_error_handling
msgid "Encode Error Handling"
@ -36,10 +43,16 @@ msgstr ""
#. module: report_csv
#. odoo-python
#: code:addons/report_csv/report/report_csv.py:0
#, python-format
msgid "Failed to encode the data with the encoding set in the report."
msgstr ""
#. module: report_csv
#: model:ir.model.fields,field_description:report_csv.field_ir_actions_report__id
#: model:ir.model.fields,field_description:report_csv.field_report_report_csv_abstract__id
#: model:ir.model.fields,field_description:report_csv.field_report_report_csv_partner_csv__id
msgid "ID"
msgstr ""
#. module: report_csv
#: model:ir.model.fields,help:report_csv.field_ir_actions_report__encode_error_handling
msgid ""
@ -52,11 +65,6 @@ msgstr ""
msgid "Ignore"
msgstr ""
#. module: report_csv
#: model:ir.actions.report,name:report_csv.partner_csv
msgid "Print to CSV"
msgstr ""
#. module: report_csv
#: model:ir.model.fields.selection,name:report_csv.selection__ir_actions_report__encode_error_handling__replace
msgid "Replace"

View file

@ -53,7 +53,7 @@ class ReportAction(models.Model):
@api.model
def _render_csv(self, report_ref, docids, data):
report_sudo = self._get_report(report_ref)
report_model_name = "report.%s" % report_sudo.report_name
report_model_name = f"report.{report_sudo.report_name}"
report_model = self.env[report_model_name]
res_id = docids[0] if docids and len(docids) == 1 else None
if not res_id or not report_sudo.attachment or not report_sudo.attachment_use:
@ -80,7 +80,7 @@ class ReportAction(models.Model):
@api.model
def _get_report_from_name(self, report_name):
res = super(ReportAction, self)._get_report_from_name(report_name)
res = super()._get_report_from_name(report_name)
if res:
return res
report_obj = self.env["ir.actions.report"]

View file

@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View file

@ -0,0 +1,12 @@
In case the exported CSV report should be encoded in another system than
UTF-8, following fields of the report record (*Settings \> Technical \>
Reports*) should be populated accordingly.
- Encoding: set an encoding system (such as cp932)
- Encode Error Handling: select 'Ignore' or 'Replace' as necessary.
- 'Ignore': in case of an encoding error, the problematic character
will be removed from the exported file.
- 'Replace': in case of an encoding error, the problematic character
will be replaced with '?' symbol.
- Leaving the field blank: in case of an encoding error, the report
generation fails with an error message.

View file

@ -1,9 +0,0 @@
In case the exported CSV report should be encoded in another system than UTF-8, following
fields of the report record (*Settings > Technical > Reports*) should be populated accordingly.
* Encoding: set an encoding system (such as cp932)
* Encode Error Handling: select 'Ignore' or 'Replace' as necessary.
* 'Ignore': in case of an encoding error, the problematic character will be removed from the exported file.
* 'Replace': in case of an encoding error, the problematic character will be replaced with '?' symbol.
* Leaving the field blank: in case of an encoding error, the report generation fails with an error message.

View file

@ -0,0 +1,5 @@
- Enric Tobella \<<etobella@creublanca.es>\>
- Jaime Arroyo \<<jaime.arroyo@creublanca.es>\>
- Rattapong Chokmasermkul \<<rattapongc@ecosoft.co.th>\>
- [Quartile](https://www.quartile.co):
- Aung Ko Ko Lin

View file

@ -1,6 +0,0 @@
* Enric Tobella <etobella@creublanca.es>
* Jaime Arroyo <jaime.arroyo@creublanca.es>
* Rattapong Chokmasermkul <rattapongc@ecosoft.co.th>
* `Quartile <https://www.quartile.co>`__:
* Aung Ko Ko Lin

View file

@ -1,6 +1,7 @@
An example of CSV report for partners on a module called `module_name`:
An example of CSV report for partners on a module called
\`module_name\`:
A python class ::
A python class :
from odoo import models
@ -24,8 +25,7 @@ A python class ::
res['quoting'] = csv.QUOTE_ALL
return res
A report XML record ::
A report XML record :
<report
id="partner_csv"

View file

@ -4,7 +4,7 @@
import logging
from io import StringIO
from odoo import _, models
from odoo import models
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
@ -47,17 +47,19 @@ class ReportCSVAbstract(models.AbstractModel):
file = csv.DictWriter(file_data, **self.csv_report_options())
self.generate_csv_report(file, data, objs)
file_data.seek(0)
encoding = self._context.get("encoding")
encoding = self.env.context.get("encoding")
if not encoding:
return file_data.read(), "csv"
error_handling = self._context.get("encode_error_handling")
error_handling = self.env.context.get("encode_error_handling")
if error_handling:
return file_data.read().encode(encoding, errors=error_handling), "csv"
try:
return file_data.read().encode(encoding), "csv"
except Exception as e:
raise UserError(
_("Failed to encode the data with the encoding set in the report.")
self.env._(
"Failed to encode the data with the encoding set in the report."
)
) from e
def csv_report_options(self):

View file

@ -372,9 +372,9 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ea7a062b40320443bdb91ba5319c9f79630439080c9ad3b7919abdbda5a6b294
!! source digest: sha256:d1c3c4d459b6b087099930f6fa7a1626300259aa06098906b5e428b9e556dd28
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/16.0/report_csv"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-report_csv"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/19.0/report_csv"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-19-0/reporting-engine-19-0-report_csv"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module provides a basic report class to generate csv report.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@ -392,22 +392,27 @@ ul.auto-toc {
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<p>In case the exported CSV report should be encoded in another system than UTF-8, following
fields of the report record (<em>Settings &gt; Technical &gt; Reports</em>) should be populated accordingly.</p>
<p>In case the exported CSV report should be encoded in another system than
UTF-8, following fields of the report record (<em>Settings &gt; Technical &gt;
Reports</em>) should be populated accordingly.</p>
<ul class="simple">
<li>Encoding: set an encoding system (such as cp932)</li>
<li>Encode Error Handling: select Ignore or Replace as necessary.<ul>
<li>Ignore: in case of an encoding error, the problematic character will be removed from the exported file.</li>
<li>Replace: in case of an encoding error, the problematic character will be replaced with ? symbol.</li>
<li>Leaving the field blank: in case of an encoding error, the report generation fails with an error message.</li>
<li>Ignore: in case of an encoding error, the problematic character
will be removed from the exported file.</li>
<li>Replace: in case of an encoding error, the problematic character
will be replaced with ? symbol.</li>
<li>Leaving the field blank: in case of an encoding error, the report
generation fails with an error message.</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<p>An example of CSV report for partners on a module called <cite>module_name</cite>:</p>
<p>A python class</p>
<p>An example of CSV report for partners on a module called
`module_name`:</p>
<p>A python class :</p>
<pre class="literal-block">
from odoo import models
@ -431,7 +436,7 @@ class PartnerCSV(models.AbstractModel):
res['quoting'] = csv.QUOTE_ALL
return res
</pre>
<p>A report XML record</p>
<p>A report XML record :</p>
<pre class="literal-block">
&lt;report
id=&quot;partner_csv&quot;
@ -450,7 +455,7 @@ class PartnerCSV(models.AbstractModel):
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_csv%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_csv%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -482,7 +487,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/16.0/report_csv">OCA/reporting-engine</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/19.0/report_csv">OCA/reporting-engine</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View file

@ -1,7 +1,6 @@
/** @odoo-module **/
import {download} from "@web/core/network/download";
import {registry} from "@web/core/registry";
import {user} from "@web/core/user";
registry
.category("ir.actions.report handlers")
@ -21,9 +20,7 @@ registry
url += `/${actionContext.active_ids.join(",")}`;
}
if (type === "csv") {
const context = encodeURIComponent(
JSON.stringify(env.services.user.context)
);
const context = encodeURIComponent(JSON.stringify(user.context));
url += `?context=${context}`;
}
}
@ -33,7 +30,7 @@ registry
url: "/report/download",
data: {
data: JSON.stringify([url, action.report_type]),
context: JSON.stringify(env.services.user.context),
context: JSON.stringify(user.context),
},
});
} finally {

View file

@ -10,7 +10,7 @@ from odoo.exceptions import UserError
from odoo.tests import common
from odoo.tools import mute_logger
from odoo.addons.web.controllers.report import ReportController
from odoo.addons.report_csv.controllers.main import ReportController
_logger = logging.getLogger(__name__)
try:
@ -35,7 +35,15 @@ class TestReport(common.TransactionCase):
active_model="res.partner"
)
self.report_name = "report_csv.partner_csv"
self.report = self.report_object._get_report_from_name(self.report_name)
self.report = self.report_object.create(
{
"name": "Print to CSV",
"report_name": self.report_name,
"model": "res.partner",
"report_file": "res_partner",
"report_type": "csv",
}
)
self.docs = self.env["res.company"].search([], limit=1).partner_id
def test_report(self):
@ -62,7 +70,6 @@ class TestReport(common.TransactionCase):
self.assertTupleEqual(rep, rep_from_attachment)
def test_id_retrieval(self):
# Typical call from WebUI with wizard
objs = self.csv_report._get_objs_for_report(
False, {"context": {"active_ids": self.docs.ids}}
@ -116,7 +123,15 @@ class TestCsvReport(common.HttpCase):
active_model="res.partner"
)
self.report_name = "report_csv.partner_csv"
self.report = self.report_object._get_report_from_name(self.report_name)
self.report = self.report_object.create(
{
"name": "Print to CSV",
"report_name": self.report_name,
"model": "res.partner",
"report_file": "res_partner",
"report_type": "csv",
}
)
self.docs = self.env["res.company"].search([], limit=1).partner_id
self.session = self.authenticate("admin", "admin")
@ -126,11 +141,12 @@ class TestCsvReport(common.HttpCase):
@mute_logger("odoo.addons.web.controllers.report")
def test_pdf_error(self):
with mock.patch.object(
ReportController, "report_routes"
) as route_patch, self.assertLogs(
"odoo.addons.report_csv.controllers.main", level=logging.ERROR
) as cm:
with (
mock.patch.object(ReportController, "report_routes") as route_patch,
self.assertLogs(
"odoo.addons.report_csv.controllers.main", level=logging.ERROR
) as cm,
):
route_patch.side_effect = TestCsvException("Test")
self.get_report_headers(
suffix="/report/pdf/test/10", f_type="qweb-pdf"

View file

@ -6,14 +6,8 @@
<field name="inherit_id" ref="base.act_report_xml_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='report_type']" position="after">
<field
name="encoding"
attrs="{'invisible': [('report_type', '!=', 'csv')]}"
/>
<field
name="encode_error_handling"
attrs="{'invisible': [('encoding', '=', False)]}"
/>
<field name="encoding" invisible="report_type != 'csv'" />
<field name="encode_error_handling" invisible="not encoding" />
</xpath>
</field>
</record>