[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 <abz@odoo.com>
This commit is contained in:
Achraf (abz)
2022-02-24 07:17:44 +00:00
parent 0a9f67c82a
commit edcbd4a196
2 changed files with 17 additions and 9 deletions
@@ -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');
@@ -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: `
<form>
<field name="selection" widget="priority" readonly="1"/>
</form>`,
arch: '<form><field name="selection" widget="priority" readonly="1"/></form>',
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();
});