Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spp_base_common/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"assets": {
"web.assets_backend": [
"spp_base_common/static/src/scss/navbar.scss",
"spp_base_common/static/src/legacy/js/views/list/list_controller_fix.js",
],
"web._assets_primary_variables": [
"spp_base_common/static/src/scss/colors.scss",
Expand Down
36 changes: 36 additions & 0 deletions spp_base_common/readme/BUGFIX_archive_notification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Bugfix: Archive Notification Message

### Issue
Odoo core has a bug in the archive notification where the parameters are swapped, showing an illogical message like:
> "Of the 20,000 records selected, only the first 50,000 have been archived/unarchived."

This is impossible since you cannot archive more records than were selected.

### Root Cause
**Location**: `odoo/addons/web/static/src/legacy/js/views/list/list_controller.js:658-659`

**Bug**: The sprintf parameters are in the wrong order:
```javascript
const msg = _.str.sprintf(
_t("Of the %d records selected, only the first %d have been archived/unarchived."),
total, resIds.length // ← WRONG ORDER
);
```

### Fix
This module patches the `ListController._toggleArchiveState` method to swap the parameters:
```javascript
const msg = _.str.sprintf(
_t("Of the %d records selected, only the first %d have been archived/unarchived."),
resIds.length, total // ← CORRECT ORDER
);
```

### Result
After the fix, the notification correctly shows:
> "Of the 50,000 records selected, only the first 20,000 have been archived/unarchived."

### References
- Odoo Repository: https://github.com/odoo/odoo/tree/17.0/odoo/addons/base
- Fixed in: `spp_base_common/static/src/legacy/js/views/list/list_controller_fix.js`

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** @odoo-module **/

import {DynamicList} from "@web/model/relational_model/dynamic_list";
import {patch} from "@web/core/utils/patch";
import {_t} from "@web/core/l10n/translation";

/**
* Patch for Odoo 17 bug: swapped parameters in archive notification message.
*
* Bug location: addons/web/static/src/model/relational_model/dynamic_list.js
* GitHub: https://github.com/odoo/odoo/blob/17.0/addons/web/static/src/model/relational_model/dynamic_list.js
*
* Original bug shows: "Of the 20,000 records selected, only the first 50,000 have been archived"
* Fixed to show: "Of the 50,000 records selected, only the first 20,000 have been archived"
*/

patch(DynamicList.prototype, {
async _toggleArchive(isSelected, state) {
const method = state ? "action_archive" : "action_unarchive";
const context = this.context;
const resIds = await this.getResIds(isSelected);
const action = await this.model.orm.call(this.resModel, method, [resIds], {context});

// FIXED: Swapped parameters from (resIds.length, this.count) to (this.count, resIds.length)
if (
this.isDomainSelected &&
resIds.length === this.model.activeIdsLimit &&
resIds.length < this.count
) {
const msg = _t(
"Of the %s records selected, only the first %s have been archived/unarchived.",
this.count, // FIXED: Total records selected (larger number)
resIds.length // FIXED: Actually processed (smaller number, limited)
);
this.model.notification.add(msg, {title: _t("Warning")});
}

const reload = () => this.model.load();
if (action && Object.keys(action).length) {
this.model.action.doAction(action, {
onClose: reload,
});
} else {
return reload();
}
},
});
Loading