summaryrefslogtreecommitdiff
path: root/addons/web/controllers/main.py
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2018-04-16 14:16:24 +0200
committerAlexandre Kühn <aku@odoo.com>2018-04-17 17:28:49 +0200
commitb15e805b5ad40e1e8e08e9be1ba248da66158bc9 (patch)
tree0bc93c17c8c161c1fa6ab3eab5130a3039a98a9f /addons/web/controllers/main.py
parentcd934f307de19b247bf88b9dc41a8fdea15fd23c (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
Diffstat (limited to 'addons/web/controllers/main.py')
-rw-r--r--addons/web/controllers/main.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 6b73f28ca7d..91d178bc69c 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -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):