diff options
Diffstat (limited to 'addons/project/project.py')
| -rw-r--r-- | addons/project/project.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/addons/project/project.py b/addons/project/project.py index b75a0e2fa95..fdffb68ed86 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -556,6 +556,12 @@ class task(osv.osv): res[task.id] = False return res + def _compute_displayed_image(self, cr, uid, ids, prop, arg, context=None): + res = {} + for line in self.browse(cr, uid, ids, context=context): + res[line.id] = line.attachment_ids and line.attachment_ids.filtered(lambda x: x.file_type_icon == 'webimage')[0] or None + return res + _columns = { 'active': fields.function(_is_template, store=True, string='Not a Template Task', type='boolean', help="This field is computed automatically and have the same behavior than the boolean 'active' field: if the task is linked to a template or unactivated project, it will be hidden unless specifically asked."), 'name': fields.char('Task Summary', track_visibility='onchange', size=128, required=True, select=True), @@ -592,7 +598,9 @@ class task(osv.osv): 'id': fields.integer('ID', readonly=True), 'color': fields.integer('Color Index'), 'user_email': fields.related('user_id', 'email', type='char', string='User Email', readonly=True), - } + 'attachment_ids': fields.one2many('ir.attachment', 'res_id', domain=lambda self: [('res_model', '=', self._name)], auto_join=True, string='Attachments'), + 'displayed_image_id': fields.function(_compute_displayed_image, relation='ir.attachment', type="many2one", string='Attachment'), + } _defaults = { 'stage_id': _get_default_stage_id, 'project_id': lambda self, cr, uid, ctx=None: ctx.get('default_project_id') if ctx is not None else False, |
