[IMP] crm: owl improvements

Applies minor fixups to improve owl usage in CRM, following the JS team advice:
https://github.com/odoo/odoo/pull/104975

* remove unused export
* use orm service from model
* remove redundancy for component call

Task-3056665

Part-of: odoo/odoo#109882
This commit is contained in:
abd-msyukyu-odoo
2023-01-20 20:58:21 +01:00
parent a556b54c89
commit b0d3da37ea
3 changed files with 4 additions and 16 deletions
@@ -1,9 +1,5 @@
/** @odoo-module **/
import { useService } from "@web/core/utils/hooks";
const { useComponent } = owl;
export async function checkRainbowmanMessage(orm, effect, recordId) {
const message = await orm.call("crm.lead", "get_rainbowman_message", [[recordId]]);
if (message) {
@@ -13,10 +9,3 @@ export async function checkRainbowmanMessage(orm, effect, recordId) {
});
}
}
export function useCheckRainbowman() {
const component = useComponent();
const orm = useService("orm");
const effect = useService("effect");
return checkRainbowmanMessage.bind(component, orm, effect);
}
@@ -4,9 +4,8 @@ import { KanbanModel } from "@web/views/kanban/kanban_model";
import { checkRainbowmanMessage } from "@crm/views/check_rainbowman_message";
export class CrmKanbanModel extends KanbanModel {
setup(params, { orm, effect }) {
setup(params, { effect }) {
super.setup(...arguments);
this.ormService = orm;
this.effect = effect;
}
}
@@ -45,7 +44,7 @@ export class CrmKanbanDynamicGroupList extends CrmKanbanModel.DynamicGroupList {
sourceGroup.groupByField.name === "stage_id"
) {
const record = targetGroup.list.records.find((r) => r.id === dataRecordId);
await checkRainbowmanMessage(this.model.ormService, this.model.effect, record.resId);
await checkRainbowmanMessage(this.model.orm, this.model.effect, record.resId);
}
}
}
@@ -71,4 +70,4 @@ export class CrmKanbanGroup extends CrmKanbanModel.Group {
CrmKanbanModel.DynamicGroupList = CrmKanbanDynamicGroupList;
CrmKanbanModel.Group = CrmKanbanGroup;
CrmKanbanModel.services = [...KanbanModel.services, "effect", "orm"];
CrmKanbanModel.services = [...KanbanModel.services, "effect"];
@@ -39,7 +39,7 @@ export class ForecastKanbanRenderer extends CrmKanbanRenderer {
granularity: granularity || "month",
})
.expand();
await this.props.list.model.root.load();
await this.props.list.load();
this.props.list.model.notify();
}