[FIX] web: record with field status with domain
If a m2o field status has an associated domain, it is used to match the records to display as status choices. This domain is extended so that it always matches the current status value. The code which was in charge of that was buggy when the status had no value (in that case the domain should not be extended).
This commit is contained in:
@@ -1414,8 +1414,10 @@ var BasicModel = AbstractModel.extend({
|
||||
var domain = record.getDomain({fieldName: fieldName});
|
||||
if (domain.length) {
|
||||
var localID = record.data[fieldName];
|
||||
var element = this.localData[localID];
|
||||
domain = ["|", ["id", "=", element.data.id]].concat(domain);
|
||||
if (localID) {
|
||||
var element = this.localData[localID];
|
||||
domain = ["|", ["id", "=", element.data.id]].concat(domain);
|
||||
}
|
||||
}
|
||||
|
||||
// avoid rpc if not necessary
|
||||
|
||||
@@ -2449,6 +2449,26 @@ QUnit.module('relational_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('statusbar with domain but no value (create mode)', function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
this.data.partner.fields.trululu.domain = "[('bar', '=', True)]";
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch:
|
||||
'<form string="Partners">' +
|
||||
'<header><field name="trululu" widget="statusbar"/></header>' +
|
||||
'</form>',
|
||||
});
|
||||
|
||||
assert.strictEqual(form.$('.o_statusbar_status button:disabled').length, 2, "should have 2 status");
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('statusbar fold_field option and statusbar_visible attribute', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user