Browse Source

[11.0][MIG] base_directory_file_download

pull/1585/head
Andrea 5 years ago
parent
commit
400b0cd8f2
  1. 10
      base_directory_file_download/README.rst
  2. 1
      base_directory_file_download/__init__.py
  3. 5
      base_directory_file_download/__manifest__.py
  4. 1
      base_directory_file_download/models/__init__.py
  5. 3
      base_directory_file_download/models/ir_filesystem_directory.py
  6. 8
      base_directory_file_download/models/ir_filesystem_file.py
  7. 1
      base_directory_file_download/tests/__init__.py
  8. 6
      base_directory_file_download/tests/test_directory_files_download.py

10
base_directory_file_download/README.rst

@ -14,13 +14,13 @@ Directory Files Download
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/10.0/base_directory_file_download
:target: https://github.com/OCA/server-tools/tree/11.0/base_directory_file_download
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-10-0/server-tools-10-0-base_directory_file_download
:target: https://translation.odoo-community.org/projects/server-tools-11-0/server-tools-11-0-base_directory_file_download
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/10.0
:target: https://runbot.odoo-community.org/runbot/149/11.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -63,7 +63,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/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 <https://github.com/OCA/server-tools/issues/new?body=module:%20base_directory_file_download%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_directory_file_download%0Aversion:%2011.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.
@ -93,6 +93,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/server-tools <https://github.com/OCA/server-tools/tree/10.0/base_directory_file_download>`_ project on GitHub.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/11.0/base_directory_file_download>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

1
base_directory_file_download/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models

5
base_directory_file_download/__manifest__.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2018 Onestein (<https://www.onestein.eu>)
# Copyright 2017-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
@ -8,7 +7,7 @@
'author': 'Onestein, Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/server-tools',
'category': 'Tools',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'license': 'AGPL-3',
'depends': [
'base_setup',

1
base_directory_file_download/models/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import ir_filesystem_directory

3
base_directory_file_download/models/ir_filesystem_directory.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2018 Onestein (<https://www.onestein.eu>)
# Copyright 2017-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging

8
base_directory_file_download/models/ir_filesystem_file.py

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2018 Onestein (<https://www.onestein.eu>)
# Copyright 2017-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import base64
import logging
import os
@ -43,14 +43,14 @@ class IrFilesystemDirectoryLine(models.TransientModel):
if bin_size:
r = human_size(os.path.getsize(full_path))
else:
r = open(full_path, 'rb').read().encode('base64')
r = base64.b64encode(open(full_path, 'rb').read())
except (IOError, OSError):
_logger.info("_read_file reading %s", fname, exc_info=True)
return r
@api.depends('stored_filename')
def _compute_file(self):
bin_size = self._context.get('bin_size')
bin_size = self.env.context.get('bin_size')
for line in self:
if line.stored_filename:
content = line._file_read(line.stored_filename, bin_size)

1
base_directory_file_download/tests/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import test_directory_files_download

6
base_directory_file_download/tests/test_directory_files_download.py

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2018 Onestein (<https://www.onestein.eu>)
# Copyright 2017-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import base64
import os
from tempfile import gettempdir
@ -36,7 +36,7 @@ class TestBaseDirectoryFilesDownload(common.TransactionCase):
filename = file.stored_filename
directory = test_dir.get_dir()
with open(os.path.join(directory, filename), 'rb') as f:
content = f.read().encode('base64')
content = base64.b64encode(f.read())
self.assertEqual(file.file_content, content)
# test onchange directory (to not existing)

Loading…
Cancel
Save