From cefa0fcb8def22f459a0b2e0d08cb577091d5ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Todorovich?= Date: Wed, 23 Nov 2016 13:12:43 -0300 Subject: [PATCH] [8.0][FIX] web_dashboard_tile security rule Rule was not being updated because of ``, hence the groups field of the tile was not working. Conflicts: web_dashboard_tile/__openerp__.py --- web_dashboard_tile/__openerp__.py | 4 +-- .../migrations/8.0.4.0/post-migration.py | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 web_dashboard_tile/migrations/8.0.4.0/post-migration.py diff --git a/web_dashboard_tile/__openerp__.py b/web_dashboard_tile/__openerp__.py index 3e636b15..f84fd1b3 100644 --- a/web_dashboard_tile/__openerp__.py +++ b/web_dashboard_tile/__openerp__.py @@ -23,7 +23,7 @@ { "name": "Dashboard Tile", "summary": "Add Tiles to Dashboard", - "version": "8.0.1.0.0", + "version": "9.0.1.0.0", "depends": [ 'web', 'board', @@ -46,5 +46,5 @@ 'qweb': [ 'static/src/xml/custom_xml.xml', ], - 'installable': False, + 'installable': True, } diff --git a/web_dashboard_tile/migrations/8.0.4.0/post-migration.py b/web_dashboard_tile/migrations/8.0.4.0/post-migration.py new file mode 100644 index 00000000..570f814e --- /dev/null +++ b/web_dashboard_tile/migrations/8.0.4.0/post-migration.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# © 2016 Iván Todorovich +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + + +def migrate(cr, version): + if version is None: + return + + # Update ir.rule + cr.execute(""" + SELECT res_id FROM ir_model_data + WHERE name = 'model_tile_rule' + AND module = 'web_dashboard_tile'""") + rule_id = cr.fetchone()[0] + new_domain = """[ + "|", + ("user_id","=",user.id), + ("user_id","=",False), + "|", + ("group_ids","=",False), + ("group_ids","in",[g.id for g in user.groups_id]), + ]""" + cr.execute(""" + UPDATE ir_rule SET domain_force = '%(domain)s' + WHERE id = '%(id)s' """ % {'domain': new_domain, 'id': rule_id})