You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
858 B

  1. # @ 2016 Florian DA COSTA @ Akretion
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import models, fields, api
  4. import os
  5. class IrAttachmentMetadata(models.Model):
  6. _inherit = 'ir.attachment.metadata'
  7. task_id = fields.Many2one('storage.backend.task', string='Task')
  8. storage_backend_id = fields.Many2one(
  9. 'storage.backend', string='Storage Backend',
  10. related='task_id.backend_id', store=True)
  11. file_type = fields.Selection(
  12. selection_add=[
  13. ('export',
  14. 'Export File (External location)')
  15. ])
  16. @api.multi
  17. def _run(self):
  18. super(IrAttachmentMetadata, self)._run()
  19. if self.file_type == 'export':
  20. path = os.path.join(self.task_id.filepath, self.datas_fname)
  21. self.storage_backend_id._add_b64_data(path, self.datas)