[FIX] mail: activity view model domain
Steps to reproduce: - Go to activity view. - Schedule an activity for one record. (Say 8 records are available) - Schedule an activity for the second time. (Again 8 records are available) - Try to schedule an activity for the 3rd time. (Only 2 records are available) Issue: Since 7682286, the existing props of activity model are being passed as params while scheduling an activity. Currently, `["activity_ids", "!=", false]` is being pushed to the domain of activity model in order to display only those records on which activities have been set. As a result, after you schedule activities more than once, `["activity_ids", "!=", false]` domain gets applied and the list of records available for scheduling activity is restricted from the third time onwards. Fix: This commit passes the props from searchModel as params to the 'load' method while scheduling activity, instead of existing props, to ensure that the existing params are applied as well as all records are accessible for scheduling an activity, in `searchCreateDialog` (i.e.["activity_ids", "!=", false] condition is not added as domain). Task : 3721750 closes odoo/odoo#155700 X-original-commit: 339df084567206cff8a5487bbe9dec249671244a Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com> Signed-off-by: Khushi Patel (khpa) <khpa@odoo.com>
This commit is contained in:
@@ -54,6 +54,11 @@ export class ActivityController extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
getSearchProps() {
|
||||
const { comparision, context, domain, groupBy, orderBy } = this.env.searchModel;
|
||||
return { comparision, context, domain, groupBy, orderBy };
|
||||
}
|
||||
|
||||
scheduleActivity() {
|
||||
this.dialog.add(SelectCreateDialog, {
|
||||
resModel: this.props.resModel,
|
||||
@@ -64,7 +69,7 @@ export class ActivityController extends Component {
|
||||
context: this.props.context,
|
||||
onSelected: async (resIds) => {
|
||||
await this.activity.schedule(this.props.resModel, resIds);
|
||||
this.model.load(this.props);
|
||||
this.model.load(this.getSearchProps());
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -86,7 +91,7 @@ export class ActivityController extends Component {
|
||||
},
|
||||
},
|
||||
{
|
||||
onClose: () => this.model.load(this.props),
|
||||
onClose: () => this.model.load(this.getSearchProps()),
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -119,7 +124,7 @@ export class ActivityController extends Component {
|
||||
archInfo: this.props.archInfo,
|
||||
groupedActivities: this.model.activityData.grouped_activities,
|
||||
scheduleActivity: this.scheduleActivity.bind(this),
|
||||
onReloadData: () => this.model.load(this.props),
|
||||
onReloadData: () => this.model.load(this.getSearchProps()),
|
||||
onEmptyCell: this.openActivityFormView.bind(this),
|
||||
onSendMailTemplate: this.sendMailTemplate.bind(this),
|
||||
openRecord: this.openRecord.bind(this),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { startServer } from "@bus/../tests/helpers/mock_python_environment";
|
||||
|
||||
import { ActivityController } from "@mail/views/web/activity/activity_controller";
|
||||
import { ActivityModel } from "@mail/views/web/activity/activity_model";
|
||||
import { ActivityRenderer } from "@mail/views/web/activity/activity_renderer";
|
||||
import { start } from "@mail/../tests/helpers/test_utils";
|
||||
@@ -22,6 +23,22 @@ const { DateTime } = luxon;
|
||||
let serverData;
|
||||
let pyEnv;
|
||||
|
||||
async function openViewAndPatchDoAction(assert) {
|
||||
const { env, openView } = await start({
|
||||
serverData,
|
||||
});
|
||||
await openView({
|
||||
res_model: "mail.test.activity",
|
||||
views: [[false, "activity"]],
|
||||
});
|
||||
patchWithCleanup(env.services.action, {
|
||||
doAction(action, options) {
|
||||
assert.step("doAction");
|
||||
options.onClose();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
QUnit.module("test_mail", {}, function () {
|
||||
QUnit.module("activity view", {
|
||||
async beforeEach() {
|
||||
@@ -883,37 +900,99 @@ QUnit.module("test_mail", {}, function () {
|
||||
);
|
||||
|
||||
QUnit.test("activity view: Domain should not reset on load", async function (assert) {
|
||||
Object.assign(serverData.views, {
|
||||
"mail.test.activity,false,list":
|
||||
'<tree string="MailTestActivity"><field name="name"/></tree>',
|
||||
});
|
||||
const { env, openView } = await start({
|
||||
serverData,
|
||||
});
|
||||
await openView({
|
||||
res_model: "mail.test.activity",
|
||||
views: [[false, "activity"]],
|
||||
domain: [['id', '=', 1]],
|
||||
});
|
||||
patchWithCleanup(env.services.action, {
|
||||
doAction(action, options) {
|
||||
assert.step("doAction");
|
||||
options.onClose();
|
||||
},
|
||||
});
|
||||
|
||||
await click(document.querySelector(".o_activity_view .o_record_selector"));
|
||||
// search create dialog
|
||||
await click(document.querySelector(".modal-lg .o_data_row .o_data_cell"));
|
||||
assert.verifySteps(["doAction"]);
|
||||
|
||||
await click(document.querySelector(".o_activity_view .o_record_selector"));
|
||||
// again open search create dialog
|
||||
assert.strictEqual(
|
||||
document.querySelectorAll(".modal-lg .o_data_row").length,
|
||||
1,
|
||||
"Should contains only one record after calling schedule activity which load view again"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"activity view: 'scheduleActivity' does not add activity_ids condition as selectCreateDialog domain",
|
||||
async function (assert) {
|
||||
patchWithCleanup(ActivityController.prototype, {
|
||||
scheduleActivity() {
|
||||
super.scheduleActivity();
|
||||
assert.step(JSON.stringify(this.getSearchProps().domain));
|
||||
},
|
||||
});
|
||||
Object.assign(serverData.views, {
|
||||
"mail.test.activity,false,list":
|
||||
'<tree string="MailTestActivity"><field name="name"/></tree>',
|
||||
});
|
||||
const { env, openView } = await start({
|
||||
serverData,
|
||||
});
|
||||
await openView({
|
||||
res_model: "mail.test.activity",
|
||||
views: [[false, "activity"]],
|
||||
domain: [['id', '=', 1]],
|
||||
});
|
||||
patchWithCleanup(env.services.action, {
|
||||
doAction(action, options) {
|
||||
assert.step("doAction");
|
||||
options.onClose();
|
||||
await openViewAndPatchDoAction(assert);
|
||||
|
||||
// open search create dialog and schedule an activity
|
||||
await click(document.querySelector(".o_activity_view .o_record_selector"));
|
||||
await click(document.querySelectorAll(".modal-lg .o_data_row .o_data_cell")[0]);
|
||||
|
||||
// again open search create dialog
|
||||
await click(document.querySelector(".o_activity_view .o_record_selector"));
|
||||
assert.verifySteps(["[]", "doAction", "[]"]);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"activity view: 'onClose' of 'openActivityFormView' does not add activity_ids condition as selectCreateDialog domain",
|
||||
async function (assert) {
|
||||
patchWithCleanup(ActivityController.prototype, {
|
||||
openActivityFormView(resId, activityTypeId) {
|
||||
super.openActivityFormView(resId, activityTypeId);
|
||||
assert.step(JSON.stringify(this.getSearchProps().domain));
|
||||
},
|
||||
});
|
||||
await openViewAndPatchDoAction(assert);
|
||||
|
||||
await click(document.querySelector(".o_activity_view .o_record_selector"));
|
||||
// search create dialog
|
||||
await click(document.querySelector(".modal-lg .o_data_row .o_data_cell"));
|
||||
assert.verifySteps(["doAction"]);
|
||||
|
||||
await click(document.querySelector(".o_activity_view .o_record_selector"));
|
||||
// again open search create dialog
|
||||
assert.strictEqual(
|
||||
document.querySelectorAll(".modal-lg .o_data_row").length,
|
||||
1,
|
||||
"Should contains only one record after calling schedule activity which load view again"
|
||||
//schedule an activity on an empty activity cell
|
||||
await click(
|
||||
document.querySelector(".o_activity_view .o_data_row .o_activity_empty_cell")
|
||||
);
|
||||
assert.verifySteps(["doAction", "[]"]);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"activity view: 'onReloadData' does not add activity_ids condition as selectCreateDialog domain",
|
||||
async function (assert) {
|
||||
patchWithCleanup(ActivityController.prototype, {
|
||||
get rendererProps() {
|
||||
const rendererProps = { ...super.rendererProps };
|
||||
assert.step(JSON.stringify(this.getSearchProps().domain));
|
||||
return rendererProps;
|
||||
},
|
||||
});
|
||||
await openViewAndPatchDoAction(assert);
|
||||
|
||||
//schedule another activity on an activity cell with a scheduled activity
|
||||
await click(document.querySelector(".today .o-mail-ActivityCell-deadline"));
|
||||
await click($(".o-mail-ActivityListPopover button:contains(Schedule an activity)")[0]);
|
||||
assert.verifySteps(["[]", "doAction", "[]", "[]"]);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user