summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Kühn <alex.e.kuhn@gmail.com>2018-04-16 12:44:16 +0200
committerAlexandre Kühn <alex.e.kuhn@gmail.com>2018-04-17 17:32:27 +0200
commitcf163d19eefb8049c8bbd443cd9d1f3260cf3774 (patch)
treea1d31456e62459bcbdb2846ce6c4b53a850ea984
parent74e208eabf950e0502d35f2c0c69bc212fdaed5b (diff)
[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
-rw-r--r--addons/board/static/src/js/dashboard.js4
-rw-r--r--addons/web/controllers/main.py20
2 files changed, 14 insertions, 10 deletions
diff --git a/addons/board/static/src/js/dashboard.js b/addons/board/static/src/js/dashboard.js
index 4bdf33c3d32..b3055637ffb 100644
--- a/addons/board/static/src/js/dashboard.js
+++ b/addons/board/static/src/js/dashboard.js
@@ -169,8 +169,8 @@ var DashBoard = form_common.FormWidget.extend({
board.columns.push(actions);
});
var arch = QWeb.render('DashBoard.xml', board);
- this.rpc('/web/view/add_custom', {
- view_id: this.view.fields_view.view_id,
+ this.rpc('/web/view/edit_custom', { // do not forward-port > saas-15
+ custom_id: this.view.fields_view.custom_view_id, // do not forward-port > saas-15
arch: arch
});
},
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 2ac11d1c1e4..d8cb0e6a36f 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -930,14 +930,18 @@ 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.session.model('ir.ui.view.custom')
- CustomView.create({
- 'user_id': request.session.uid,
- 'ref_id': view_id,
- 'arch': arch
- }, request.context)
+ @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 TreeView(View):