Skip to content

Commit 28fbf43

Browse files
committed
[FIX] swap parameter
1 parent 0576e1b commit 28fbf43

5 files changed

Lines changed: 78 additions & 70 deletions

File tree

spp_base_common/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +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",
36+
"spp_base_common/static/src/legacy/js/views/list/list_controller_fix.js",
3737
],
3838
"web._assets_primary_variables": [
3939
"spp_base_common/static/src/scss/colors.scss",

spp_base_common/readme/ARCHIVING_FIX.md

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Bugfix: Archive Notification Message
2+
3+
### Issue
4+
Odoo core has a bug in the archive notification where the parameters are swapped, showing an illogical message like:
5+
> "Of the 20,000 records selected, only the first 50,000 have been archived/unarchived."
6+
7+
This is impossible since you cannot archive more records than were selected.
8+
9+
### Root Cause
10+
**Location**: `odoo/addons/web/static/src/legacy/js/views/list/list_controller.js:658-659`
11+
12+
**Bug**: The sprintf parameters are in the wrong order:
13+
```javascript
14+
const msg = _.str.sprintf(
15+
_t("Of the %d records selected, only the first %d have been archived/unarchived."),
16+
total, resIds.length // ← WRONG ORDER
17+
);
18+
```
19+
20+
### Fix
21+
This module patches the `ListController._toggleArchiveState` method to swap the parameters:
22+
```javascript
23+
const msg = _.str.sprintf(
24+
_t("Of the %d records selected, only the first %d have been archived/unarchived."),
25+
resIds.length, total // ← CORRECT ORDER
26+
);
27+
```
28+
29+
### Result
30+
After the fix, the notification correctly shows:
31+
> "Of the 50,000 records selected, only the first 20,000 have been archived/unarchived."
32+
33+
### References
34+
- Odoo Repository: https://github.com/odoo/odoo/tree/17.0/odoo/addons/base
35+
- Fixed in: `spp_base_common/static/src/legacy/js/views/list/list_controller_fix.js`
36+

spp_base_common/static/src/js/list_controller.js

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
odoo.define('spp_base_common.ListControllerFix', function (require) {
2+
'use strict';
3+
4+
/**
5+
* Patch for Odoo bug: swapped parameters in archive notification message.
6+
*
7+
* Bug location: odoo/addons/web/static/src/legacy/js/views/list/list_controller.js:658-659
8+
* Bug report: https://github.com/odoo/odoo/issues/xxxxx (if applicable)
9+
*
10+
* Original shows: "Of the 20,000 records selected, only the first 50,000 have been archived"
11+
* Fixed to show: "Of the 50,000 records selected, only the first 20,000 have been archived"
12+
*/
13+
14+
var ListController = require('web.ListController');
15+
var session = require('web.session');
16+
var core = require('web.core');
17+
18+
var _t = core._t;
19+
20+
ListController.include({
21+
/**
22+
* @override
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+
if (notif && resIds.length === session.active_ids_limit && resIds.length < total) {
30+
const msg = _.str.sprintf(
31+
_t("Of the %d records selected, only the first %d have been archived/unarchived."),
32+
resIds.length, // Fixed: swapped - total selected (larger)
33+
total // Fixed: swapped - actually processed (smaller)
34+
);
35+
this.displayNotification({ title: _t('Warning'), message: msg });
36+
}
37+
},
38+
});
39+
40+
});
41+

0 commit comments

Comments
 (0)