[FIX] web: FieldDomain: open selection with field context

Closes #33658

closes odoo/odoo#34989

Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
This commit is contained in:
Aaron Bohy
2019-07-19 12:23:10 +00:00
parent 3295ffe632
commit c1eec46f7e
3 changed files with 32 additions and 1 deletions
@@ -3036,6 +3036,7 @@ var FieldDomain = AbstractField.extend({
new view_dialogs.SelectCreateDialog(this, {
title: _t("Selected records"),
res_model: this._domainModel,
context: this.record.getContext({fieldName: this.name, viewType: this.viewType}),
domain: this.value || "[]",
no_create: true,
readonly: true,
@@ -5743,6 +5743,36 @@ QUnit.module('basic_fields', {
form.destroy();
});
QUnit.test('field context is propagated when opening selection', async function (assert) {
assert.expect(1);
this.data.partner.records[0].foo = "[]";
var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
arch: `
<form>
<field name="foo" widget="domain" options="{'model': 'partner_type'}" context="{'tree_view_ref': 3}"/>
</form>
`,
archs: {
'partner_type,false,list': '<tree><field name="display_name"/></tree>',
'partner_type,3,list': '<tree><field name="id"/></tree>',
'partner_type,false,search': '<search><field name="name" string="Name"/></search>',
},
res_id: 1,
});
await testUtils.dom.click(form.$(".o_domain_show_selection_button"));
assert.strictEqual($('.modal .o_data_row').text(), '1214',
"should have picked the correct list view");
form.destroy();
});
QUnit.module('FieldProgressBar');
QUnit.test('Field ProgressBar: max_value should update', async function (assert) {
@@ -662,7 +662,7 @@ var MockServer = Class.extend({
var viewID = view_descr[0] || false;
var viewType = view_descr[1];
if (!viewID) {
var contextKey = viewType + '_view_ref';
var contextKey = (viewType === 'list' ? 'tree' : viewType) + '_view_ref';
if (contextKey in kwargs.context) {
viewID = kwargs.context[contextKey];
}