diff --git a/attachment_synchronize/models/task.py b/attachment_synchronize/models/task.py index 5bea4d541..b156ecb41 100644 --- a/attachment_synchronize/models/task.py +++ b/attachment_synchronize/models/task.py @@ -204,9 +204,11 @@ class AttachmentSynchronizeTask(models.Model): ) def _file_to_import(self, filenames): - imported = self.attachment_ids.filtered( - lambda r: r.name in filenames - ).mapped("name") + imported = ( + self.env["attachment.queue"] + .search([("name", "in", filenames)]) + .mapped("name") + ) return list(set(filenames) - set(imported)) def button_toogle_enabled(self): diff --git a/attachment_synchronize/tests/common.py b/attachment_synchronize/tests/common.py index 56418e556..ddaa26da0 100644 --- a/attachment_synchronize/tests/common.py +++ b/attachment_synchronize/tests/common.py @@ -29,7 +29,7 @@ class SyncCommon(Common): self.env.cr.commit = mock.Mock() self.registry.enter_test_mode(self.env.cr) self.directory_input = "test_import" - self.directory_output = "test_output" + self.directory_output = "test_export" self.directory_archived = "test_archived" self._clean_testing_directory() self._create_test_file() diff --git a/attachment_synchronize/tests/test_export.py b/attachment_synchronize/tests/test_export.py index 1f37c41ef..18ce825a3 100644 --- a/attachment_synchronize/tests/test_export.py +++ b/attachment_synchronize/tests/test_export.py @@ -4,6 +4,7 @@ import mock from .common import SyncCommon +from odoo.tools import mute_logger def raising_side_effect(*args, **kwargs): @@ -29,6 +30,7 @@ class TestExport(SyncCommon): result = self.backend._list("test_export") self.assertEqual(result, ["foo.txt"]) + @mute_logger("odoo.addons.attachment_queue.models.attachment_queue") def test_failing_export(self): with mock.patch.object( type(self.backend), diff --git a/attachment_synchronize/tests/test_import.py b/attachment_synchronize/tests/test_import.py index 8846ff26e..6bf9b50f6 100644 --- a/attachment_synchronize/tests/test_import.py +++ b/attachment_synchronize/tests/test_import.py @@ -15,9 +15,7 @@ class TestImport(SyncCommon): return self.backend._list(self.directory_input) def _check_attachment_created(self, count=1): - attachment = self.env["attachment.queue"].search( - [("name", "=", "bar.txt")] - ) + attachment = self.env["attachment.queue"].search([("name", "=", "bar.txt")]) self.assertEqual(len(attachment), count) def test_import_with_rename(self): @@ -28,9 +26,7 @@ class TestImport(SyncCommon): self.assertEqual(self.archived_files, []) def test_import_with_move(self): - self.task.write( - {"after_import": "move", "move_path": self.directory_archived} - ) + self.task.write({"after_import": "move", "move_path": self.directory_archived}) self.task.run_import() self._check_attachment_created() self.assertEqual(self.input_files, [])