Skip to content

Commit

Permalink
[MIG] storage_backend: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thienvh332 committed Nov 5, 2024
1 parent 499a0a7 commit 5649725
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 54 deletions.
13 changes: 10 additions & 3 deletions storage_backend/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
==============
Storage Bakend
==============
===============
Storage Backend
===============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down Expand Up @@ -74,6 +74,13 @@ Contributors
- Benoît Guillot <[email protected]>
- Laurent Mignon <[email protected]>
- Denis Roussel <[email protected]>
- Thien Vo <[email protected]>

Other credits
-------------

The migration of this module from 16.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------
Expand Down
4 changes: 2 additions & 2 deletions storage_backend/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Storage Bakend",
"name": "Storage Backend",
"summary": "Implement the concept of Storage with amazon S3, sftp...",
"version": "16.0.1.0.2",
"version": "18.0.1.0.0",
"category": "Storage",
"website": "https://github.com/OCA/storage",
"author": " Akretion, Odoo Community Association (OCA)",
Expand Down
5 changes: 2 additions & 3 deletions storage_backend/components/filesystem_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os
import shutil

from odoo import _
from odoo.exceptions import AccessError

from odoo.addons.component.core import Component
Expand All @@ -31,11 +30,11 @@ def _fullpath(self, relative_path):
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)
full_path = super()._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)
raise AccessError(self.env._("Access to %s is forbidden") % full_path)

Check warning on line 37 in storage_backend/components/filesystem_adapter.py

View check run for this annotation

Codecov / codecov/patch

storage_backend/components/filesystem_adapter.py#L37

Added line #L37 was not covered by tests
return full_path

def add(self, relative_path, data, **kwargs):
Expand Down
40 changes: 4 additions & 36 deletions storage_backend/models/storage_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
import warnings

from odoo import _, fields, models
from odoo import fields, models

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -89,59 +89,27 @@ def add(self, relative_path, data, binary=True, **kwargs):
data = base64.b64decode(data)
return self._forward("add", relative_path, data, **kwargs)

@deprecated("Use `add`")
def _add_bin_data(self, relative_path, data, **kwargs):
return self.add(relative_path, data, **kwargs)

@deprecated("Use `add` with `binary=False`")
def _add_b64_data(self, relative_path, data, **kwargs):
return self.add(relative_path, data, binary=False, **kwargs)

def get(self, relative_path, binary=True, **kwargs):
data = self._forward("get", relative_path, **kwargs)
if not binary and data:
data = base64.b64encode(data)
return data

@deprecated("Use `get` with `binary=False`")
def _get_b64_data(self, relative_path, **kwargs):
return self.get(relative_path, binary=False, **kwargs)

@deprecated("Use `get`")
def _get_bin_data(self, relative_path, **kwargs):
return self.get(relative_path, **kwargs)

def list_files(self, relative_path="", pattern=False):
names = self._forward("list", relative_path)
if pattern:
names = fnmatch.filter(names, pattern)

Check warning on line 101 in storage_backend/models/storage_backend.py

View check run for this annotation

Codecov / codecov/patch

storage_backend/models/storage_backend.py#L101

Added line #L101 was not covered by tests
return names

@deprecated("Use `list_files`")
def _list(self, relative_path="", pattern=False):
return self.list_files(relative_path, pattern=pattern)

def find_files(self, pattern, relative_path="", **kw):
return self._forward("find_files", pattern, relative_path=relative_path)

@deprecated("Use `find_files`")
def _find_files(self, pattern, relative_path="", **kw):
return self.find_files(pattern, relative_path=relative_path, **kw)

def move_files(self, files, destination_path, **kw):
return self._forward("move_files", files, destination_path, **kw)

@deprecated("Use `move_files`")
def _move_files(self, files, destination_path, **kw):
return self.move_files(files, destination_path, **kw)

def delete(self, relative_path):
return self._forward("delete", relative_path)

@deprecated("Use `delete`")
def _delete(self, relative_path):
return self.delete(relative_path)

def _forward(self, method, *args, **kwargs):
_logger.debug(
"Backend Storage ID: %s type %s: %s file %s %s",
Expand All @@ -165,11 +133,11 @@ def action_test_config(self):
adapter = self._get_adapter()
try:
adapter.validate_config()
title = _("Connection Test Succeeded!")
message = _("Everything seems properly set up!")
title = self.env._("Connection Test Succeeded!")
message = self.env._("Everything seems properly set up!")
msg_type = "success"
except Exception as err:
title = _("Connection Test Failed!")
title = self.env._("Connection Test Failed!")
message = str(err)
msg_type = "danger"
return {

Check warning on line 143 in storage_backend/models/storage_backend.py

View check run for this annotation

Codecov / codecov/patch

storage_backend/models/storage_backend.py#L132-L143

Added lines #L132 - L143 were not covered by tests
Expand Down
1 change: 1 addition & 0 deletions storage_backend/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
- Benoît Guillot \<<[email protected]>\>
- Laurent Mignon \<<[email protected]>\>
- Denis Roussel \<<[email protected]>\>
- Thien Vo \<<[email protected]>\>
1 change: 1 addition & 0 deletions storage_backend/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 16.0 to 18.0 was financially supported by Camptocamp.
17 changes: 12 additions & 5 deletions storage_backend/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Storage Bakend</title>
<title>Storage Backend</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,8 +360,8 @@
</style>
</head>
<body>
<div class="document" id="storage-bakend">
<h1 class="title">Storage Bakend</h1>
<div class="document" id="storage-backend">
<h1 class="title">Storage Backend</h1>

<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
Expand All @@ -379,7 +379,8 @@ <h1 class="title">Storage Bakend</h1>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-7">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -417,10 +418,16 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Benoît Guillot &lt;<a class="reference external" href="mailto:benoit.guillot&#64;akretion.com">benoit.guillot&#64;akretion.com</a>&gt;</li>
<li>Laurent Mignon &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li>
<li>Denis Roussel &lt;<a class="reference external" href="mailto:denis.roussel&#64;acsone.eu">denis.roussel&#64;acsone.eu</a>&gt;</li>
<li>Thien Vo &lt;<a class="reference external" href="mailto:thienvh&#64;trobz.com">thienvh&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2>
<p>The migration of this module from 16.0 to 18.0 was financially supported
by Camptocamp.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand Down
10 changes: 5 additions & 5 deletions storage_backend/views/backend_storage_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<record id="storage_backend_view_tree" model="ir.ui.view">
<field name="model">storage.backend</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="backend_type" />
</tree>
</list>
</field>
</record>
<record id="storage_backend_view_form" model="ir.ui.view">
Expand All @@ -19,7 +19,7 @@
type="object"
name="action_test_config"
string="Test connection"
attrs="{'invisible': [('has_validation', '=', False)]}"
invisible="has_validation == False"
/>
</header>
<sheet>
Expand Down Expand Up @@ -49,7 +49,7 @@
<field name="name">Storage Backend</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">storage.backend</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="storage_backend_view_search" />
<field name="domain">[]</field>
<field name="context">{}</field>
Expand All @@ -63,7 +63,7 @@
<record model="ir.actions.act_window.view" id="act_open_storage_backend_view_tree">
<field name="act_window_id" ref="act_open_storage_backend_view" />
<field name="sequence" eval="10" />
<field name="view_mode">tree</field>
<field name="view_mode">list</field>
<field name="view_id" ref="storage_backend_view_tree" />
</record>
<menuitem
Expand Down

0 comments on commit 5649725

Please sign in to comment.