File types for attachments
attachment_file_type · OCA/knowledge
-
Security25/25No findings
-
Activity0/25Last human commit 141 months ago
-
Required by5/250 modules depend on it
-
Maturity5/25In 1 Odoo series since 6.1
Heuristic over the facts below, not an audit · How it's computed
Migration considerations
- Migrating to 19.0: only `__manifest__.py` is recognized: a module with `__openerp__.py` is not detected at all. migration-openerp-manifest · source
Attachment— Class 'Attachment' still inherits from the old-style `orm.Model` API: rewrite it against `models.Model`/`models.TransientModel`/`models.AbstractModel` - the old `osv`/`orm` API was removed entirely in modern Odoo. migration-old-api-base · sourceAttachment— Class 'Attachment' declares `_columns` as a plain dict: old-style field/default declarations, replace with `fields.X(...)` class attributes and `default=`. migration-old-style-fields · sourcecron_update_file_type— Migrating to 18.0: `ir.cron` lost `numbercall`/`doall`: remove them from the record, data loading fails on unknown fields. migration-cron-numbercall · source- Migrating to 10.0: the `openerp` namespace was renamed to `odoo`; only a deprecated `openerp.addons` alias remained. (`openerp.osv`) migration-openerp-import · source
- Raw `cr.execute()` INSERT/UPDATE/DELETE bypasses the ORM (no compute/constrains/tracking/mail): `UPDATE ir_attachment SET file_type = %s WHERE id = %s` - re-check the table/column names still match after upgrading. migration-raw-sql-write · source
Migration review checklist, not a compatibility verdict. "Migrating to X.0" applies once you upgrade to that version; "Since X.0" means this version already ignores or rejects that code. Methodology
Description
File types for attachments
Adds a content type to attachments. This is useful for instance in combination with http://bazaar.launchpad.net/~ocb/ocb-web/6.1/revision/2524, which makes Odoo offer downloads with the correct file type based on this field.
The document module makes this field available as well. This module does not interfere with its functionality when both are installed.
Installation
To install this module, you need to install python-magic in your environment first.
Configuration
This module comes with a daily scheduled task to provide content types for attachments without one in small batches (instead of trying to do this for all attachments at installation time). Depending on the number of attachments in your system you may deactivate this task after some time. You can follow the progress in the logs at the time that the cron job is fired.
Credits
Contributors
- Stefan Rijnhart stefan@therp.nl
- Holger Brunn hbrunn@therp.nl
Maintainer
.. image:: http://odoo-community.org/logo.png :alt: Odoo Community Association :target: http://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.
Dependencies
Code analysis
Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.
Views touched 0
No views found for this module.
HTTP endpoints 0
No HTTP endpoints found for this module.
Models touched 1
No new fields.
Public methods (4)-
create(self, cr, uid, vals, context=None)Determine the mime type when the attachment is created -
update_file_type(self, cr, uid, ids, force=False, context=None)Write the file types for these attachments. If the document module is installed, don't do anything unless in force mode. -
update_file_type_from_cron(self, cr, uid, count=10000, context=None) -
write(self, cr, uid, ids, vals, context=None)Update the mime type when the contents are overwritten