Skip to content

Commit 4862daf

Browse files
committed
[ADD] swap parameter
1 parent 9f54353 commit 4862daf

3 files changed

Lines changed: 62 additions & 0 deletions

File tree

spp_base_common/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"assets": {
3434
"web.assets_backend": [
3535
"spp_base_common/static/src/scss/navbar.scss",
36+
"spp_base_common/static/src/js/list_controller.js",
3637
],
3738
"web._assets_primary_variables": [
3839
"spp_base_common/static/src/scss/colors.scss",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Archiving Notification Fix
2+
3+
### Issue
4+
The global Odoo archiving method had swapped notification parameters, showing messages like:
5+
"50,000 records have been archived out of 20,000 selected"
6+
7+
This is illogical as you cannot archive more records than were selected.
8+
9+
### Solution
10+
This module overrides the `_toggleArchiveState` method in the legacy ListController to fix the swapped parameters in the notification message.
11+
12+
The fix swaps the parameters from `(total, resIds.length)` to `(resIds.length, total)` to correctly display:
13+
"Of the [number_selected] records selected, only the first [number_archived] have been archived/unarchived."
14+
15+
### Technical Details
16+
- **File**: `static/src/js/list_controller.js`
17+
- **Method**: `_toggleArchiveState`
18+
- **Original Location**: `addons/web/static/src/legacy/js/views/list/list_controller.js` (line 658-659)
19+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/** @odoo-module **/
2+
3+
import { ListController } from "web.ListController";
4+
import { _t } from "web.core";
5+
import { session } from "@web/session";
6+
7+
/**
8+
* Fix for swapped notification message parameters when archiving/unarchiving records.
9+
*
10+
* Original bug: Shows "Of the 20,000 records selected, only the first 50,000 have been archived"
11+
* This is illogical - you can't archive more records than selected.
12+
*
13+
* Fixed to show: "Of the 50,000 records selected, only the first 20,000 have been archived"
14+
* This makes sense - you selected 50,000 but only 20,000 were processed due to active_ids_limit.
15+
*/
16+
ListController.include({
17+
/**
18+
* Toggle the archive state of the selected records.
19+
*
20+
* @override
21+
* @param {boolean} archive - whether to archive or unarchive
22+
* @returns {Promise}
23+
*/
24+
_toggleArchiveState: async function (archive) {
25+
const resIds = await this.getSelectedIdsWithDomain();
26+
const notif = this.isDomainSelected;
27+
await this._archive(resIds, archive);
28+
const total = this.model.get(this.handle, {raw: true}).count;
29+
30+
// Fixed: Swapped parameters from (total, resIds.length) to (resIds.length, total)
31+
// Original Odoo bug had them backwards in addons/web/static/src/legacy/js/views/list/list_controller.js:658-659
32+
if (notif && resIds.length === session.active_ids_limit && resIds.length < total) {
33+
const msg = _.str.sprintf(
34+
_t("Of the %d records selected, only the first %d have been archived/unarchived."),
35+
resIds.length, // Fixed: total records selected
36+
total // Fixed: number actually archived/unarchived
37+
);
38+
this.displayNotification({ title: _t('Warning'), message: msg });
39+
}
40+
},
41+
});
42+

0 commit comments

Comments
 (0)