|
| 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