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 @@ - +