From eddef06ad4e4ce5f281a71929ff05d55521d39d1 Mon Sep 17 00:00:00 2001 From: std-odoo Date: Wed, 26 Jan 2022 09:38:06 +0000 Subject: [PATCH 1/3] [IMP] web: use Yes/No instead of True/False for the custom filters Purpose ======= "True" and "False" are not very user-friendly, especially for non-technical people. Instead, we want to have "Yes" or "No" for the custom filters, when we search on a view, which have more sens for non-technical people. Task-2648390 Part-of: odoo/odoo#79911 --- addons/web/static/src/legacy/js/control_panel/search_utils.js | 4 ++-- .../web/static/src/search/filter_menu/custom_filter_item.js | 4 ++-- .../tests/legacy/control_panel/custom_filter_item_tests.js | 4 ++-- addons/web/static/tests/search/custom_filter_item_tests.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/web/static/src/legacy/js/control_panel/search_utils.js b/addons/web/static/src/legacy/js/control_panel/search_utils.js index ab82f82e429..d672f3b0c5f 100644 --- a/addons/web/static/src/legacy/js/control_panel/search_utils.js +++ b/addons/web/static/src/legacy/js/control_panel/search_utils.js @@ -16,8 +16,8 @@ odoo.define('web.searchUtils', function (require) { { symbol: "=", description: _lt("is not set"), value: false }, ], boolean: [ - { symbol: "=", description: _lt("is true"), value: true }, - { symbol: "!=", description: _lt("is false"), value: true }, + { symbol: "=", description: _lt("is Yes"), value: true }, + { symbol: "!=", description: _lt("is No"), value: true }, ], char: [ { symbol: "ilike", description: _lt("contains") }, diff --git a/addons/web/static/src/search/filter_menu/custom_filter_item.js b/addons/web/static/src/search/filter_menu/custom_filter_item.js index 1eec963f3d2..cd04ea4f615 100644 --- a/addons/web/static/src/search/filter_menu/custom_filter_item.js +++ b/addons/web/static/src/search/filter_menu/custom_filter_item.js @@ -33,8 +33,8 @@ const FIELD_TYPES = { // FilterMenu parameters const FIELD_OPERATORS = { boolean: [ - { symbol: "=", description: _lt("is true"), value: true }, - { symbol: "!=", description: _lt("is false"), value: true }, + { symbol: "=", description: _lt("is Yes"), value: true }, + { symbol: "!=", description: _lt("is No"), value: true }, ], char: [ { symbol: "ilike", description: _lt("contains") }, diff --git a/addons/web/static/tests/legacy/control_panel/custom_filter_item_tests.js b/addons/web/static/tests/legacy/control_panel/custom_filter_item_tests.js index 8133b05a66e..29129d9fbff 100644 --- a/addons/web/static/tests/legacy/control_panel/custom_filter_item_tests.js +++ b/addons/web/static/tests/legacy/control_panel/custom_filter_item_tests.js @@ -211,7 +211,7 @@ odoo.define('web.filter_menu_generator_tests', function (require) { const preFilters = args[0]; const preFilter = preFilters[0]; assert.strictEqual(preFilter.type, 'filter'); - assert.strictEqual(preFilter.description, 'Boolean Field is true'); + assert.strictEqual(preFilter.description, 'Boolean Field is Yes'); assert.strictEqual(preFilter.domain, '[["boolean_field","=",True]]'); } } @@ -557,7 +557,7 @@ odoo.define('web.filter_menu_generator_tests', function (require) { type: "filter", }, { - description: 'Boolean Field is false', + description: 'Boolean Field is No', domain: '[["boolean_field","!=",True]]', type: "filter", }, diff --git a/addons/web/static/tests/search/custom_filter_item_tests.js b/addons/web/static/tests/search/custom_filter_item_tests.js index 4fe539271f0..9177368a341 100644 --- a/addons/web/static/tests/search/custom_filter_item_tests.js +++ b/addons/web/static/tests/search/custom_filter_item_tests.js @@ -320,7 +320,7 @@ QUnit.module("Search", (hooks) => { await applyFilter(controlPanel); - assert.deepEqual(getFacetTexts(controlPanel), ["Boolean Field is true"]); + assert.deepEqual(getFacetTexts(controlPanel), ["Boolean Field is Yes"]); assert.deepEqual(getDomain(controlPanel), [["boolean_field", "=", true]]); assert.containsOnce(controlPanel, ".o_menu_item"); @@ -672,7 +672,7 @@ QUnit.module("Search", (hooks) => { assert.deepEqual(getFacetTexts(controlPanel), [ [ 'A date is equal to "01/09/1997"', - "Boolean Field is false", + "Boolean Field is No", 'Floaty McFloatface is equal to "7.2"', 'ID is "9"', ].join("or"), From 36857cdf87ae727036f41ac5eae79996324c26fa Mon Sep 17 00:00:00 2001 From: std-odoo Date: Wed, 26 Jan 2022 09:38:17 +0000 Subject: [PATCH 2/3] [IMP] mail: use Yes/No instead of True/False in the tracking messages Purpose ======= When the value of a tracked boolean field change, we can see in the chatter "True -> False". It doesn't have that much sens for non-technical people, and instead we want to use "Yes -> No". Task-2648390 Part-of: odoo/odoo#79911 --- .../static/src/components/message/message.js | 4 +- .../static/src/components/message/message.xml | 2 + .../components/message/tests/message_tests.js | 52 +++++++++---------- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/addons/mail/static/src/components/message/message.js b/addons/mail/static/src/components/message/message.js index 917f0e212c9..55db73b73b1 100644 --- a/addons/mail/static/src/components/message/message.js +++ b/addons/mail/static/src/components/message/message.js @@ -282,8 +282,8 @@ export class Message extends Component { */ switch (value.field_type) { case 'boolean': - value.old_value = format.boolean(value.old_value, undefined, { forceString: true }); - value.new_value = format.boolean(value.new_value, undefined, { forceString: true }); + value.old_value = value.old_value ? _lt('Yes') : _lt('No'); + value.new_value = value.new_value ? _lt('Yes') : _lt('No'); break; /** * many2one formatter exists but is expecting id/name_get or data diff --git a/addons/mail/static/src/components/message/message.xml b/addons/mail/static/src/components/message/message.xml index 839af71082e..9676e705d3f 100644 --- a/addons/mail/static/src/components/message/message.xml +++ b/addons/mail/static/src/components/message/message.xml @@ -151,10 +151,12 @@
+ None