Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16.0 mig storage backend #234

Closed
wants to merge 108 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
9ac1d00
[IMP] add meta code
sebastienbeau Apr 12, 2017
2e9792f
First work
Apr 14, 2017
2ed741f
Comment code
Apr 18, 2017
0b68e04
Work
Apr 19, 2017
bf1006a
ajout de la factory
Apr 20, 2017
4e00778
Add implented_by wrapper for backend
Apr 25, 2017
34bc949
Add odoo backend
May 3, 2017
81ce707
Add some comments
May 3, 2017
be600f3
Fix thumbnail url for odoo backend
May 3, 2017
93ece5a
Gestion du nom
May 4, 2017
d7b31b8
Pylinting
May 4, 2017
b2963b8
+ Readme
May 4, 2017
a9f23df
Add sftp backend
May 4, 2017
1356161
Suppression d'image wizard
May 9, 2017
eb17fd8
Virer storage.thumbnail factory & wizard
May 9, 2017
d3193d9
Add view for backend
May 9, 2017
897ebef
sparse backend
May 9, 2017
75a00c7
Add backend_type by sub classes
May 10, 2017
c0e3e05
Shared backend_name
May 10, 2017
19a133f
add s3 (marche pas)
May 10, 2017
e6cbd38
res_model marche pas
May 11, 2017
690d674
Add config_parameter avec odoo par defaut
May 11, 2017
9cb3e75
Add default backend
May 18, 2017
f0b81a7
[IMP] remove dead code, start to refactor amazon export, fix issue wi…
sebastienbeau May 18, 2017
bf42635
[IMP] start to add a special widget for reading the image from the pu…
sebastienbeau May 18, 2017
43ffe4e
[REF] refactor thumbnails and marke it work on small and medium of odoo
sebastienbeau May 22, 2017
855bd30
[REF] continue refactoring, remove inheriting ir.attachment as the wr…
sebastienbeau May 22, 2017
1b5d41a
[REF] finish to refactor and remove testing code as product_multi_ima…
sebastienbeau May 28, 2017
20fbf99
[IMP] add security rule for admin. Add TODO for adding some extra cod…
sebastienbeau May 29, 2017
71be1d0
Refactore Odoo, local and sftp storage
florian-dacosta May 30, 2017
e3bc779
Add pre and post init hook meant to be used is submodules
florian-dacosta May 31, 2017
8d38686
[IMP] improve storage with amazon S3, better support of cloudfront
sebastienbeau Jun 19, 2017
e3f2f0e
[FIX] jail local storage inside the directory <path_to_filestore>/st…
sebastienbeau Aug 25, 2017
aa9ab33
[REF] refactor code after reading this https://security.openstack.org…
sebastienbeau Aug 25, 2017
6621cf0
[FIX] fix pep 8
sebastienbeau Aug 25, 2017
e02246b
[REF] start refactoring sftp
sebastienbeau Aug 28, 2017
2021af2
[FIX] fix missing lib
sebastienbeau Aug 28, 2017
8082df2
[REF] start refactoring retriveing data, and rename method to have a …
sebastienbeau Aug 28, 2017
35f3ffb
[FIX] fix mode for reading local file
sebastienbeau Sep 8, 2017
4fcb805
[FIX] configure correctly the right access
sebastienbeau Sep 12, 2017
99f6d86
[FIX] fix pep8
sebastienbeau Sep 27, 2017
a1c374a
[IMP] rename retrieve_datas to retrieve_data
sebastienbeau Sep 27, 2017
a9f199a
[MIG] Make modules uninstallable
renatonlima Sep 27, 2017
ae929ee
[MIG] Rename manifest files
renatonlima Sep 27, 2017
b97bde8
MIGR storage_backend
bealdav Oct 2, 2017
27e4df4
Update manifest
hparfr Oct 2, 2017
0d78d76
[FIX] fix retrieving data for amazon
sebastienbeau Sep 30, 2017
f592b74
IMP set minimal README
bealdav Oct 3, 2017
2ccf6eb
update to new keychain api
hparfr Feb 6, 2018
616caf9
update new api
hparfr Feb 6, 2018
27f3cc4
Back port fixes in odoo_back from v8
hparfr Mar 29, 2018
ddf2c25
[REF] start to refactor code. Start to use component instead of odoo …
sebastienbeau Apr 9, 2018
489744e
[IMP] start adding tests for local storage
sebastienbeau Apr 9, 2018
3a5788b
[REF] rename filestore by filesystem
sebastienbeau Apr 9, 2018
b1cf4a0
[PEP8] pep8 clean up
sebastienbeau Apr 9, 2018
957eb6d
[IMP] add test for storage_file
sebastienbeau Apr 9, 2018
55e95b9
[REF] Several refactor for splitting amazon storage
sebastienbeau Apr 10, 2018
0fca23d
[REF] split sftp backend in a separated module
sebastienbeau Apr 11, 2018
ce9de17
[REF] rename method store and retrieve by more explicit method add/ge…
sebastienbeau Apr 11, 2018
8258de2
[REF] refactor test in order to use the same test between the differe…
sebastienbeau Apr 11, 2018
f687ef7
[IMP] add method for listing directory and deleting file on storage.b…
sebastienbeau Apr 13, 2018
f5491a5
[REF] review access right add special group for images, make method f…
sebastienbeau Apr 17, 2018
cc5b4df
[REF] set all module to the category storage
sebastienbeau Apr 17, 2018
c37d5e7
Add alt name of thumbnail + update openerp into odoo
acsonefho Apr 26, 2018
9889251
Remove read access on storage backend for common user
florian-dacosta Apr 10, 2019
79ed713
[FIX] clean with pre-commit and pep 8
bguillot Apr 10, 2019
39f2a70
[REF] refactor test for checking access right and refactor S3 testing
sebastienbeau Apr 11, 2019
5c5a1b8
[12.0][MIG] storage_backend
rousseldenis Jun 7, 2019
ea3c472
[ADD] icon.png
OCA-git-bot Sep 15, 2019
17de9d9
[FIX] __manifest__: Uses github repo url as website and add OCA into …
lmignon Sep 24, 2019
db4b08e
storage_backend 12.0.1.0.1
OCA-git-bot Sep 24, 2019
ac8db6e
pre-commit, black, isort
sbidoul Oct 1, 2019
9d91777
13.0: Create branche
lmignon Oct 21, 2019
7575296
[MIG] storage_backend: Migration to 13.0
Oct 22, 2019
09afc11
storage_backend_s3: improvements
simahawk Nov 2, 2019
6ae81e0
[MIG] storage_backend: Finalyse migration to 13.0
lmignon Nov 5, 2019
c1dd186
Add server_env support
simahawk Nov 22, 2019
73daf7d
storage_backend tests: use SavepointCase
simahawk Jan 16, 2020
018cf67
pre-commit update
OCA-git-bot Mar 14, 2020
5d99422
storage_backend: add generic validation action
simahawk Jun 19, 2020
d583f6d
storage_backend 13.0.1.1.0
OCA-git-bot Jul 2, 2020
1e0a86a
[FIX] fix wrong key in manisfest'
sebastienbeau Nov 20, 2020
83835af
storage_backend 13.0.1.1.1
OCA-git-bot Nov 20, 2020
d829f91
storage_backend: run permission tests explicitely
simahawk Oct 29, 2020
7d051b0
storage_backend: add _find_files + _move_files
simahawk Oct 29, 2020
6551453
storage_backend|_sftp: add test for find_files
simahawk Oct 29, 2020
fd676dc
storage_backend bump 13.0.1.2.0
simahawk Nov 23, 2020
7858e1b
storage_backend: fix development_status
simahawk Nov 23, 2020
b7ed5fe
storage_backend: expose public api (implements #51)
simahawk Nov 24, 2020
7a1400d
storage_backend 13.0.1.3.0
OCA-git-bot Nov 25, 2020
0764b79
[ADD] add new V14 config
sebastienbeau Dec 6, 2020
3de48a5
[IMP] all: black, isort, prettier
sebastienbeau Dec 6, 2020
9f79836
[MIG] batch migration of modules
sebastienbeau Dec 6, 2020
5d1af6d
storage_backend 14.0.1.0.1
OCA-git-bot Mar 1, 2021
42b3e46
filter files in _list by pattern in storage_backend
florian-dacosta May 10, 2021
08ff30e
storage_backend 14.0.1.1.0
OCA-git-bot Jun 9, 2021
16abd06
[CHG] storage: Use more permissive licence: AGPL-> LGPL
etobella Mar 10, 2021
d176358
storage_backend 14.0.2.0.0
OCA-git-bot Aug 2, 2021
51f6fba
[IMP] storage_backend: black, isort, prettier
gurneyalex Dec 1, 2021
a0586c1
[MIG] storage_backend: Migration to 15.0
gurneyalex Dec 1, 2021
203865d
[UPD] Update storage_backend.pot
Feb 22, 2022
d1f6367
[UPD] README.rst
OCA-git-bot Feb 22, 2022
297f218
[IMP] update dotfiles [ci skip]
OCA-git-bot Mar 31, 2022
b11b7f5
[IMP] storage_backend: check fullpath already passed to ``_fullpath()``
SilvioC2C Apr 6, 2022
da28b1f
[UPD] Update storage_backend.pot
Apr 6, 2022
80a12a2
storage_backend 15.0.1.0.1
OCA-git-bot Apr 6, 2022
956982a
[IMP] storage_backend: pre-commit stuff
vince-dynapps Feb 2, 2023
d8120db
[MIG] storage_backend: Migration to 16.0
vince-dynapps Feb 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup/storage_backend/odoo/addons/storage_backend
6 changes: 6 additions & 0 deletions setup/storage_backend/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
79 changes: 79 additions & 0 deletions storage_backend/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
==============
Storage Bakend
==============

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstorage-lightgray.png?logo=github
:target: https://github.com/OCA/storage/tree/15.0/storage_backend
:alt: OCA/storage
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/storage-15-0/storage-15-0-storage_backend
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/275/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|


**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/storage/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/storage/issues/new?body=module:%20storage_backend%0Aversion:%2015.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.

Credits
=======

Authors
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Sébastien BEAU <[email protected]>
* Raphaël Reverdy <[email protected]>
* Florian da Costa <[email protected]>
* Cédric Pigeon <[email protected]>
* Renato Lima <[email protected]>
* Benoît Guillot <[email protected]>
* Laurent Mignon <[email protected]>
* Denis Roussel <[email protected]>

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.

This module is part of the `OCA/storage <https://github.com/OCA/storage/tree/15.0/storage_backend>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions storage_backend/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import components
21 changes: 21 additions & 0 deletions storage_backend/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2017 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Storage Bakend",
"summary": "Implement the concept of Storage with amazon S3, sftp...",
"version": "16.0.1.0.0",
"category": "Storage",
"website": "https://github.com/OCA/storage",
"author": " Akretion, Odoo Community Association (OCA)",
"license": "LGPL-3",
"development_status": "Production/Stable",
"installable": True,
"depends": ["base", "component", "server_environment"],
"data": [
"views/backend_storage_view.xml",
"data/data.xml",
"security/ir.model.access.csv",
],
}
2 changes: 2 additions & 0 deletions storage_backend/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import base_adapter
from . import filesystem_adapter
69 changes: 69 additions & 0 deletions storage_backend/components/base_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2017 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
# Copyright 2020 ACSONE SA/NV (<http://acsone.eu>)
# @author Simone Orsi <[email protected]>

import os
import re

from odoo.addons.component.core import AbstractComponent


class BaseStorageAdapter(AbstractComponent):
_name = "base.storage.adapter"
_collection = "storage.backend"

def _fullpath(self, relative_path):
dp = self.collection.directory_path
if not dp or relative_path.startswith(dp):
return relative_path
return os.path.join(dp, relative_path)

def add(self, relative_path, data, **kwargs):
raise NotImplementedError

def get(self, relative_path, **kwargs):
raise NotImplementedError

def list(self, relative_path=""):
raise NotImplementedError

def find_files(self, pattern, relative_path="", **kwargs):
"""Find files matching given pattern.

:param pattern: regex expression
:param relative_path: optional relative path containing files
:return: list of file paths as full paths from the root
"""
regex = re.compile(pattern)
filelist = self.list(relative_path)
files_matching = [
regex.match(file_).group() for file_ in filelist if regex.match(file_)
]
filepaths = []
if files_matching:
filepaths = [
os.path.join(self._fullpath(relative_path) or "", filename)
for filename in files_matching
]
return filepaths

def move_files(self, files, destination_path, **kwargs):
"""Move files to given destination.

:param files: list of file paths to be moved
:param destination_path: directory path where to move files
:return: None
"""
raise NotImplementedError

def delete(self, relative_path):
raise NotImplementedError

# You can define `validate_config` on your own adapter
# to make validation button available on UI.
# This method should simply pass smoothly when validation is ok,
# otherwise it should raise an exception.
# def validate_config(self):
# raise NotImplementedError
59 changes: 59 additions & 0 deletions storage_backend/components/filesystem_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2017 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import os

from odoo import _
from odoo.exceptions import AccessError

from odoo.addons.component.core import Component


def is_safe_path(basedir, path):
return os.path.realpath(path).startswith(basedir)


class FileSystemStorageBackend(Component):
_name = "filesystem.adapter"
_inherit = "base.storage.adapter"
_usage = "filesystem"

def _basedir(self):
return os.path.join(self.env["ir.attachment"]._filestore(), "storage")

def _fullpath(self, relative_path):
"""This will build the full path for the file, we force to
store the data inside the filestore in the directory 'storage".
Becarefull if you implement your own custom path, end user
should never be able to write or read unwanted filesystem file"""
full_path = super(FileSystemStorageBackend, self)._fullpath(relative_path)
base_dir = self._basedir()
full_path = os.path.join(base_dir, full_path)
if not is_safe_path(base_dir, full_path):
raise AccessError(_("Access to %s is forbidden") % full_path)
return full_path

def add(self, relative_path, data, **kwargs):
full_path = self._fullpath(relative_path)
dirname = os.path.dirname(full_path)
if not os.path.isdir(dirname):
os.makedirs(dirname)
with open(full_path, "wb") as my_file:
my_file.write(data)

def get(self, relative_path, **kwargs):
full_path = self._fullpath(relative_path)
with open(full_path, "rb") as my_file:
data = my_file.read()
return data

def list(self, relative_path=""):
full_path = self._fullpath(relative_path)
if os.path.isdir(full_path):
return os.listdir(full_path)
return []

def delete(self, relative_path):
full_path = self._fullpath(relative_path)
os.remove(full_path)
7 changes: 7 additions & 0 deletions storage_backend/data/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="default_storage_backend" model="storage.backend">
<field name="name">Filesystem Backend</field>
<field name="backend_type">filesystem</field>
</record>
</odoo>
140 changes: 140 additions & 0 deletions storage_backend/i18n/storage_backend.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * storage_backend
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__backend_type_env_default
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__directory_path_env_default
msgid " Env Default"
msgstr ""

#. module: storage_backend
#: code:addons/storage_backend/components/filesystem_adapter.py:0
#, python-format
msgid "Access to %s is forbidden"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__backend_type
msgid "Backend Type"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__backend_type_env_is_editable
msgid "Backend Type Env Is Editable"
msgstr ""

#. module: storage_backend
#: code:addons/storage_backend/models/storage_backend.py:0
#, python-format
msgid "Connection Test Failed!"
msgstr ""

#. module: storage_backend
#: code:addons/storage_backend/models/storage_backend.py:0
#, python-format
msgid "Connection Test Succeeded!"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__create_uid
msgid "Created by"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__create_date
msgid "Created on"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__directory_path
msgid "Directory Path"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__directory_path_env_is_editable
msgid "Directory Path Env Is Editable"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__display_name
msgid "Display Name"
msgstr ""

#. module: storage_backend
#: code:addons/storage_backend/models/storage_backend.py:0
#, python-format
msgid "Everything seems properly set up!"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields.selection,name:storage_backend.selection__storage_backend__backend_type__filesystem
msgid "Filesystem"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__has_validation
msgid "Has Validation"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__id
msgid "ID"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend____last_update
msgid "Last Modified on"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__write_uid
msgid "Last Updated by"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__write_date
msgid "Last Updated on"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__name
msgid "Name"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,help:storage_backend.field_storage_backend__directory_path
#: model:ir.model.fields,help:storage_backend.field_storage_backend__directory_path_env_default
msgid "Relative path to the directory to store the file"
msgstr ""

#. module: storage_backend
#: model:ir.model.fields,field_description:storage_backend.field_storage_backend__server_env_defaults
msgid "Server Env Defaults"
msgstr ""

#. module: storage_backend
#: model:ir.actions.act_window,name:storage_backend.act_open_storage_backend_view
#: model:ir.model,name:storage_backend.model_storage_backend
#: model:ir.ui.menu,name:storage_backend.menu_storage
#: model:ir.ui.menu,name:storage_backend.menu_storage_backend
#: model_terms:ir.ui.view,arch_db:storage_backend.storage_backend_view_form
#: model_terms:ir.ui.view,arch_db:storage_backend.storage_backend_view_search
msgid "Storage Backend"
msgstr ""

#. module: storage_backend
#: model_terms:ir.ui.view,arch_db:storage_backend.storage_backend_view_form
msgid "Test connection"
msgstr ""
1 change: 1 addition & 0 deletions storage_backend/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import storage_backend
Loading