|
1 | | -odoo.define('spp_base_common.ListControllerPatch', ['web.ListController', 'web.session', 'web.core'], function (require) { |
2 | | -'use strict'; |
| 1 | +/** @odoo-module **/ |
3 | 2 |
|
4 | 3 | /** |
5 | | - * Patch for Odoo bug: swapped parameters in archive notification message. |
| 4 | + * Patch for Odoo: The archive notification is generated in the model layer. |
6 | 5 | * |
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 |
9 | 7 | * |
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. |
12 | 10 | */ |
13 | 11 |
|
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"; |
17 | 14 |
|
18 | | -var _t = core._t; |
19 | | - |
20 | | -// Patch the ListController using .include() |
21 | | -ListController.include({ |
| 15 | +patch(ListController.prototype, { |
22 | 16 | /** |
23 | | - * @override |
| 17 | + * @override - Test if patch works |
24 | 18 | */ |
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"}); |
30 | 22 |
|
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); |
39 | 26 | } |
| 27 | + return this.model.root.unarchive(true); |
40 | 28 | }, |
41 | 29 | }); |
42 | 30 |
|
43 | | -}); |
44 | | - |
0 commit comments