diff --git a/external_file_location/__openerp__.py b/external_file_location/__openerp__.py
index b485d0d0..57c4ba35 100644
--- a/external_file_location/__openerp__.py
+++ b/external_file_location/__openerp__.py
@@ -38,6 +38,7 @@
'menu.xml',
'location_view.xml',
'task_view.xml',
+ 'cron.xml',
],
'installable': True,
'application': True,
diff --git a/external_file_location/attachment.py b/external_file_location/attachment.py
index 33e55086..30b8e335 100644
--- a/external_file_location/attachment.py
+++ b/external_file_location/attachment.py
@@ -33,3 +33,7 @@ class IrAttachment(models.Model):
('done', 'Done'),
], readonly=True, 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',
+ related='task_id.location_id', store=True
+ )
diff --git a/external_file_location/attachment_view.xml b/external_file_location/attachment_view.xml
index cfbcecfb..640b4819 100644
--- a/external_file_location/attachment_view.xml
+++ b/external_file_location/attachment_view.xml
@@ -10,8 +10,9 @@
+
+
-
@@ -21,8 +22,8 @@
-
-
+
+
@@ -32,6 +33,40 @@
+
+ ir.attachment
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Attachments
ir.actions.act_window
@@ -39,10 +74,12 @@
form
kanban,tree,form
+ [('task_id', '!=', False)]
+
-
+
kanban
diff --git a/external_file_location/cron.xml b/external_file_location/cron.xml
new file mode 100644
index 00000000..a18f5f6a
--- /dev/null
+++ b/external_file_location/cron.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ Run file exchange tasks
+ 30
+ minutes
+ -1
+ True
+
+ external.file.task
+ _run
+ ([])
+
+
+
+
diff --git a/external_file_location/task.py b/external_file_location/task.py
index 70759aab..948e4772 100644
--- a/external_file_location/task.py
+++ b/external_file_location/task.py
@@ -34,7 +34,8 @@ class Task(models.Model):
filename = fields.Char()
filepath = fields.Char()
location_id = fields.Many2one('external.file.location', string='Location')
- attachment_id = fields.Many2one('ir.attachment', string='Attachment')
+ attachment_ids = fields.One2many('ir.attachment', 'task_id',
+ string='Attachment')
def _get_method(self):
res = []
@@ -45,7 +46,14 @@ class Task(models.Model):
res.append(cls_info)
return res
- @api.multi
+ @api.model
+ def _run(self, domain=None):
+ if not domain:
+ domain = []
+ tasks = self.env['external.file.task'].search(domain)
+ tasks.run()
+
+ @api.one
def run(self):
for cls in itersubclasses(AbstractTask):
if cls._synchronize_type and \
diff --git a/external_file_location/task_view.xml b/external_file_location/task_view.xml
index 284b63fe..caf1dc7f 100644
--- a/external_file_location/task_view.xml
+++ b/external_file_location/task_view.xml
@@ -13,7 +13,7 @@
-
+
diff --git a/external_file_location/tasks/.filestore.py.swp b/external_file_location/tasks/.filestore.py.swp
deleted file mode 100644
index 09405007..00000000
Binary files a/external_file_location/tasks/.filestore.py.swp and /dev/null differ
diff --git a/external_file_location/tasks/ftp.py b/external_file_location/tasks/ftp.py
index 6992aba6..5bbeaf49 100644
--- a/external_file_location/tasks/ftp.py
+++ b/external_file_location/tasks/ftp.py
@@ -42,7 +42,7 @@ class FtpTask(AbstractTask):
self.port = config.get('port', '')
self.allow_dir_creation = config.get('allow_dir_creation', '')
self.file_name = config.get('file_name', '')
- self.path = config.get('path', '')
+ self.path = config.get('path', './')
self.move_path = config.get('move_path', '')
self.delete_file = config.get('delete_file', False)
self.attachment_id = config.get('attachment_id', False)
@@ -138,6 +138,7 @@ class FtpExportTask(FtpTask):
fileobj.write(filedata)
_logger.info('wrote %s, size %d', target_name, len(filedata))
self.attachment_id.state = 'done'
+ self.attachment_id.state_message = ''
except FTPIOError:
self.attachment_id.state = 'failed'
self.attachment_id.state_message = (