From 277cd2005503aafd4ba38c4de9df3d20f46dcc71 Mon Sep 17 00:00:00 2001 From: Valentin Chemiere Date: Wed, 4 Mar 2015 18:55:37 +0100 Subject: [PATCH] One task could have multiple attachment to handle --- external_file_location/abstract_task.py | 10 +++------- external_file_location/attachment.py | 2 +- external_file_location/task.py | 3 ++- external_file_location/task_view.xml | 3 ++- external_file_location/tasks/ftp.py | 24 +++++++++++++++--------- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/external_file_location/abstract_task.py b/external_file_location/abstract_task.py index 322f0062..13eae0cc 100755 --- a/external_file_location/abstract_task.py +++ b/external_file_location/abstract_task.py @@ -11,13 +11,9 @@ class AbstractTask(object): { 'name': filename, 'datas': b64encode(data), - 'datas_fname': filename + 'datas_fname': filename, + 'task_id': self.task.id, + 'location_id': self.task.location_id.id } ) return ir_attachment_id - - # def load_file(self, file_id): - # f = self.session.browse('impexp.file', file_id) - # if not f.attachment_id.datas: - # return None - # return b64decode(f.attachment_id.datas) diff --git a/external_file_location/attachment.py b/external_file_location/attachment.py index 30b8e335..410da1db 100644 --- a/external_file_location/attachment.py +++ b/external_file_location/attachment.py @@ -31,7 +31,7 @@ class IrAttachment(models.Model): ('pending', 'Pending'), ('failed', 'Failed'), ('done', 'Done'), - ], readonly=True, required=True, default='pending') + ], readonly=False, required=True, default='pending') state_message = fields.Text() task_id = fields.Many2one('external.file.task', string='Task') location_id = fields.Many2one('external.file.location', string='Location', diff --git a/external_file_location/task.py b/external_file_location/task.py index 948e4772..af190eba 100644 --- a/external_file_location/task.py +++ b/external_file_location/task.py @@ -67,7 +67,8 @@ class Task(models.Model): 'allow_dir_creation': False, 'file_name': self.filename, 'path': self.filepath, - 'attachment_id': self.attachment_id, + 'attachment_ids': self.attachment_ids, + 'task': self, } conn = method_class(self.env, config) conn.run() diff --git a/external_file_location/task_view.xml b/external_file_location/task_view.xml index caf1dc7f..9e907e92 100644 --- a/external_file_location/task_view.xml +++ b/external_file_location/task_view.xml @@ -13,7 +13,8 @@ - + +