Skip to content

Commit

Permalink
[IMP] edi_storage_oca: Allow files with duplicate names to create Edi…
Browse files Browse the repository at this point in the history
… Exchange Record
  • Loading branch information
thienvh332 committed Feb 10, 2025
1 parent f070e47 commit 8f7b612
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion edi_storage_oca/models/edi_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class EDIBackend(models.Model):
output_dir_error = fields.Char(
"Output error directory", help="Path to folder for error operations"
)
input_allow_duplicate_filename = fields.Boolean(
help="For this backend, filenames are not unique, e.g. output.edi")

_storage_actions = ("check", "send", "receive")

Expand Down Expand Up @@ -133,7 +135,9 @@ def _storage_exchange_type_pending_input_domain(self):
def _storage_create_record_if_missing(self, exchange_type, remote_file_name):
"""Create a new exchange record for given type and file name if missing."""
file_name = os.path.basename(remote_file_name)
extra_domain = [("exchange_filename", "=", file_name)]
extra_domain = []
if not self.input_allow_duplicate_filename:
extra_domain.append(["exchange_filename", "=", file_name])
existing = self._find_existing_exchange_records(
exchange_type, extra_domain=extra_domain, count_only=True
)
Expand Down
1 change: 1 addition & 0 deletions edi_storage_oca/views/edi_backend_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<field name="storage_id" />
<field name="input_dir_pending" />
<field name="input_dir_remove" />
<field name="input_allow_duplicate_filename" />
<field
name="input_dir_done"
attrs="{'invisible': [('input_dir_remove', '=', True)]}"
Expand Down

0 comments on commit 8f7b612

Please sign in to comment.