Rename all imports with alias old system to the new js module system Task ID: 3266759 closes odoo/odoo#127414 Related: odoo/design-themes#671 Related: odoo/enterprise#43716 Signed-off-by: Bastien Pierre (ipb) <ipb@odoo.com>
80 lines
2.6 KiB
JavaScript
80 lines
2.6 KiB
JavaScript
/** @odoo-module **/
|
|
|
|
import fieldRegistry from "@web/legacy/js/fields/field_registry";
|
|
|
|
import {
|
|
Many2OneAvatarUser,
|
|
KanbanMany2OneAvatarUser,
|
|
KanbanMany2ManyAvatarUser,
|
|
ListMany2ManyAvatarUser,
|
|
Many2ManyAvatarUser,
|
|
} from "@mail/views/web/fields/m2x_avatar_user";
|
|
|
|
// This module defines variants of the Many2OneAvatarUser and Many2ManyAvatarUser
|
|
// field widgets, to support fields pointing to 'hr.employee'. It also defines the
|
|
// kanban version of the Many2OneAvatarEmployee widget.
|
|
//
|
|
// Usage:
|
|
// <field name="employee_id" widget="many2one_avatar_employee"/>
|
|
|
|
const M2XAvatarEmployeeMixin = {
|
|
supportedModels: ["hr.employee", "hr.employee.public"],
|
|
|
|
//----------------------------------------------------------------------
|
|
// Private
|
|
//----------------------------------------------------------------------
|
|
|
|
_getEmployeeID() {
|
|
return this.value.res_id;
|
|
},
|
|
|
|
//----------------------------------------------------------------------
|
|
// Handlers
|
|
//----------------------------------------------------------------------
|
|
|
|
/**
|
|
* @override
|
|
*/
|
|
_onAvatarClicked(ev) {
|
|
ev.stopPropagation(); // in list view, prevent from opening the record
|
|
const employeeId = this._getEmployeeID(ev);
|
|
this._openChat({ employeeId: employeeId });
|
|
},
|
|
};
|
|
|
|
export const Many2OneAvatarEmployee = Many2OneAvatarUser.extend(M2XAvatarEmployeeMixin);
|
|
export const KanbanMany2OneAvatarEmployee = KanbanMany2OneAvatarUser.extend(M2XAvatarEmployeeMixin);
|
|
|
|
fieldRegistry.add("many2one_avatar_employee", Many2OneAvatarEmployee);
|
|
fieldRegistry.add("kanban.many2one_avatar_employee", KanbanMany2OneAvatarEmployee);
|
|
|
|
const M2MAvatarEmployeeMixin = Object.assign(M2XAvatarEmployeeMixin, {
|
|
//----------------------------------------------------------------------
|
|
// Private
|
|
//----------------------------------------------------------------------
|
|
|
|
_getEmployeeID(ev) {
|
|
return parseInt(ev.target.getAttribute("data-id"), 10);
|
|
},
|
|
});
|
|
|
|
export const Many2ManyAvatarEmployee = Many2ManyAvatarUser.extend(M2MAvatarEmployeeMixin, {});
|
|
|
|
export const KanbanMany2ManyAvatarEmployee = KanbanMany2ManyAvatarUser.extend(
|
|
M2MAvatarEmployeeMixin,
|
|
{}
|
|
);
|
|
|
|
export const ListMany2ManyAvatarEmployee = ListMany2ManyAvatarUser.extend(
|
|
M2MAvatarEmployeeMixin,
|
|
{}
|
|
);
|
|
|
|
fieldRegistry.add("many2many_avatar_employee", Many2ManyAvatarEmployee);
|
|
fieldRegistry.add("kanban.many2many_avatar_employee", KanbanMany2ManyAvatarEmployee);
|
|
fieldRegistry.add("list.many2many_avatar_employee", ListMany2ManyAvatarEmployee);
|
|
|
|
export default {
|
|
Many2OneAvatarEmployee,
|
|
};
|