-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] datev_export_xml: Improve handling and download of bigger files
- Loading branch information
1 parent
a369427
commit c8b000a
Showing
6 changed files
with
84 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (C) 2022-2024 initOS GmbH | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (C) 2022-2024 initOS GmbH | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import base64 | ||
import logging | ||
|
||
from odoo import http | ||
from odoo.http import request, send_file | ||
|
||
from odoo.addons.web.controllers.main import Home | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class DatevHome(Home): | ||
@http.route("/datev/xml/download/<int:export_id>", type="http", auth="user") | ||
def datev_xml_download_attachment(self, export_id): | ||
export = request.env["datev.export.xml"].search([("id", "=", export_id)]) | ||
|
||
if not export.attachment_id: | ||
return request.not_found() | ||
|
||
att = export.attachment_id | ||
|
||
if att.store_fname: | ||
full_path = att._full_path(att.store_fname) | ||
return send_file( | ||
full_path, | ||
filename=att.name, | ||
mimetype=att.mimetype, | ||
as_attachment=True, | ||
) | ||
|
||
return request.make_response( | ||
base64.b64decode(att.datas), | ||
[ | ||
("Content-Type", att.mimetype), | ||
("Content-Disposition", f'attachment; filename="{att.name}"'), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters