[IMP] Set cover image from project document(ir.attachment) for project
This commit is contained in:
parent
3e52008bb1
commit
13e820a64d
@ -218,6 +218,9 @@ class Project(models.Model):
|
|||||||
low = fields.Integer("No of Days for Low priority")
|
low = fields.Integer("No of Days for Low priority")
|
||||||
medium = fields.Integer("No of Days for Medium priority")
|
medium = fields.Integer("No of Days for Medium priority")
|
||||||
high = fields.Integer("No of Days for High priority")
|
high = fields.Integer("No of Days for High priority")
|
||||||
|
displayed_image_id = fields.Many2one('ir.attachment',
|
||||||
|
domain="[('res_model', '=', 'project.project'), ('res_id', '=', id), ('mimetype', 'ilike', 'image')]",
|
||||||
|
string='Cover Image')
|
||||||
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
('project_date_greater', 'check(date >= date_start)', 'Error! project start-date must be lower than project end-date.')
|
('project_date_greater', 'check(date >= date_start)', 'Error! project start-date must be lower than project end-date.')
|
||||||
|
@ -35,10 +35,11 @@ KanbanRecord.include({
|
|||||||
*/
|
*/
|
||||||
_onKanbanActionClicked: function (ev) {
|
_onKanbanActionClicked: function (ev) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var domain = null;
|
||||||
if (this.modelName === 'project.task' && $(ev.currentTarget).data('type') === 'set_cover') {
|
if (this.modelName === 'project.task' && $(ev.currentTarget).data('type') === 'set_cover') {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
var domain = [['res_model', '=', 'project.task'], ['res_id', '=', this.id], ['mimetype', 'ilike', 'image']];
|
domain = [['res_model', '=', 'project.task'], ['res_id', '=', this.id], ['mimetype', 'ilike', 'image']];
|
||||||
this._rpc({
|
this._rpc({
|
||||||
model: 'ir.attachment',
|
model: 'ir.attachment',
|
||||||
method: 'search_read',
|
method: 'search_read',
|
||||||
@ -46,7 +47,19 @@ KanbanRecord.include({
|
|||||||
fields: ['id', 'name'],
|
fields: ['id', 'name'],
|
||||||
})
|
})
|
||||||
.then(open_cover_images_dialog);
|
.then(open_cover_images_dialog);
|
||||||
} else {
|
} else if (this.modelName === 'project.project' && $(ev.currentTarget).data('type') === 'set_cover') {
|
||||||
|
ev.preventDefault();
|
||||||
|
|
||||||
|
domain = [['res_model', '=', 'project.project'], ['res_id', '=', this.id], ['mimetype', 'ilike', 'image']];
|
||||||
|
this._rpc({
|
||||||
|
model: 'ir.attachment',
|
||||||
|
method: 'search_read',
|
||||||
|
domain: domain,
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
})
|
||||||
|
.then(open_cover_images_dialog);
|
||||||
|
}
|
||||||
|
else {
|
||||||
this._super.apply(this, arguments, ev);
|
this._super.apply(this, arguments, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +316,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="o_kanban_card_manage_pane" groups="project.group_project_manager">
|
<div class="o_kanban_card_manage_pane" groups="project.group_project_manager">
|
||||||
<div class="o_kanban_card_manage_section o_kanban_manage_reports">
|
<div class="o_kanban_card_manage_section o_kanban_manage_reports">
|
||||||
|
<div>
|
||||||
|
<a type="set_cover">Set Cover Image</a>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a type="edit">Settings</a>
|
<a type="edit">Settings</a>
|
||||||
</div>
|
</div>
|
||||||
@ -331,6 +334,10 @@
|
|||||||
<span class="o_right"><field name="is_favorite" widget="boolean_favorite" nolabel="1" /></span>
|
<span class="o_right"><field name="is_favorite" widget="boolean_favorite" nolabel="1" /></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div t-if="record.displayed_image_id.value">
|
||||||
|
<field name="displayed_image_id" widget="attachment_image"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="o_project_kanban_boxes">
|
<div class="o_project_kanban_boxes">
|
||||||
<a class="o_project_kanban_box" name="%(act_project_project_2_project_task_all)d" type="action">
|
<a class="o_project_kanban_box" name="%(act_project_project_2_project_task_all)d" type="action">
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
Reference in New Issue
Block a user