From d60a768d223fb660a29006a74ce3264c4af26460 Mon Sep 17 00:00:00 2001 From: hveficent Date: Wed, 25 Jul 2018 15:54:32 +0200 Subject: [PATCH] [MIG] sql_request_abstract: Migration to 11.0 --- sql_request_abstract/README.rst | 6 +++--- sql_request_abstract/__init__.py | 1 - sql_request_abstract/__manifest__.py | 3 +-- sql_request_abstract/models/__init__.py | 1 - sql_request_abstract/models/sql_request_mixin.py | 13 +++++++------ 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/sql_request_abstract/README.rst b/sql_request_abstract/README.rst index d3b86b9a9..3f57b9cd4 100644 --- a/sql_request_abstract/README.rst +++ b/sql_request_abstract/README.rst @@ -1,4 +1,4 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 @@ -6,7 +6,7 @@ Abstract Model to manage SQL Requests ===================================== -This module provide an abstract model to manage SQL Select request on database. +This module provides an abstract model to manage SQL Select requests on database. It is not usefull for itself. You can see an exemple of implementation in the 'sql_export' module. (same repository). @@ -45,7 +45,7 @@ Inherit the model: .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/149/10.0 + :target: https://runbot.odoo-community.org/runbot/149/11.0 Bug Tracker =========== diff --git a/sql_request_abstract/__init__.py b/sql_request_abstract/__init__.py index a77a6fcbc..83e553ac4 100644 --- a/sql_request_abstract/__init__.py +++ b/sql_request_abstract/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/sql_request_abstract/__manifest__.py b/sql_request_abstract/__manifest__.py index fa3382d96..67e62c04b 100644 --- a/sql_request_abstract/__manifest__.py +++ b/sql_request_abstract/__manifest__.py @@ -1,11 +1,10 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2017 - Today: GRAP (http://www.grap.coop) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'SQL Request Abstract', - 'version': '10.0.1.0.1', + 'version': '11.0.1.0.1', 'author': 'GRAP,Akretion,Odoo Community Association (OCA)', 'website': 'https://www.odoo-community.org', 'license': 'AGPL-3', diff --git a/sql_request_abstract/models/__init__.py b/sql_request_abstract/models/__init__.py index 40603335c..5a7c1380d 100644 --- a/sql_request_abstract/models/__init__.py +++ b/sql_request_abstract/models/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import sql_request_mixin diff --git a/sql_request_abstract/models/sql_request_mixin.py b/sql_request_abstract/models/sql_request_mixin.py index 9aced3863..8a639b070 100644 --- a/sql_request_abstract/models/sql_request_mixin.py +++ b/sql_request_abstract/models/sql_request_mixin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2015 Akretion () # Copyright (C) 2017 - Today: GRAP (http://www.grap.coop) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) @@ -6,7 +5,7 @@ import re import uuid -import StringIO +from io import StringIO import base64 from psycopg2 import ProgrammingError @@ -144,10 +143,12 @@ class SQLRequestMixin(models.AbstractModel): if mode in ('view', 'materialized_view'): rollback = False - params = params or {} # pylint: disable=sql-injection - query = self.query % params - query = query.decode('utf-8') + if params: + query = self.query % params + else: + query = self.query + query = query if mode in ('fetchone', 'fetchall'): pass @@ -242,7 +243,7 @@ class SQLRequestMixin(models.AbstractModel): res = self._hook_executed_request() except ProgrammingError as e: raise UserError( - _("The SQL query is not valid:\n\n %s") % e.message) + _("The SQL query is not valid:\n\n %s") % e) finally: self._rollback_savepoint(rollback_name) return res