[IMP] crm,mail,project: support many2one_avatar_user on activity view
Currently, activity view does not support many2one_avatar_user widget due to which clicking on image do not open chat window, with this commit, we add support of many2one_avatar_user widget in activity_view so that user can click on avatar image and open chat window. task-2554466 closes odoo/odoo#71804 Related: odoo/enterprise#18803 Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
This commit is contained in:
committed by
Simon Genin (ges)
parent
d81875491c
commit
88857a397e
@@ -498,7 +498,7 @@
|
||||
<field name="company_currency"/>
|
||||
<templates>
|
||||
<div t-name="activity-box">
|
||||
<img t-att-src="activity_image('res.users', 'avatar_128', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value"/>
|
||||
<field name="user_id" widget="many2one_avatar_user"/>
|
||||
<div>
|
||||
<field name="name" display="full"/>
|
||||
<field name="expected_revenue" widget="monetary" display="full" muted="1"/>
|
||||
|
||||
@@ -97,4 +97,5 @@ export const Many2ManyAvatarUser = FieldMany2ManyTagsAvatar.extend(M2XAvatarMixi
|
||||
|
||||
fieldRegistry.add('many2one_avatar_user', Many2OneAvatarUser);
|
||||
fieldRegistry.add('kanban.many2one_avatar_user', KanbanMany2OneAvatarUser);
|
||||
fieldRegistry.add('activity.many2one_avatar_user', KanbanMany2OneAvatarUser);
|
||||
fieldRegistry.add('many2many_avatar_user', Many2ManyAvatarUser);
|
||||
|
||||
@@ -69,8 +69,9 @@
|
||||
padding: 8px 8px;
|
||||
cursor: pointer;
|
||||
|
||||
> img {
|
||||
.o_m2o_avatar > img, > img {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
max-height: 32px;
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
@@ -528,4 +528,57 @@ QUnit.test("Activity view: discard an activity creation dialog", async function
|
||||
assert.containsNone($, ".modal.o_technical_modal", "Activity Modal should be closed");
|
||||
});
|
||||
|
||||
QUnit.test('Activity view: many2one_avatar_user widget in activity view', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
const taskModel = serverData.models.task;
|
||||
|
||||
serverData.models['res.users'] = {
|
||||
fields: {
|
||||
display_name: { string: "Displayed name", type: "char" },
|
||||
avatar_128: { string: "Image 128", type: 'image' },
|
||||
},
|
||||
records: [{
|
||||
id: 1,
|
||||
display_name: "first user",
|
||||
avatar_128: "Atmaram Bhide",
|
||||
}],
|
||||
};
|
||||
taskModel.fields.user_id = { string: "Related User", type: "many2one", relation: 'res.users' };
|
||||
taskModel.records[0].user_id = 1;
|
||||
|
||||
serverData.actions = {
|
||||
1: {
|
||||
id: 1,
|
||||
name: 'Task Action',
|
||||
res_model: 'task',
|
||||
type: 'ir.actions.act_window',
|
||||
views: [[false, 'activity']],
|
||||
}
|
||||
};
|
||||
|
||||
serverData.views = {
|
||||
'task,false,activity': `
|
||||
<activity string="Task">
|
||||
<templates>
|
||||
<div t-name="activity-box">
|
||||
<field name="user_id" widget="many2one_avatar_user"/>
|
||||
<field name="foo"/>
|
||||
</div>
|
||||
</templates>
|
||||
</activity>`,
|
||||
'task,false,search': '<search></search>'
|
||||
};
|
||||
|
||||
const webClient = await createWebClient({ serverData, legacyParams: { withLegacyMockServer: true } });
|
||||
await doAction(webClient, 1);
|
||||
|
||||
await legacyExtraNextTick();
|
||||
assert.containsN(webClient, '.o_m2o_avatar', 2);
|
||||
assert.containsOnce(webClient, 'tr[data-res-id=13] .o_m2o_avatar > img[src="/web/image/res.users/1/avatar_128"]',
|
||||
"should have m2o avatar image");
|
||||
assert.containsNone(webClient, '.o_m2o_avatar > span',
|
||||
"should not have text on many2one_avatar_user if onlyImage node option is passed");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1082,7 +1082,7 @@
|
||||
<field name="user_id"/>
|
||||
<templates>
|
||||
<div t-name="activity-box">
|
||||
<img t-att-src="activity_image('res.users', 'avatar_128', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value"/>
|
||||
<field name="user_id" widget="many2one_avatar_user"/>
|
||||
<div>
|
||||
<field name="name" display="full"/>
|
||||
<field name="project_id" muted="1" display="full" invisible="context.get('default_project_id', False)"/>
|
||||
|
||||
Reference in New Issue
Block a user