summaryrefslogtreecommitdiff
path: root/addons/board/controllers
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/board/controllers
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/board/controllers')
-rw-r--r--addons/board/controllers/__init__.py4
-rw-r--r--addons/board/controllers/main.py40
2 files changed, 44 insertions, 0 deletions
diff --git a/addons/board/controllers/__init__.py b/addons/board/controllers/__init__.py
new file mode 100644
index 00000000..5d4b25db
--- /dev/null
+++ b/addons/board/controllers/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import main
diff --git a/addons/board/controllers/main.py b/addons/board/controllers/main.py
new file mode 100644
index 00000000..303f5b09
--- /dev/null
+++ b/addons/board/controllers/main.py
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from lxml import etree as ElementTree
+
+from odoo.http import Controller, route, request
+
+
+class Board(Controller):
+
+ @route('/board/add_to_dashboard', type='json', auth='user')
+ def add_to_dashboard(self, action_id, context_to_save, domain, view_mode, name=''):
+ # Retrieve the 'My Dashboard' action from its xmlid
+ action = request.env.ref('board.open_board_my_dash_action').sudo()
+
+ if action and action['res_model'] == 'board.board' and action['views'][0][1] == 'form' and action_id:
+ # Maybe should check the content instead of model board.board ?
+ view_id = action['views'][0][0]
+ board = request.env['board.board'].fields_view_get(view_id, 'form')
+ if board and 'arch' in board:
+ xml = ElementTree.fromstring(board['arch'])
+ column = xml.find('./board/column')
+ if column is not None:
+ new_action = ElementTree.Element('action', {
+ 'name': str(action_id),
+ 'string': name,
+ 'view_mode': view_mode,
+ 'context': str(context_to_save),
+ 'domain': str(domain)
+ })
+ column.insert(0, new_action)
+ arch = ElementTree.tostring(xml, encoding='unicode')
+ request.env['ir.ui.view.custom'].create({
+ 'user_id': request.session.uid,
+ 'ref_id': view_id,
+ 'arch': arch
+ })
+ return True
+
+ return False