|
@ -5,6 +5,7 @@ |
|
|
|
|
|
|
|
|
import re |
|
|
import re |
|
|
import uuid |
|
|
import uuid |
|
|
|
|
|
import logging |
|
|
from io import BytesIO |
|
|
from io import BytesIO |
|
|
import base64 |
|
|
import base64 |
|
|
from psycopg2 import ProgrammingError |
|
|
from psycopg2 import ProgrammingError |
|
@ -12,6 +13,8 @@ from psycopg2 import ProgrammingError |
|
|
from odoo import _, api, fields, models |
|
|
from odoo import _, api, fields, models |
|
|
from odoo.exceptions import UserError |
|
|
from odoo.exceptions import UserError |
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SQLRequestMixin(models.AbstractModel): |
|
|
class SQLRequestMixin(models.AbstractModel): |
|
|
_name = 'sql.request.mixin' |
|
|
_name = 'sql.request.mixin' |
|
@ -242,6 +245,7 @@ class SQLRequestMixin(models.AbstractModel): |
|
|
self.env.cr.execute(query) |
|
|
self.env.cr.execute(query) |
|
|
res = self._hook_executed_request() |
|
|
res = self._hook_executed_request() |
|
|
except ProgrammingError as e: |
|
|
except ProgrammingError as e: |
|
|
|
|
|
logger.exception("Failed query: %s", query) |
|
|
raise UserError( |
|
|
raise UserError( |
|
|
_("The SQL query is not valid:\n\n %s") % e) |
|
|
_("The SQL query is not valid:\n\n %s") % e) |
|
|
finally: |
|
|
finally: |
|
|