19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:12 +01:00
parent 79f83631d5
commit 73afc09215
6267 changed files with 1534193 additions and 1130106 deletions

View file

@ -0,0 +1,51 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { formView } from "@web/views/form/form_view";
import { FormController } from "@web/views/form/form_controller";
import { registry } from "@web/core/registry";
import { user } from "@web/core/user";
import { useService } from "@web/core/utils/hooks";
/**
* Controller used to directly activate the multi-team option
* via a button present in the crm team member alert.
*
* This alert is only displayed when a user is assigned to
* multiple teams but the multi-team option is deactivated.
*/
class CrmTeamFormController extends FormController {
setup() {
super.setup();
this.orm = useService("orm");
}
async beforeExecuteActionButton(clickParams) {
if (clickParams.name === "crm_team_activate_multi_membership") {
if (!user.hasGroup("sales_team.group_sale_manager")) {
return false;
}
const alert = document.querySelector(".alert");
try {
await this.orm.call("ir.config_parameter", "set_param", [
"sales_team.membership_multi",
true,
]);
alert?.classList.add('d-none');
} catch {
if (alert) {
alert.classList.replace("alert-info", "alert-danger");
alert.textContent = _t("An error occurred while activating the Multi-Team option.");
}
}
return false;
}
return super.beforeExecuteActionButton(...arguments);
}
}
registry.category("views").add("crm_team_form", {
...formView,
Controller: CrmTeamFormController,
});

View file

@ -1,35 +1,23 @@
.o_kanban_renderer.o_crm_team_kanban {
--KanbanRecord-width: 400px;
.o_crm_team_kanban .o_kanban_record {
.o_dropdown_kanban {
visibility: visible;
}
.o_field_widget.o_field_many2one_avatar_user .o_quick_assign {
visibility: visible;
}
}
.o_kanban_renderer.o_crm_team_member_kanban {
.o_crm_team_kanban .o_kanban_renderer {
--KanbanRecord-width: 350px;
}
.o_crm_team_member_kanban .o_kanban_renderer {
--KanbanRecord-width: 350px;
.o_kanban_group:not(.o_column_folded) {
min-height: 100px;
}
.o_kanban_record {
&:not(.o_kanban_ghost){
min-height: 100px;
}
}
.ribbon {
&::before, &::after {
display: none;
}
span {
padding: 5px;
font-size: small;
height: auto;
}
}
.ribbon-top-right {
margin-top: -$o-kanban-dashboard-vpadding;
span {
left: 0px;
right: 30px;
}
--Ribbon-wrapper-width: 6rem;
}
}

View file

@ -0,0 +1,80 @@
import { expect, test } from "@odoo/hoot";
import { contains as webContains, onRpc } from "@web/../tests/web_test_helpers";
import {
contains,
openFormView,
start,
startServer,
} from "@mail/../tests/mail_test_helpers";
import { defineCrmTeamModels } from "@sales_team/../tests/crm_team_test_helpers";
defineCrmTeamModels();
test("crm team form activate multi-team option via alert", async () => {
expect.assertions(7);
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({ name: "Maria" });
const userId = pyEnv["res.users"].create({ partner_id: partnerId });
const [teamId_1] = pyEnv["crm.team"].create([
{
name: "Team1",
member_ids: [userId],
},
{
name: "Team2",
member_ids: [userId],
},
]);
onRpc("has_group", ({ args }) => {
expect.step("has_group");
expect(args[1]).toBe("sales_team.group_sale_manager");
return true;
});
onRpc("set_param", ({ args }) => {
expect.step("set_param");
expect(args[0]).toBe("sales_team.membership_multi");
return true;
});
await start();
await openFormView("crm.team", teamId_1, {
arch: `<form js_class="crm_team_form">
<field name="is_membership_multi" invisible="1"/>
<field name="member_warning" invisible="1"/>
<div class="alert alert-info" invisible="is_membership_multi or not member_warning">
<field name="member_warning"/>
Working in multiple teams?
<button name="crm_team_activate_multi_membership" type="button">
Activate "Multi-team"
</button>
</div>
<sheet>
<field name="member_ids">
<kanban>
<templates>
<t t-name="card">
<field name="name"/>
</t>
</templates>
</kanban>
</field>
</sheet>
</form>`,
});
// Members list should have Maria which is already in Team2 => Alert should be shown
await expect(".o_field_widget[name='member_ids'] .o_kanban_record:visible:not(.o-kanban-button-new)").toHaveCount(1);
await expect(".o_field_widget[name='member_ids'] .o_kanban_record:visible:not(.o-kanban-button-new)").toHaveText("Maria");
await contains(".alert:visible", { count: 1 });
// Clicking on the button should update the multi-team option and remove the alert
await webContains(".alert button[name='crm_team_activate_multi_membership']").click();
await contains(".alert:visible", { count: 0 });
expect.verifySteps([
"has_group",
"set_param",
]);
});

View file

@ -0,0 +1,9 @@
import { defineModels } from "@web/../tests/web_test_helpers";
import { mailModels } from "@mail/../tests/mail_test_helpers";
import { CrmTeam } from "./mock_server/mock_models/crm_team";
export function defineCrmTeamModels() {
return defineModels({ CrmTeam, ...mailModels });
}

View file

@ -0,0 +1,21 @@
import { fields, models } from "@web/../tests/web_test_helpers";
export class CrmTeam extends models.ServerModel {
_name = "crm.team";
name = fields.Char();
member_ids = fields.Many2many({ string: "Salespersons", relation: "res.users" });
is_membership_multi = fields.Boolean({ default: false });
member_warning = fields.Text({ compute: "_compute_member_warning" });
_compute_member_warning() {
for (const team of this) {
const other_memberships = this.env["crm.team"].search_count([
["id", "!=", team.id],
["member_ids", "in", team.member_ids]
]);
team.member_warning = other_memberships ? "Users already in other teams." : false;
}
}
}