Browse Source

[ADD] add file type on attachment_metadata

pull/515/head
Mourad El Hadj Mimoune 9 years ago
committed by Florian da Costa
parent
commit
490e867138
  1. 12
      attachment_metadata/models/attachment.py
  2. 1
      attachment_metadata/views/attachment_view.xml

12
attachment_metadata/models/attachment.py

@ -25,6 +25,11 @@ class IrAttachmentMetadata(models.Model):
attachment_id = fields.Many2one(
'ir.attachment', required=True, ondelete='cascade',
help="Link to ir.attachment model ")
file_type = fields.Selection(
selection="_get_file_type",
string="File type",
help="The file type detrmine an import method to be used "
"to parse and transforme data before theire import in odoo")
@api.depends('datas', 'external_hash')
def _compute_hash(self):
@ -34,3 +39,10 @@ class IrAttachmentMetadata(models.Model):
raise UserError(
_("File corrupted: Something was wrong with "
"the retrieved file, please relaunch the task."))
def _get_file_type(self):
"""This is the method to be inherited for adding file types
The basic import do not apply any parsing or transform of the file.
The file is just added as an attachement
"""
return [('basic_import', 'Basic import')]

1
attachment_metadata/views/attachment_view.xml

@ -9,6 +9,7 @@
<field name="url" position="after">
<field name="internal_hash"/>
<field name="external_hash"/>
<field name="file_type"/>
</field>
</field>
</record>

Loading…
Cancel
Save