[FIX] web: breadcrumbs with readonly Many2One links
Step to reproduce: - Open 'Sales' - Open a SO - Click on the product link in the OrderLine tree Current Behaviour: - Breadcrumbs are cleared Since https://github.com/odoo/odoo/commit/cefd6ade293e6cfa8ec405f55c6d4d7194f36e7e the onClick is only triggered in form view Behaviour after PR: - Breadcrumbs are not cleared Link are now trigger via another click action '_onLinkClick' and quickEdit does not trigger on URL click Test provided by Anh Thao (pta) opw-2748041 closes odoo/odoo#85203 X-original-commit: 8ba45fde9f248e5a2b76ff3e934d9784d5d57ff0 Signed-off-by: Damhaut Florian (flda) <flda@odoo.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -88,10 +88,14 @@ var FieldMany2One = AbstractField.extend({
|
||||
}),
|
||||
events: _.extend({}, AbstractField.prototype.events, {
|
||||
'click input': '_onInputClick',
|
||||
'click': '_onLinkClick',
|
||||
'focusout input': '_onInputFocusout',
|
||||
'keyup input': '_onInputKeyup',
|
||||
'click .o_external_button': '_onExternalButtonClick',
|
||||
}),
|
||||
quickEditExclusion: [
|
||||
'.o_form_uri',
|
||||
],
|
||||
AUTOCOMPLETE_DELAY: 200,
|
||||
SEARCH_MORE_LIMIT: 320,
|
||||
isQuickEditable: true,
|
||||
@@ -749,13 +753,11 @@ var FieldMany2One = AbstractField.extend({
|
||||
* @override
|
||||
* @param {MouseEvent} event
|
||||
*/
|
||||
_onClick: function (event) {
|
||||
_onLinkClick: function (event) {
|
||||
var self = this;
|
||||
if (this.mode === 'readonly') {
|
||||
event.preventDefault();
|
||||
if (this.noOpen) {
|
||||
this._super(...arguments);
|
||||
} else {
|
||||
if (!this.noOpen) {
|
||||
event.stopPropagation();
|
||||
this._rpc({
|
||||
model: this.field.relation,
|
||||
|
||||
@@ -10,8 +10,10 @@ var testUtils = require('web.test_utils');
|
||||
var Widget = require('web.Widget');
|
||||
|
||||
const { triggerScroll } = require("@web/../tests/helpers/utils");
|
||||
const { legacyExtraNextTick } = require("@web/../tests/helpers/utils");
|
||||
const { createWebClient, doAction } = require('@web/../tests/webclient/helpers');
|
||||
const { browser } = require('@web/core/browser/browser');
|
||||
const { patchWithCleanup } = require('@web/../tests/helpers/utils');
|
||||
const { patchWithCleanup, getFixture } = require('@web/../tests/helpers/utils');
|
||||
const cpHelpers = require('@web/../tests/search/helpers');
|
||||
var createView = testUtils.createView;
|
||||
|
||||
@@ -3721,6 +3723,71 @@ QUnit.module('fields', {}, function () {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('many2one links form view call', async function (assert) {
|
||||
assert.expect(5);
|
||||
|
||||
let serverData = {};
|
||||
serverData.models = this.data;
|
||||
serverData.models['turtle'].records[1].product_id = 37;
|
||||
serverData.views= {
|
||||
"partner,false,form": '<form string="Partners"> <field name="turtles"/> </form>',
|
||||
"partner,false,search": '<search></search>',
|
||||
'turtle,false,list':`
|
||||
<tree readonly="1">
|
||||
<field name="product_id" widget="many2one"/>
|
||||
</tree>`,
|
||||
"product,false,search": '<search></search>',
|
||||
"product,false,form": '<form></form>',
|
||||
}
|
||||
serverData.actions= {
|
||||
1: {
|
||||
name: 'Partner',
|
||||
res_model: 'partner',
|
||||
res_id: 1,
|
||||
type: 'ir.actions.act_window',
|
||||
views: [[false, 'form']],
|
||||
}
|
||||
}
|
||||
|
||||
const webClient = await createWebClient({
|
||||
serverData,
|
||||
legacyParams: { withLegacyMockServer: true },
|
||||
mockRPC: function (route, args){
|
||||
if (args.method === 'get_formview_action'){
|
||||
assert.step('get_formview_action')
|
||||
return {
|
||||
type: "ir.actions.act_window",
|
||||
res_model: "product",
|
||||
view_type: "form",
|
||||
view_mode: "form",
|
||||
views: [[false, "form"]],
|
||||
target: "current",
|
||||
res_id: args[0],
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const target = getFixture();
|
||||
|
||||
await doAction(webClient, 1);
|
||||
|
||||
assert.containsOnce(target, 'a.o_form_uri',
|
||||
"should display 1 m2o link in form");
|
||||
|
||||
assert.containsN(target, '.breadcrumb-item', 1,
|
||||
"Should only contain one breadcrumb at the start");
|
||||
|
||||
await testUtils.dom.click($(target).find('a.o_form_uri'));
|
||||
|
||||
await legacyExtraNextTick();
|
||||
|
||||
assert.verifySteps(['get_formview_action'])
|
||||
|
||||
assert.containsN(target, '.breadcrumb-item', 2,
|
||||
"Should contain 2 breadcrumbs after the clicking on the link");
|
||||
});
|
||||
|
||||
QUnit.module('Many2OneAvatar');
|
||||
|
||||
QUnit.test('many2one_avatar widget in form view', async function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user