From 3d5af8d79b5a4503e17db4e0f9fce46a6d74ff4c Mon Sep 17 00:00:00 2001 From: Marco Folco Date: Mon, 4 Nov 2019 11:54:43 -0300 Subject: [PATCH] [MOD]document_sftp_root_by_model.py Changed _list_folder method to show " - " instead of only in the ftp --- document_sftp/models/document_sftp_root_by_model.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/document_sftp/models/document_sftp_root_by_model.py b/document_sftp/models/document_sftp_root_by_model.py index 76d0c818..26aa1abf 100644 --- a/document_sftp/models/document_sftp_root_by_model.py +++ b/document_sftp/models/document_sftp_root_by_model.py @@ -64,11 +64,18 @@ class DocumentSFTPRootByModel(models.Model): ], order='res_id asc'): # TODO: better lump ids together in steps of 100 or something? if attachment.res_id not in seen: - seen.add(attachment.res_id) - result.append(self._directory(str(attachment.res_id))) + res_id = attachment.res_id + res_model = attachment.res_model + seen.add(res_id) + res = self.env[res_model].browse(res_id) + if res.name: + display_name = str(res_id) + ' - ' + res.name + else: + display_name = str(res_id) + ' - No Name' + result.append(self._directory(display_name)) elif len(components) == 3: model = components[-2] - res_id = int(components[-1]) + res_id = int(components[-1].split('-')[0]) for attachment in self.env['ir.attachment'].search([ ('res_model', '=', model), ('res_id', '=', res_id),