[FIX] board,web: edit custom views in place
Before this commit, whenever we do an operation on any of these custom views, such as folding it, the custom view was saved by creating a new one. This behaviour comes from a lost feature to undo operations on custom views. Since we do not have this feature anymore, it makes no sense to create new custom views on save, instead of applying the changes in place. With this commit, custom views are edited in place. Fixes #23712
This commit is contained in:
@@ -20,7 +20,7 @@ FormView.include({
|
||||
*/
|
||||
init: function (viewInfo) {
|
||||
this._super.apply(this, arguments);
|
||||
this.controllerParams.viewID = viewInfo.view_id;
|
||||
this.controllerParams.customViewID = viewInfo.custom_view_id;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ FormController.include({
|
||||
}),
|
||||
init: function (parent, model, renderer, params) {
|
||||
this._super.apply(this, arguments);
|
||||
this.viewID = params.viewID;
|
||||
this.customViewID = params.customViewID;
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -63,9 +63,9 @@ FormController.include({
|
||||
var board = this.renderer.getBoard();
|
||||
var arch = QWeb.render('DashBoard.xml', _.extend({}, board));
|
||||
return this._rpc({
|
||||
route: '/web/view/add_custom',
|
||||
route: '/web/view/edit_custom',
|
||||
params: {
|
||||
view_id: this.viewID,
|
||||
custom_id: this.customViewID,
|
||||
arch: arch,
|
||||
}
|
||||
}).then(dataManager.invalidate.bind(dataManager));
|
||||
|
||||
@@ -124,8 +124,8 @@ QUnit.test('basic functionality, with one sub action', function (assert) {
|
||||
if (route === '/web/dataset/search_read') {
|
||||
assert.deepEqual(args.domain, [['foo', '!=', 'False']], "the domain should be passed");
|
||||
}
|
||||
if (route === '/web/view/add_custom') {
|
||||
assert.step('add custom');
|
||||
if (route === '/web/view/edit_custom') {
|
||||
assert.step('edit custom');
|
||||
return $.when(true);
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
@@ -156,7 +156,7 @@ QUnit.test('basic functionality, with one sub action', function (assert) {
|
||||
form.$('.oe_fold').click();
|
||||
|
||||
assert.ok(form.$('.oe_content').is(':visible'), "content is visible again");
|
||||
assert.verifySteps(['load action', 'add custom', 'add custom']);
|
||||
assert.verifySteps(['load action', 'edit custom', 'edit custom']);
|
||||
|
||||
assert.strictEqual($('.modal').length, 0, "should have no modal open");
|
||||
|
||||
@@ -184,7 +184,7 @@ QUnit.test('basic functionality, with one sub action', function (assert) {
|
||||
assert.strictEqual($('.modal').length, 0, "should have no modal open");
|
||||
assert.strictEqual(form.$('.oe_action').length, 0, "should have no displayed action");
|
||||
|
||||
assert.verifySteps(['load action', 'add custom', 'add custom', 'add custom', 'add custom']);
|
||||
assert.verifySteps(['load action', 'edit custom', 'edit custom', 'edit custom', 'edit custom']);
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
@@ -293,8 +293,8 @@ QUnit.test('can drag and drop a view', function (assert) {
|
||||
views: [[4, 'list']],
|
||||
});
|
||||
}
|
||||
if (route === '/web/view/add_custom') {
|
||||
assert.step('add custom');
|
||||
if (route === '/web/view/edit_custom') {
|
||||
assert.step('edit custom');
|
||||
return $.when(true);
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
@@ -340,8 +340,8 @@ QUnit.test('twice the same action in a dashboard', function (assert) {
|
||||
views: [[4, 'list'],[5, 'kanban']],
|
||||
});
|
||||
}
|
||||
if (route === '/web/view/add_custom') {
|
||||
assert.step('add custom');
|
||||
if (route === '/web/view/edit_custom') {
|
||||
assert.step('edit custom');
|
||||
return $.when(true);
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
|
||||
@@ -961,14 +961,17 @@ class DataSet(http.Controller):
|
||||
|
||||
class View(http.Controller):
|
||||
|
||||
@http.route('/web/view/add_custom', type='json', auth="user")
|
||||
def add_custom(self, view_id, arch):
|
||||
CustomView = request.env['ir.ui.view.custom']
|
||||
CustomView.create({
|
||||
'user_id': request.session.uid,
|
||||
'ref_id': view_id,
|
||||
'arch': arch
|
||||
})
|
||||
@http.route('/web/view/edit_custom', type='json', auth="user")
|
||||
def edit_custom(self, custom_id, arch):
|
||||
"""
|
||||
Edit a custom view
|
||||
|
||||
:param int custom_id: the id of the edited custom view
|
||||
:param str arch: the edited arch of the custom view
|
||||
:returns: dict with acknowledged operation (result set to True)
|
||||
"""
|
||||
custom_view = request.env['ir.ui.view.custom'].browse(custom_id)
|
||||
custom_view.write({ 'arch': arch })
|
||||
return {'result': True}
|
||||
|
||||
class Binary(http.Controller):
|
||||
|
||||
Reference in New Issue
Block a user