Revert "[IMP] project: remove displayed_image_id on project"
This reverts commit 00adbd36ff.
This commit is contained in:
@@ -436,6 +436,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.mimetype.startswith('image'))[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 Title', track_visibility='onchange', size=128, required=True, select=True),
|
||||
@@ -473,6 +479,7 @@ class task(osv.osv):
|
||||
'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,
|
||||
|
||||
@@ -319,6 +319,7 @@
|
||||
<field name="date_deadline"/>
|
||||
<field name="message_needaction_counter"/>
|
||||
<field name="tag_ids"/>
|
||||
<field name="displayed_image_id"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_global_click">
|
||||
@@ -359,6 +360,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div t-if="record.displayed_image_id.value">
|
||||
<field name="displayed_image_id" widget="attachment_image"/>
|
||||
</div>
|
||||
<div class="oe_clear"></div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -150,6 +150,10 @@ var KanbanSelection = AbstractField.extend({
|
||||
},
|
||||
});
|
||||
|
||||
var KanbanAttachmentImage = AbstractField.extend({
|
||||
template: 'KanbanAttachmentImage',
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Kanban widgets: ProgressBar
|
||||
@@ -228,6 +232,7 @@ var fields_registry = new Registry();
|
||||
fields_registry
|
||||
.add('priority', KanbanPriority)
|
||||
.add('kanban_state_selection', KanbanSelection)
|
||||
.add("attachment_image", KanbanAttachmentImage)
|
||||
.add('progress', KanbanProgressBar);
|
||||
|
||||
return {
|
||||
|
||||
@@ -268,6 +268,13 @@
|
||||
box-shadow: 0 1px 4px @gray-light;
|
||||
}
|
||||
|
||||
.o_kanban_attachment_image {
|
||||
// The image should take the whole card
|
||||
margin: -8px;
|
||||
> img {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.o_progressbar {
|
||||
.o-flex-display();
|
||||
|
||||
|
||||
@@ -75,4 +75,9 @@
|
||||
<t t-raw="content"/>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="KanbanAttachmentImage">
|
||||
<div class="o_kanban_attachment_image">
|
||||
<img t-att-src="'/web/image/' + widget.field.raw_value[0] + '?unique=1'"/>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user