[FIX] web: correctly display nocontent helper if create='0'
When the root node of the arch has attribute 'create' set to '0', the generated DOM element must have classname 'o_cannot_create'. This is used to correctly display the nocontent helper (when there is no record). Before this rev., the helper indicated that the user can click on 'Create' to create a new record, even if the create action was disabled. This was for example the case in Point of Sale > Orders.
This commit is contained in:
@@ -46,6 +46,9 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
|
||||
* @returns {Deferred}
|
||||
*/
|
||||
start: function () {
|
||||
// add classname to reflect the (absence of) access rights (used to
|
||||
// correctly display the nocontent helper)
|
||||
this.$el.toggleClass('o_cannot_create', !this.activeActions.create);
|
||||
return this._super.apply(this, arguments)
|
||||
.then(this._updateEnv.bind(this));
|
||||
},
|
||||
|
||||
@@ -84,7 +84,7 @@ QUnit.module('Views', {
|
||||
QUnit.module('ListView');
|
||||
|
||||
QUnit.test('simple readonly list', function (assert) {
|
||||
assert.expect(9);
|
||||
assert.expect(10);
|
||||
|
||||
var list = createView({
|
||||
View: ListView,
|
||||
@@ -93,6 +93,9 @@ QUnit.module('Views', {
|
||||
arch: '<tree><field name="foo"/><field name="int_field"/></tree>',
|
||||
});
|
||||
|
||||
assert.notOk(list.$el.hasClass('o_cannot_create'),
|
||||
"should not have className 'o_cannot_create'");
|
||||
|
||||
// 3 th (1 for checkbox, 2 for columns)
|
||||
assert.strictEqual(list.$('th').length, 3, "should have 3 columns");
|
||||
|
||||
@@ -114,6 +117,24 @@ QUnit.module('Views', {
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('list with create="0"', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var list = createView({
|
||||
View: ListView,
|
||||
model: 'foo',
|
||||
data: this.data,
|
||||
arch: '<tree create="0"><field name="foo"/></tree>',
|
||||
});
|
||||
|
||||
assert.ok(list.$el.hasClass('o_cannot_create'),
|
||||
"should have className 'o_cannot_create'");
|
||||
assert.strictEqual(list.$buttons.find('.o_list_button_add').length, 0,
|
||||
"should not have the 'Create' button");
|
||||
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('simple editable rendering', function (assert) {
|
||||
assert.expect(9);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user