From edcbd4a19696a96b119a16fd1728eda5f962a9e4 Mon Sep 17 00:00:00 2001 From: "Achraf (abz)" Date: Mon, 21 Feb 2022 15:30:58 +0000 Subject: [PATCH] [FIX] web: Star a product via sales form For the moment we cannot star a product from the form of sales view Steps: -Sales/Quotation - Create new quotation - Add a new product in the order lines - Open product form from External link - Try to star product Because of the quickedit the onClick is called when it shouldn't, the solution would be to rename the onClick function so that it doesn't interfere with the quickEdit. opw-2759063 closes odoo/odoo#85242 X-original-commit: edafd9fe49b1e4c73ee1768efc3df26b463b2f14 Signed-off-by: Achraf --- .../src/legacy/js/fields/basic_fields.js | 4 ++-- .../tests/legacy/fields/basic_fields_tests.js | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/addons/web/static/src/legacy/js/fields/basic_fields.js b/addons/web/static/src/legacy/js/fields/basic_fields.js index e91ad751959..ab7e399f0fe 100644 --- a/addons/web/static/src/legacy/js/fields/basic_fields.js +++ b/addons/web/static/src/legacy/js/fields/basic_fields.js @@ -2472,7 +2472,7 @@ var PriorityWidget = AbstractField.extend({ events: { 'mouseover > a': '_onMouseOver', 'mouseout > a': '_onMouseOut', - 'click > a': '_onClick', + 'click > a': '_onPriorityClick', 'keydown > a': '_onKeydown', }, supportedFieldTypes: ['selection'], @@ -2595,7 +2595,7 @@ var PriorityWidget = AbstractField.extend({ * @param {MouseEvent} event * @private */ - _onClick: function (event) { + _onPriorityClick: function (event) { event.preventDefault(); event.stopPropagation(); var index = $(event.currentTarget).data('index'); diff --git a/addons/web/static/tests/legacy/fields/basic_fields_tests.js b/addons/web/static/tests/legacy/fields/basic_fields_tests.js index 35157a20735..245d74a1c17 100644 --- a/addons/web/static/tests/legacy/fields/basic_fields_tests.js +++ b/addons/web/static/tests/legacy/fields/basic_fields_tests.js @@ -6652,21 +6652,29 @@ QUnit.module('basic_fields', { }); QUnit.test('priority widget with readonly attribute', async function (assert) { - assert.expect(1); + assert.expect(2); const form = await createView({ View: FormView, model: 'partner', data: this.data, - arch: ` -
- - `, + arch: '
', res_id: 2, + mockRPC(route, args) { + if (args.method === "write") { + throw new Error("should not save"); + } + return this._super.apply(this, arguments); + }, }); - assert.containsN(form, '.o_field_widget.o_priority span', 2, - "stars of priority widget should rendered with span tag if readonly"); + assert.strictEqual(form.$('span.o_priority_star.fa.fa-star-o').length, 2, + "stars of priority widget should rendered with span tag if readonly"); + + await testUtils.dom.click(form.$('.o_priority_star.fa-star-o').last()); + + assert.strictEqual(form.$('.o_priority_star.fa.fa-star-o').length, 2, + "should still have two stars"); form.destroy(); });