Skip to content

Commit 88ee7e3

Browse files
committed
[BPRT] edi_storage_oca: Backport from 14.0
1 parent 8edb534 commit 88ee7e3

11 files changed

+65
-30
lines changed

edi_storage_oca/README.rst

+15-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ EDI Storage backend support
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:8b943f104b4d54ed51a4fb55f4e17ffe1ec3995e962bb7654ea4c5837d952673
10+
!! source digest: sha256:58511c29ba3a21a1216a155c53ffb1da90ba5561d407af23213e4207b9a0bcaf
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ EDI Storage backend support
1717
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1818
:alt: License: LGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github
20-
:target: https://github.com/OCA/edi/tree/14.0/edi_storage_oca
20+
:target: https://github.com/OCA/edi/tree/12.0/edi_storage_oca
2121
:alt: OCA/edi
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-edi_storage_oca
23+
:target: https://translation.odoo-community.org/projects/edi-12-0/edi-12-0-edi_storage_oca
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/edi&target_branch=14.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/edi&target_branch=12.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -68,7 +68,7 @@ Bug Tracker
6868
Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/issues>`_.
6969
In case of trouble, please check there if your issue has already been reported.
7070
If you spotted it first, help us to smash it by providing a detailed and welcomed
71-
`feedback <https://github.com/OCA/edi/issues/new?body=module:%20edi_storage_oca%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
71+
`feedback <https://github.com/OCA/edi/issues/new?body=module:%20edi_storage_oca%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
7272

7373
Do not contact contributors directly about support or help with technical issues.
7474

@@ -86,6 +86,15 @@ Contributors
8686
* Simone Orsi <simahawk@gmail.com>
8787
* Foram Shah <foram.shah@initos.com>
8888
* Lois Rilo <lois.rilo@forgeflow.com>
89+
* `Trobz <https://trobz.com>`_:
90+
91+
* Thien <thienvh@trobz.com>
92+
93+
94+
Other credits
95+
~~~~~~~~~~~~~
96+
97+
The backport of this module from 14.0 to 12.0 was financially supported by Camptocamp
8998

9099
Maintainers
91100
~~~~~~~~~~~
@@ -100,6 +109,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
100109
mission is to support the collaborative development of Odoo features and
101110
promote its widespread use.
102111

103-
This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/14.0/edi_storage_oca>`_ project on GitHub.
112+
This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/12.0/edi_storage_oca>`_ project on GitHub.
104113

105114
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

edi_storage_oca/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"summary": """
88
Base module to allow exchanging files via storage backend (eg: SFTP).
99
""",
10-
"version": "14.0.1.8.1",
10+
"version": "12.0.1.0.1",
1111
"development_status": "Beta",
1212
"license": "LGPL-3",
1313
"website": "https://github.com/OCA/edi",

