[FIX] web: fields with many2many_tags widget have "default" as view type
When we load a field data with many2many_tags widget, there is no views in the field info but instead we need to fetch the default fields, e.g. color, display name and id.
This commit is contained in:
@@ -81,8 +81,10 @@ var BasicView = AbstractView.extend({
|
||||
if (!('fieldsInfo' in record.data[name])) {
|
||||
fieldNames.push(name);
|
||||
} else {
|
||||
var fieldInfo = record.fieldsInfo[viewType][name];
|
||||
var fieldViews = fieldInfo.views || fieldInfo.fieldsInfo || {};
|
||||
var fieldViewTypes = Object.keys(fieldViews);
|
||||
var recordViewTypes = Object.keys(record.data[name].fieldsInfo);
|
||||
var fieldViewTypes = Object.keys(record.fieldsInfo[viewType][name].views);
|
||||
if (_.difference(fieldViewTypes, recordViewTypes).length) {
|
||||
fieldNames.push(name);
|
||||
}
|
||||
|
||||
@@ -3402,5 +3402,53 @@ QUnit.module('Views', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('open one2many form containing many2many_tags', function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
this.data.partner.records[0].product_ids = [37];
|
||||
this.data.product.fields.partner_type_ids = {
|
||||
string: "many2many partner_type", type: "many2many", relation: "partner_type",
|
||||
};
|
||||
this.data.product.records[0].partner_type_ids = [12, 14];
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
res_id: 1,
|
||||
data: this.data,
|
||||
arch: '<form string="Partners">' +
|
||||
'<sheet>' +
|
||||
'<group>' +
|
||||
'<field name="product_ids">' +
|
||||
'<tree create="0">' +
|
||||
'<field name="display_name"/>' +
|
||||
'<field name="partner_type_ids" widget="many2many_tags"/>' +
|
||||
'</tree>' +
|
||||
'<form string="Products">' +
|
||||
'<sheet>' +
|
||||
'<group>' +
|
||||
'<label for="partner_type_ids"/>' +
|
||||
'<div>' +
|
||||
'<field name="partner_type_ids" widget="many2many_tags"/>' +
|
||||
'</div>' +
|
||||
'</group>' +
|
||||
'</sheet>' +
|
||||
'</form>' +
|
||||
'</field>' +
|
||||
'</group>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
mockRPC: function (route, args) {
|
||||
assert.step(args.method);
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
});
|
||||
var row = form.$('.o_form_field_one2many .o_list_view .o_data_row');
|
||||
row.click();
|
||||
assert.verifySteps(['read', 'read', 'read'],
|
||||
"there should be 3 read rpcs");
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user