diff --git a/mis_builder/__init__.py b/mis_builder/__init__.py index 386e1d1d..409475d8 100644 --- a/mis_builder/__init__.py +++ b/mis_builder/__init__.py @@ -1,26 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import models from . import wizard diff --git a/mis_builder/__openerp__.py b/mis_builder/__openerp__.py index f46ece52..1e78005b 100644 --- a/mis_builder/__openerp__.py +++ b/mis_builder/__openerp__.py @@ -1,26 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { 'name': 'MIS Builder', diff --git a/mis_builder/models/__init__.py b/mis_builder/models/__init__.py index e99af9da..7f8b7fc8 100644 --- a/mis_builder/models/__init__.py +++ b/mis_builder/models/__init__.py @@ -1,26 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import mis_builder from . import aep diff --git a/mis_builder/models/aep.py b/mis_builder/models/aep.py index 740a58ec..ffa344ae 100644 --- a/mis_builder/models/aep.py +++ b/mis_builder/models/aep.py @@ -1,32 +1,12 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). import re from collections import defaultdict -from openerp.exceptions import Warning -from openerp.osv import expression +from openerp.exceptions import Warning as UserError +from openerp.models import expression from openerp.tools.safe_eval import safe_eval from openerp.tools.translate import _ @@ -321,7 +301,7 @@ class AccountingExpressionProcessor(object): if mode == MODE_VARIATION: domain = [('date', '>=', date_from), ('date', '<=', date_to)] else: - raise Warning(_("Modes i and e are only applicable for " + raise UserError(_("Modes i and e are only applicable for " "fiscal periods")) if target_move == 'posted': domain.append(('move_id.state', '=', 'posted')) diff --git a/mis_builder/models/aggregate.py b/mis_builder/models/aggregate.py index 4788c4c2..bd2aa3c3 100644 --- a/mis_builder/models/aggregate.py +++ b/mis_builder/models/aggregate.py @@ -1,26 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). def _sum(l): diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py index 7e4a7964..3872233a 100644 --- a/mis_builder/models/mis_builder.py +++ b/mis_builder/models/mis_builder.py @@ -1,26 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). import datetime import dateutil @@ -76,7 +56,7 @@ class MisReportKpi(models.Model): In addition to a name and description, it has an expression to compute it based on queries defined in the MIS report. It also has various informations defining how to render it - (numeric or percentage or a string, a suffix, divider) and + (numeric or percentage or a string, a prefix, a suffix, divider) and how to render comparison of two values of the KPI. KPI's have a sequence and are ordered inside the MIS report. """ @@ -106,6 +86,7 @@ class MisReportKpi(models.Model): string='Factor', default='1') dp = fields.Integer(string='Rounding', default=0) + prefix = fields.Char(size=16, string='Prefix') suffix = fields.Char(size=16, string='Suffix') compare_method = fields.Selection([('diff', _('Difference')), ('pct', _('Percentage')), @@ -163,10 +144,10 @@ class MisReportKpi(models.Model): return '#N/A' elif self.type == 'num': return self._render_num(lang_id, value, self.divider, - self.dp, self.suffix) + self.dp, self.prefix, self.suffix) elif self.type == 'pct': return self._render_num(lang_id, value, 0.01, - self.dp, '%') + self.dp, '', '%') else: return unicode(value) @@ -180,7 +161,7 @@ class MisReportKpi(models.Model): return self._render_num( lang_id, value - base_value, - 0.01, self.dp, _('pp'), sign='+') + 0.01, self.dp, '', _('pp'), sign='+') elif self.type == 'num': if average_value: value = value / float(average_value) @@ -190,17 +171,17 @@ class MisReportKpi(models.Model): return self._render_num( lang_id, value - base_value, - self.divider, self.dp, self.suffix, sign='+') + self.divider, self.dp, self.prefix, self.suffix, sign='+') elif self.compare_method == 'pct': if round(base_value, self.dp) != 0: return self._render_num( lang_id, (value - base_value) / abs(base_value), - 0.01, self.dp, '%', sign='+') + 0.01, self.dp, '', '%', sign='+') return '' def _render_num(self, lang_id, value, divider, - dp, suffix, sign='-'): + dp, prefix, suffix, sign='-'): divider_label = _get_selection_label( self._columns['divider'].selection, divider) if divider_label == '1': @@ -211,8 +192,8 @@ class MisReportKpi(models.Model): '%%%s.%df' % (sign, dp), value, grouping=True) - value = u'%s\N{NO-BREAK SPACE}%s%s' % \ - (value, divider_label, suffix or '') + value = u'%s\N{NARROW NO-BREAK SPACE}%s\N{NO-BREAK SPACE}%s%s' % \ + (prefix or '', value, divider_label, suffix or '') value = value.replace('-', u'\N{NON-BREAKING HYPHEN}') return value @@ -567,6 +548,7 @@ class MisReportInstancePeriod(models.Model): 'val_r': kpi_val_rendered, 'val_c': kpi_val_comment, 'style': kpi_style, + 'prefix': kpi.prefix, 'suffix': kpi.suffix, 'dp': kpi.dp, 'is_percentage': kpi.type == 'pct', diff --git a/mis_builder/report/__init__.py b/mis_builder/report/__init__.py index 671c3f7b..b215fc74 100644 --- a/mis_builder/report/__init__.py +++ b/mis_builder/report/__init__.py @@ -1,26 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). try: from . import mis_builder_xls diff --git a/mis_builder/report/mis_builder_xls.py b/mis_builder/report/mis_builder_xls.py index 88dcd1cf..df3d3ee5 100644 --- a/mis_builder/report/mis_builder_xls.py +++ b/mis_builder/report/mis_builder_xls.py @@ -1,26 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). import xlwt from openerp.report import report_sxw @@ -29,19 +9,19 @@ import logging _logger = logging.getLogger(__name__) -class mis_builder_xls_parser(report_sxw.rml_parse): +class MisBuilderXlsParser(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): - super(mis_builder_xls_parser, self).__init__( + super(MisBuilderXlsParser, self).__init__( cr, uid, name, context=context) self.context = context -class mis_builder_xls(report_xls): +class MisBuilderXls(report_xls): def __init__(self, name, table, rml=False, parser=False, header=True, store=False): - super(mis_builder_xls, self).__init__( + super(MisBuilderXls, self).__init__( name, table, rml, parser, header, store) # Cell Styles @@ -118,8 +98,10 @@ class mis_builder_xls(report_xls): if value.get('dp'): num_format_str += '.' num_format_str += '0' * int(value['dp']) + if value.get('prefix'): + num_format_str = '"%s"' % value['prefix'] + num_format_str if value.get('suffix'): - num_format_str = num_format_str + ' "%s"' % value['suffix'] + num_format_str += ' "%s"' % value['suffix'] kpi_cell_style = xlwt.easyxf( _xs['borders_all'] + _xs['right'], num_format_str=num_format_str) @@ -133,6 +115,6 @@ class mis_builder_xls(report_xls): row_pos += 1 -mis_builder_xls('report.mis.report.instance.xls', - 'mis.report.instance', - parser=mis_builder_xls_parser) +MisBuilderXls('report.mis.report.instance.xls', + 'mis.report.instance', + parser=MisBuilderXlsParser) diff --git a/mis_builder/report/report_mis_report_instance.py b/mis_builder/report/report_mis_report_instance.py index 9305081c..44cfbeb8 100644 --- a/mis_builder/report/report_mis_report_instance.py +++ b/mis_builder/report/report_mis_report_instance.py @@ -1,26 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). import logging diff --git a/mis_builder/tests/__init__.py b/mis_builder/tests/__init__.py index 42df0b2e..622712e3 100644 --- a/mis_builder/tests/__init__.py +++ b/mis_builder/tests/__init__.py @@ -1,25 +1,5 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import test_mis_builder diff --git a/mis_builder/tests/test_mis_builder.py b/mis_builder/tests/test_mis_builder.py index 4533f003..1ac4610d 100644 --- a/mis_builder/tests/test_mis_builder.py +++ b/mis_builder/tests/test_mis_builder.py @@ -1,36 +1,16 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). import openerp.tests.common as common from ..models import mis_builder -class test_mis_builder(common.TransactionCase): +class TestMisBuilder(common.TransactionCase): def setUp(self): - super(test_mis_builder, self).setUp() + super(TestMisBuilder, self).setUp() def test_datetime_conversion(self): date_to_convert = '2014-07-05' @@ -65,11 +45,12 @@ class test_mis_builder(common.TransactionCase): 'mis_report_instance_' 'period_test'), 'style': None, + 'prefix': False, 'suffix': False, 'expr': 'len(test)', 'val_c': 'total_test = len(test)', 'val': 0, - 'val_r': u'0\xa0', + 'val_r': u'\u202f0\xa0', 'is_percentage': False, 'dp': 0, 'drilldown': False}] diff --git a/mis_builder/views/mis_builder.xml b/mis_builder/views/mis_builder.xml index 31551f10..65d3c211 100644 --- a/mis_builder/views/mis_builder.xml +++ b/mis_builder/views/mis_builder.xml @@ -49,6 +49,7 @@ + diff --git a/mis_builder/wizard/__init__.py b/mis_builder/wizard/__init__.py index 78ba3c22..8cbd8455 100644 --- a/mis_builder/wizard/__init__.py +++ b/mis_builder/wizard/__init__.py @@ -1,25 +1,5 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import mis_builder_dashboard diff --git a/mis_builder/wizard/mis_builder_dashboard.py b/mis_builder/wizard/mis_builder_dashboard.py index 19bf36fa..f4f91a1b 100644 --- a/mis_builder/wizard/mis_builder_dashboard.py +++ b/mis_builder/wizard/mis_builder_dashboard.py @@ -1,87 +1,66 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# mis_builder module for Odoo, Management Information System Builder -# Copyright (C) 2014-2015 ACSONE SA/NV () -# -# This file is a part of mis_builder -# -# mis_builder is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License v3 or later -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# mis_builder is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License v3 or later for more details. -# -# You should have received a copy of the GNU Affero General Public License -# v3 or later along with this program. -# If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014-2015 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp.osv import orm, fields +from openerp import api, fields, models from lxml import etree -class add_mis_report_instance_dashboard(orm.TransientModel): +class AddMisReportInstanceDashboard(models.TransientModel): _name = "add.mis.report.instance.dashboard.wizard" - _columns = {'name': fields.char('Name', size=32, required=True), - 'dashboard_id': fields.many2one( - 'ir.actions.act_window', - string="Dashboard", required=True, - domain="[('res_model', '=', 'board.board')]"), - } + name = fields.Char('Name', size=32, required=True) - def default_get(self, cr, uid, fields, context=None): - if context is None: - context = {} - if context.get('active_id'): - res = super(add_mis_report_instance_dashboard, self).default_get( - cr, uid, fields, context=context) + dashboard_id = fields.Many2one('ir.actions.act_window', + string="Dashboard", required=True, + domain="[('res_model', '=', " + "'board.board')]") + + @api.model + def default_get(self, fields): + res = {} + if self.env.context.get('active_id', False): + res = super(AddMisReportInstanceDashboard, self).default_get( + fields) # get report instance name - res['name'] = self.pool['mis.report.instance'].read( - cr, uid, context['active_id'], ['name'])['name'] + res['name'] = self.env['mis.report.instance'].browse( + self.env.context['active_id']).name return res - def action_add_to_dashboard(self, cr, uid, ids, context=None): - if context is None: - context = {} - assert 'active_id' in context, "active_id missing in context" - wizard_data = self.browse(cr, uid, ids, context=context)[0] + @api.multi + def action_add_to_dashboard(self): + assert self.env.context.get('active_id', False), \ + "active_id missing in context" # create the act_window corresponding to this report - view_id = self.pool['ir.model.data'].get_object_reference( - cr, uid, 'mis_builder', 'mis_report_instance_result_view_form')[1] - report_result = self.pool['ir.actions.act_window'].create( - cr, uid, + self.env.ref('mis_builder.mis_report_instance_result_view_form') + view = self.env.ref( + 'mis_builder.mis_report_instance_result_view_form') + report_result = self.env['ir.actions.act_window'].create( {'name': 'mis.report.instance.result.view.action.%d' - % context['active_id'], + % self.env.context['active_id'], 'res_model': 'mis.report.instance', - 'res_id': context['active_id'], + 'res_id': self.env.context['active_id'], 'target': 'current', 'view_mode': 'form', - 'view_id': view_id}) + 'view_id': view.id}) # add this result in the selected dashboard - last_customization = self.pool['ir.ui.view.custom'].search( - cr, uid, - [('user_id', '=', uid), - ('ref_id', '=', wizard_data.dashboard_id.view_id.id)], limit=1) - arch = wizard_data.dashboard_id.view_id.arch + last_customization = self.env['ir.ui.view.custom'].search( + [('user_id', '=', self.env.uid), + ('ref_id', '=', self.dashboard_id.view_id.id)], limit=1) + arch = self.dashboard_id.view_id.arch if last_customization: - arch = self.pool['ir.ui.view.custom'].read( - cr, uid, last_customization[0], ['arch'])['arch'] + arch = self.env['ir.ui.view.custom'].browse( + last_customization[0].id).arch new_arch = etree.fromstring(arch) column = new_arch.xpath("//column")[0] - column.append(etree.Element('action', {'context': str(context), - 'name': str(report_result), - 'string': wizard_data.name, - 'view_mode': 'form'})) - self.pool['ir.ui.view.custom'].create( - cr, uid, {'user_id': uid, - 'ref_id': wizard_data.dashboard_id.view_id.id, - 'arch': etree.tostring(new_arch, pretty_print=True)}) + column.append(etree.Element('action', {'context': str( + self.env.context), + 'name': str(report_result.id), + 'string': self.name, + 'view_mode': 'form'})) + self.env['ir.ui.view.custom'].create( + {'user_id': self.env.uid, + 'ref_id': self.dashboard_id.view_id.id, + 'arch': etree.tostring(new_arch, pretty_print=True)}) return {'type': 'ir.actions.act_window_close', }