edi_storage_oca/components/listener.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class EdiStorageListener(Component):
1414
def _move_file(self, storage, from_dir_str, to_dir_str, filename):
1515
from_dir = PurePath(from_dir_str)
1616
to_dir = PurePath(to_dir_str)
17-
if filename not in storage.list_files(from_dir.as_posix()):
17+
if filename not in storage._list(from_dir.as_posix()):
1818
# The file might have been moved after a previous error.
1919
return False
2020
self._add_after_commit_hook(
@@ -24,7 +24,7 @@ def _move_file(self, storage, from_dir_str, to_dir_str, filename):
2424

2525
def _remove_file(self, storage, from_dir_str, filename):
2626
from_dir = PurePath(from_dir_str)
27-
if filename not in storage.list_files(from_dir.as_posix()):
27+
if filename not in storage._list(from_dir.as_posix()):
2828
# The file might have been moved after a previous error.
2929
return False
3030
self._add_after_commit_hook(storage.delete, (from_dir / filename).as_posix())

edi_storage_oca/models/edi_backend.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,12 @@ def _storage_create_record_if_missing(self, exchange_type, remote_file_name):
140140
if existing:
141141
return
142142
record = self.create_record(
143-
exchange_type.code, self._storage_new_exchange_record_vals(file_name)
143+
exchange_type.code,
144+
{
145+
"edi_exchange_state": "input_pending"
146+
}
144147
)
148+
record.exchange_filename = file_name
145149
_logger.debug("%s: new exchange record generated.", self.name)
146150
return record.identifier
147151

@@ -153,7 +157,7 @@ def _storage_get_input_filenames(self, exchange_type):
153157
# If there is not pattern, return everything
154158
filenames = [
155159
x
156-
for x in self.storage_id.list_files(full_input_dir_pending)
160+
for x in self.storage_id._list(full_input_dir_pending)
157161
if x.strip("/")
158162
]
159163
return filenames
@@ -162,13 +166,10 @@ def _storage_get_input_filenames(self, exchange_type):
162166
if exchange_type.exchange_file_ext:
163167
bits.append(r"\." + exchange_type.exchange_file_ext)
164168
pattern = "".join(bits)
165-
full_paths = self.storage_id.find_files(pattern, full_input_dir_pending)
169+
full_paths = self.storage_id._find_files(pattern, full_input_dir_pending)
166170
pending_path_len = len(full_input_dir_pending)
167171
return [p[pending_path_len:].strip("/") for p in full_paths]
168172

169-
def _storage_new_exchange_record_vals(self, file_name):
170-
return {"exchange_filename": file_name, "edi_exchange_state": "input_pending"}
171-
172173
def _check_output_exchange_sync(self, **kw):
173174
# Do not skip sent records when dealing w/ storage related exchanges,
174175
# because we want to update the file state
+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
* Simone Orsi <simahawk@gmail.com>
22
* Foram Shah <foram.shah@initos.com>
33
* Lois Rilo <lois.rilo@forgeflow.com>
4+
* `Trobz <https://trobz.com>`_:
5+
6+
* Thien <thienvh@trobz.com>
7+

edi_storage_oca/readme/CREDITS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The backport of this module from 14.0 to 12.0 was financially supported by Camptocamp

edi_storage_oca/static/description/index.html

+24-9
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ <h1 class="title">EDI Storage backend support</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:8b943f104b4d54ed51a4fb55f4e17ffe1ec3995e962bb7654ea4c5837d952673
370+
!! source digest: sha256:58511c29ba3a21a1216a155c53ffb1da90ba5561d407af23213e4207b9a0bcaf
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/edi/tree/14.0/edi_storage_oca"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-edi_storage_oca"><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/edi&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/edi/tree/12.0/edi_storage_oca"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/edi-12-0/edi-12-0-edi_storage_oca"><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/edi&amp;target_branch=12.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>Allow exchange files using storage backends from <cite>OCA/storage</cite>.</p>
374374
<p>This module adds a storage backend relation on the EDI backend.
375375
There you can configure the backend to be used (most often and SFTP)
@@ -399,7 +399,8 @@ <h1 class="title">EDI Storage backend support</h1>
399399
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
400400
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
401401
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
402-
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
402+
<li><a class="reference internal" href="#other-credits" id="toc-entry-6">Other credits</a></li>
403+
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
403404
</ul>
404405
</li>
405406
</ul>
@@ -413,7 +414,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
413414
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/edi/issues">GitHub Issues</a>.
414415
In case of trouble, please check there if your issue has already been reported.
415416
If you spotted it first, help us to smash it by providing a detailed and welcomed
416-
<a class="reference external" href="https://github.com/OCA/edi/issues/new?body=module:%20edi_storage_oca%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
417+
<a class="reference external" href="https://github.com/OCA/edi/issues/new?body=module:%20edi_storage_oca%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
417418
<p>Do not contact contributors directly about support or help with technical issues.</p>
418419
</div>
419420
<div class="section" id="credits">
@@ -426,20 +427,34 @@ <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
426427
</div>
427428
<div class="section" id="contributors">
428429
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
430+
<ul>
431+
<li><p class="first">Simone Orsi &lt;<a class="reference external" href="mailto:simahawk&#64;gmail.com">simahawk&#64;gmail.com</a>&gt;</p>
432+
</li>
433+
<li><p class="first">Foram Shah &lt;<a class="reference external" href="mailto:foram.shah&#64;initos.com">foram.shah&#64;initos.com</a>&gt;</p>
434+
</li>
435+
<li><p class="first">Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</p>
436+
</li>
437+
<li><p class="first"><a class="reference external" href="https://trobz.com">Trobz</a>:</p>
438+
<blockquote>
429439
<ul class="simple">
430-
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simahawk&#64;gmail.com">simahawk&#64;gmail.com</a>&gt;</li>
431-
<li>Foram Shah &lt;<a class="reference external" href="mailto:foram.shah&#64;initos.com">foram.shah&#64;initos.com</a>&gt;</li>
432-
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
440+
<li>Thien &lt;<a class="reference external" href="mailto:thienvh&#64;trobz.com">thienvh&#64;trobz.com</a>&gt;</li>
433441
</ul>
442+
</blockquote>
443+
</li>
444+
</ul>
445+
</div>
446+
<div class="section" id="other-credits">
447+
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
448+
<p>The backport of this module from 14.0 to 12.0 was financially supported by Camptocamp</p>
434449
</div>
435450
<div class="section" id="maintainers">
436-
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
451+
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
437452
<p>This module is maintained by the OCA.</p>
438453
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
439454
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
440455
mission is to support the collaborative development of Odoo features and
441456
promote its widespread use.</p>
442-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/14.0/edi_storage_oca">OCA/edi</a> project on GitHub.</p>
457+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/12.0/edi_storage_oca">OCA/edi</a> project on GitHub.</p>
443458
<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>
444459
</div>
445460
</div>

edi_storage_oca/tests/common.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,22 @@ def _mocked_backend_list_files(self, mocked_paths, path, **kwargs):
106106

107107
def _mock_storage_backend_get(self, mocked_paths):
108108
mocked = functools.partial(self._mocked_backend_get, mocked_paths)
109-
return mock.patch(STORAGE_BACKEND_MOCK_PATH + ".get", mocked)
109+
return mock.patch(STORAGE_BACKEND_MOCK_PATH + "._get_b64_data", mocked)
110110

111111
def _mock_storage_backend_add(self):
112-
return mock.patch(STORAGE_BACKEND_MOCK_PATH + ".add", self._mocked_backend_add)
112+
return mock.patch(
113+
STORAGE_BACKEND_MOCK_PATH + "._add_b64_data", self._mocked_backend_add
114+
)
113115

114116
def _mock_storage_backend_list_files(self, mocked_paths):
115117
mocked = functools.partial(self._mocked_backend_list_files, mocked_paths)
116-
return mock.patch(STORAGE_BACKEND_MOCK_PATH + ".list_files", mocked)
118+
return mock.patch(STORAGE_BACKEND_MOCK_PATH + "._list", mocked)
117119

118120
def _mock_storage_backend_find_files(self, result):
119121
def _result(self, pattern, relative_path=None, **kw):
120122
return result
121123

122-
return mock.patch(STORAGE_BACKEND_MOCK_PATH + ".find_files", _result)
124+
return mock.patch(STORAGE_BACKEND_MOCK_PATH + "._find_files", _result)
123125

124126
def _test_result(
125127
self,

edi_storage_oca/tests/test_components_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_remote_file_path(self):
3030
self.checker_input._get_remote_file_path("WHATEVER", "foo.csv")
3131

3232
def test_get_remote_file(self):
33-
with mock.patch(STORAGE_BACKEND_MOCK_PATH + ".get") as mocked:
33+
with mock.patch(STORAGE_BACKEND_MOCK_PATH + "._get_b64_data") as mocked:
3434
self.checker._get_remote_file("pending")
3535
mocked.assert_called_with(
3636
"demo_out/pending/{}".format(self._filename(self.record)), binary=False

edi_storage_oca/tests/test_edi_backend_storage.py

+4
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ def test_cron_full_flow(self):
161161
"exchange_file": rec1.exchange_file,
162162
}
163163
)
164+
# Avoid the exchange_file name generated from the compute function
165+
# of rec2 and rec3 is the same, leading to an incorrect test
166+
rec2.exchange_filename = "rec2.csv"
167+
164168
mocked_paths = {
165169
self._file_fullpath("done", record=rec1): self.fakepath,
166170
self._file_fullpath("error", record=rec2): self.fakepath,

edi_storage_oca/tests/test_edi_storage_listener.py

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def test_02_process_record_with_error(self):
7575

7676
def test_03_process_record_success_delete(self):
7777
self.backend.write({"input_dir_remove": True, "input_dir_done": False})
78-
self.backend.flush()
7978

8079
with self._mock_listener_remove_file():
8180
self.record.write({"edi_exchange_state": "input_received"})

0 commit comments

Comments
 (0)