Skip to content

Commit 8ad3267

Browse files
committed
[FIX] new approach
1 parent f27da64 commit 8ad3267

File tree

1 file changed

+16
-30
lines changed

1 file changed

+16
-30
lines changed
Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,30 @@
1-
odoo.define('spp_base_common.ListControllerPatch', ['web.ListController', 'web.session', 'web.core'], function (require) {
2-
'use strict';
1+
/** @odoo-module **/
32

43
/**
5-
* Patch for Odoo bug: swapped parameters in archive notification message.
4+
* Patch for Odoo: The archive notification is generated in the model layer.
65
*
7-
* Bug location: odoo/addons/web/static/src/legacy/js/views/list/list_controller.js:658-659
8-
* Reference: https://github.com/odoo/odoo/tree/17.0/odoo/addons/base
6+
* Reference: https://github.com/odoo/odoo/blob/17.0/addons/web/static/src/views/list/list_controller.js
97
*
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"
8+
* The modern ListController just calls model.root.archive(), so we need to look elsewhere for the notification.
9+
* This test will verify if we can patch the controller at all.
1210
*/
1311

14-
var ListController = require('web.ListController');
15-
var session = require('web.session');
16-
var core = require('web.core');
12+
import {ListController} from "@web/views/list/list_controller";
13+
import {patch} from "@web/core/utils/patch";
1714

18-
var _t = core._t;
19-
20-
// Patch the ListController using .include()
21-
ListController.include({
15+
patch(ListController.prototype, {
2216
/**
23-
* @override
17+
* @override - Test if patch works
2418
*/
25-
_toggleArchiveState: async function (archive) {
26-
const resIds = await this.getSelectedIdsWithDomain();
27-
const notif = this.isDomainSelected;
28-
await this._archive(resIds, archive);
29-
const total = this.model.get(this.handle, {raw: true}).count;
19+
async toggleArchiveState(archive) {
20+
console.log("🎯 OPENSPP PATCH IS BEING CALLED!");
21+
this.notification.add("🎯 OpenSPP Patch Working!", {type: "success"});
3022

31-
// TEST: Completely change the message to verify patch is working
32-
if (notif && resIds.length === session.active_ids_limit && resIds.length < total) {
33-
const msg = _.str.sprintf(
34-
_t("🎯 PATCH IS WORKING! Selected: %d, Processed: %d"),
35-
resIds.length, // Total selected
36-
total // Actually processed
37-
);
38-
this.displayNotification({ title: _t('OpenSPP Archive Fix'), message: msg });
23+
// Call the original method
24+
if (archive) {
25+
return this.model.root.archive(true);
3926
}
27+
return this.model.root.unarchive(true);
4028
},
4129
});
4230

43-
});
44-

0 commit comments

Comments
 (0)