From f34b7cfae2a6b19423c05c6ba2dd5833d5464ada Mon Sep 17 00:00:00 2001 From: "Adrien Peiffer (ACSONE)" Date: Tue, 11 Oct 2016 12:01:39 +0200 Subject: [PATCH] Migration of mis_builder to 10.0 --- mis_builder/__manifest__.py | 5 ++-- mis_builder/datas/ir_cron.xml | 4 ++-- mis_builder/models/aep.py | 8 +++---- mis_builder/models/mis_report.py | 9 ++++---- mis_builder/models/mis_report_instance.py | 6 ++--- mis_builder/models/mis_report_style.py | 4 ++-- mis_builder/models/mis_safe_eval.py | 2 +- .../report/mis_report_instance_qweb.py | 23 ++++++++----------- .../report/mis_report_instance_qweb.xml | 4 ++-- .../report/mis_report_instance_xlsx.py | 4 ++-- .../report/mis_report_instance_xlsx.xml | 4 ++-- mis_builder/security/mis_builder_security.xml | 4 ++-- mis_builder/static/src/css/custom.css | 2 +- mis_builder/static/src/xml/mis_widget.xml | 8 +++---- mis_builder/tests/test_accounting_none.py | 2 +- mis_builder/tests/test_aep.py | 6 ++--- mis_builder/tests/test_aggregate.py | 2 +- mis_builder/tests/test_fetch_query.py | 2 +- mis_builder/tests/test_mis_report_instance.py | 4 ++-- mis_builder/tests/test_mis_safe_eval.py | 2 +- mis_builder/tests/test_render.py | 2 +- mis_builder/tests/test_simple_array.py | 2 +- mis_builder/tests/test_utc_midnight.py | 2 +- mis_builder/views/mis_report.xml | 4 ++-- mis_builder/views/mis_report_instance.xml | 20 ++++++++-------- mis_builder/views/mis_report_style.xml | 4 ++-- mis_builder/wizard/mis_builder_dashboard.py | 2 +- mis_builder/wizard/mis_builder_dashboard.xml | 4 ++-- 28 files changed, 71 insertions(+), 74 deletions(-) diff --git a/mis_builder/__manifest__.py b/mis_builder/__manifest__.py index 0b7ce378..f286f235 100644 --- a/mis_builder/__manifest__.py +++ b/mis_builder/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'MIS Builder', - 'version': '9.0.2.0.2', + 'version': '10.0.2.0.2', 'category': 'Reporting', 'summary': """ Build 'Management Information System' Reports and Dashboards @@ -14,6 +14,7 @@ 'website': 'http://acsone.eu', 'depends': [ 'account', + 'board', 'report_xlsx', # OCA/reporting-engine 'date_range', # OCA/server-tools # TODO uncomment when https://github.com/OCA/web/pull/270 is merged @@ -40,7 +41,7 @@ 'qweb': [ 'static/src/xml/*.xml' ], - 'installable': False, + 'installable': True, 'application': True, 'license': 'AGPL-3', } diff --git a/mis_builder/datas/ir_cron.xml b/mis_builder/datas/ir_cron.xml index 199770c8..800020e2 100644 --- a/mis_builder/datas/ir_cron.xml +++ b/mis_builder/datas/ir_cron.xml @@ -1,5 +1,5 @@ - + @@ -15,4 +15,4 @@ - + diff --git a/mis_builder/models/aep.py b/mis_builder/models/aep.py index 25f8970d..b79276c7 100644 --- a/mis_builder/models/aep.py +++ b/mis_builder/models/aep.py @@ -6,10 +6,10 @@ import re from collections import defaultdict from itertools import izip -from openerp import fields -from openerp.models import expression -from openerp.tools.safe_eval import safe_eval -from openerp.tools.float_utils import float_is_zero +from odoo import fields +from odoo.models import expression +from odoo.tools.safe_eval import safe_eval +from odoo.tools.float_utils import float_is_zero from .accounting_none import AccountingNone diff --git a/mis_builder/models/mis_report.py b/mis_builder/models/mis_report.py index 7068afbf..8e9c3f5c 100644 --- a/mis_builder/models/mis_report.py +++ b/mis_builder/models/mis_report.py @@ -12,9 +12,9 @@ import time import pytz -from openerp import api, fields, models, _ -from openerp.exceptions import UserError -from openerp.tools.safe_eval import safe_eval +from odoo import api, fields, models, _ +from odoo.exceptions import UserError +from odoo.tools.safe_eval import safe_eval from .aep import AccountingExpressionProcessor as AEP from .aggregate import _sum, _avg, _min, _max @@ -159,8 +159,7 @@ class KpiMatrix(object): def __init__(self, env): # cache language id for faster rendering lang_model = env['res.lang'] - lang_id = lang_model._lang_get(env.user.lang) - self.lang = lang_model.browse(lang_id) + self.lang = lang_model._lang_get(env.user.lang) self._style_model = env['mis.report.style'] self._account_model = env['account.account'] # data structures diff --git a/mis_builder/models/mis_report_instance.py b/mis_builder/models/mis_report_instance.py index 5d111b83..7178fa08 100644 --- a/mis_builder/models/mis_report_instance.py +++ b/mis_builder/models/mis_report_instance.py @@ -2,7 +2,7 @@ # © 2014-2016 ACSONE SA/NV () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp import api, fields, models, _ +from odoo import api, fields, models, _ import datetime import logging @@ -264,8 +264,8 @@ class MisReportInstance(models.Model): def _format_date(self, date): # format date following user language lang_model = self.env['res.lang'] - lang_id = lang_model._lang_get(self.env.user.lang) - date_format = lang_model.browse(lang_id).date_format + lang = lang_model._lang_get(self.env.user.lang) + date_format = lang.date_format return datetime.datetime.strftime( fields.Date.from_string(date), date_format) diff --git a/mis_builder/models/mis_report_style.py b/mis_builder/models/mis_report_style.py index 20fb236f..32c80491 100644 --- a/mis_builder/models/mis_report_style.py +++ b/mis_builder/models/mis_report_style.py @@ -3,8 +3,8 @@ # © 2016 ACSONE SA/NV () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp import api, fields, models, _ -from openerp.exceptions import UserError +from odoo import api, fields, models, _ +from odoo.exceptions import UserError from .accounting_none import AccountingNone from .data_error import DataError diff --git a/mis_builder/models/mis_safe_eval.py b/mis_builder/models/mis_safe_eval.py index 995ff76c..180ab2f9 100644 --- a/mis_builder/models/mis_safe_eval.py +++ b/mis_builder/models/mis_safe_eval.py @@ -4,7 +4,7 @@ import traceback -from openerp.tools.safe_eval import test_expr, _SAFE_OPCODES, _BUILTINS +from odoo.tools.safe_eval import test_expr, _SAFE_OPCODES, _BUILTINS from .data_error import DataError, NameDataError diff --git a/mis_builder/report/mis_report_instance_qweb.py b/mis_builder/report/mis_report_instance_qweb.py index 162b146a..54f5c47a 100644 --- a/mis_builder/report/mis_report_instance_qweb.py +++ b/mis_builder/report/mis_report_instance_qweb.py @@ -4,7 +4,7 @@ import logging -from openerp import api, models +from odoo import api, models _logger = logging.getLogger(__name__) @@ -12,16 +12,13 @@ _logger = logging.getLogger(__name__) class Report(models.Model): _inherit = "report" - @api.v7 - def get_pdf(self, cr, uid, ids, report_name, html=None, data=None, - context=None): - if ids: - report = self._get_report_from_name(cr, uid, report_name) - obj = self.pool[report.model].browse(cr, uid, ids, - context=context)[0] - context = context.copy() + @api.model + def get_pdf(self, docids, report_name, html=None, data=None): + if docids: + report = self._get_report_from_name(report_name) + obj = self.env[report.model].browse(docids)[0] + ctx = self.env.context.copy() if hasattr(obj, 'landscape_pdf') and obj.landscape_pdf: - context.update({'landscape': True}) - return super(Report, self).get_pdf(cr, uid, ids, report_name, - html=html, data=data, - context=context) + ctx.update({'landscape': True}) + return super(Report, self.with_context(ctx)).get_pdf( + docids, report_name, html=html, data=data) diff --git a/mis_builder/report/mis_report_instance_qweb.xml b/mis_builder/report/mis_report_instance_qweb.xml index 769034bc..48e5bb90 100644 --- a/mis_builder/report/mis_report_instance_qweb.xml +++ b/mis_builder/report/mis_report_instance_qweb.xml @@ -1,5 +1,5 @@ - + @@ -86,4 +86,4 @@ - + diff --git a/mis_builder/report/mis_report_instance_xlsx.py b/mis_builder/report/mis_report_instance_xlsx.py index ecfa470b..bc0940cb 100644 --- a/mis_builder/report/mis_report_instance_xlsx.py +++ b/mis_builder/report/mis_report_instance_xlsx.py @@ -5,7 +5,7 @@ from collections import defaultdict import logging -from openerp.report import report_sxw +from odoo.report import report_sxw from ..models.accounting_none import AccountingNone from ..models.data_error import DataError @@ -13,7 +13,7 @@ from ..models.data_error import DataError _logger = logging.getLogger(__name__) try: - from openerp.addons.report_xlsx.report.report_xlsx import ReportXlsx + from odoo.addons.report_xlsx.report.report_xlsx import ReportXlsx except ImportError: _logger.debug("report_xlsx not installed, Excel export non functional") diff --git a/mis_builder/report/mis_report_instance_xlsx.xml b/mis_builder/report/mis_report_instance_xlsx.xml index e3695648..77d7c40c 100644 --- a/mis_builder/report/mis_report_instance_xlsx.xml +++ b/mis_builder/report/mis_report_instance_xlsx.xml @@ -1,5 +1,5 @@ - + @@ -12,4 +12,4 @@ - + diff --git a/mis_builder/security/mis_builder_security.xml b/mis_builder/security/mis_builder_security.xml index d4562df0..e80c51d7 100644 --- a/mis_builder/security/mis_builder_security.xml +++ b/mis_builder/security/mis_builder_security.xml @@ -1,5 +1,5 @@ - + @@ -10,4 +10,4 @@ - + diff --git a/mis_builder/static/src/css/custom.css b/mis_builder/static/src/css/custom.css index f4405a86..2c59d7e7 100644 --- a/mis_builder/static/src/css/custom.css +++ b/mis_builder/static/src/css/custom.css @@ -20,7 +20,7 @@ text-decoration: underline; } -.openerp .oe_mis_builder_buttons { +.odoo .oe_mis_builder_buttons { padding-bottom: 10px; padding-top: 10px; } diff --git a/mis_builder/static/src/xml/mis_widget.xml b/mis_builder/static/src/xml/mis_widget.xml index 8ef0ef04..e077fc5e 100644 --- a/mis_builder/static/src/xml/mis_widget.xml +++ b/mis_builder/static/src/xml/mis_widget.xml @@ -4,10 +4,10 @@

- - - - + + + +
diff --git a/mis_builder/tests/test_accounting_none.py b/mis_builder/tests/test_accounting_none.py index 6a410228..7af50d0b 100644 --- a/mis_builder/tests/test_accounting_none.py +++ b/mis_builder/tests/test_accounting_none.py @@ -4,7 +4,7 @@ import doctest -from openerp.addons.mis_builder.models import accounting_none +from odoo.addons.mis_builder.models import accounting_none def load_tests(loader, tests, ignore): diff --git a/mis_builder/tests/test_aep.py b/mis_builder/tests/test_aep.py index 5b1f349a..a5f4b258 100644 --- a/mis_builder/tests/test_aep.py +++ b/mis_builder/tests/test_aep.py @@ -5,9 +5,9 @@ import datetime import time -from openerp import fields -import openerp.tests.common as common -from openerp.tools.safe_eval import safe_eval +from odoo import fields +import odoo.tests.common as common +from odoo.tools.safe_eval import safe_eval from ..models.aep import AccountingExpressionProcessor as AEP from ..models.accounting_none import AccountingNone diff --git a/mis_builder/tests/test_aggregate.py b/mis_builder/tests/test_aggregate.py index ca92a4d1..2472b2a1 100644 --- a/mis_builder/tests/test_aggregate.py +++ b/mis_builder/tests/test_aggregate.py @@ -4,7 +4,7 @@ import doctest -from openerp.addons.mis_builder.models import aggregate +from odoo.addons.mis_builder.models import aggregate def load_tests(loader, tests, ignore): diff --git a/mis_builder/tests/test_fetch_query.py b/mis_builder/tests/test_fetch_query.py index f701e735..f3b69b6d 100644 --- a/mis_builder/tests/test_fetch_query.py +++ b/mis_builder/tests/test_fetch_query.py @@ -2,7 +2,7 @@ # © 2014-2016 ACSONE SA/NV () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -import openerp.tests.common as common +import odoo.tests.common as common class TestFetchQuery(common.TransactionCase): diff --git a/mis_builder/tests/test_mis_report_instance.py b/mis_builder/tests/test_mis_report_instance.py index 052b8601..c417f072 100644 --- a/mis_builder/tests/test_mis_report_instance.py +++ b/mis_builder/tests/test_mis_report_instance.py @@ -2,8 +2,8 @@ # © 2016 ACSONE SA/NV () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -import openerp.tests.common as common -from openerp.tools import test_reports +import odoo.tests.common as common +from odoo.tools import test_reports class TestMisReportInstance(common.TransactionCase): diff --git a/mis_builder/tests/test_mis_safe_eval.py b/mis_builder/tests/test_mis_safe_eval.py index f2cf9b06..524f4f3f 100644 --- a/mis_builder/tests/test_mis_safe_eval.py +++ b/mis_builder/tests/test_mis_safe_eval.py @@ -2,7 +2,7 @@ # © 2016 ACSONE SA/NV () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -import openerp.tests.common as common +import odoo.tests.common as common from ..models.mis_safe_eval import mis_safe_eval, DataError, NameDataError diff --git a/mis_builder/tests/test_render.py b/mis_builder/tests/test_render.py index 4a08a6ab..90537f0f 100644 --- a/mis_builder/tests/test_render.py +++ b/mis_builder/tests/test_render.py @@ -2,7 +2,7 @@ # © 2016 ACSONE SA/NV () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -import openerp.tests.common as common +import odoo.tests.common as common from ..models.accounting_none import AccountingNone from ..models.mis_report_style import ( diff --git a/mis_builder/tests/test_simple_array.py b/mis_builder/tests/test_simple_array.py index ab59eed0..ff622fbd 100644 --- a/mis_builder/tests/test_simple_array.py +++ b/mis_builder/tests/test_simple_array.py @@ -4,7 +4,7 @@ import doctest -from openerp.addons.mis_builder.models import simple_array +from odoo.addons.mis_builder.models import simple_array def load_tests(loader, tests, ignore): diff --git a/mis_builder/tests/test_utc_midnight.py b/mis_builder/tests/test_utc_midnight.py index 4e5d3df2..ca574553 100644 --- a/mis_builder/tests/test_utc_midnight.py +++ b/mis_builder/tests/test_utc_midnight.py @@ -2,7 +2,7 @@ # © 2014-2015 ACSONE SA/NV () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -import openerp.tests.common as common +import odoo.tests.common as common from ..models.mis_report import _utc_midnight diff --git a/mis_builder/views/mis_report.xml b/mis_builder/views/mis_report.xml index 83c69cc2..d752eef7 100644 --- a/mis_builder/views/mis_report.xml +++ b/mis_builder/views/mis_report.xml @@ -1,5 +1,5 @@ - + @@ -169,4 +169,4 @@ - + diff --git a/mis_builder/views/mis_report_instance.xml b/mis_builder/views/mis_report_instance.xml index 1d03095c..b018e0fa 100644 --- a/mis_builder/views/mis_report_instance.xml +++ b/mis_builder/views/mis_report_instance.xml @@ -1,5 +1,5 @@ - +