[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:
qsm-odoo
2017-04-11 19:44:38 +02:00
committed by Aaron Bohy
parent fc8cfc5762
commit c1256d1453
2 changed files with 24 additions and 2 deletions
@@ -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);