Browse Source

various improvement. Courtesy @dreispt review

pull/1323/head
Sylvain LE GAL 8 years ago
committed by hveficent
parent
commit
b95a80fc07
  1. 11
      sql_request_abstract/models/sql_request_mixin.py
  2. 2
      sql_request_abstract/security/ir_module_category.xml

11
sql_request_abstract/models/sql_request_mixin.py

@ -14,7 +14,7 @@ from openerp import _, api, fields, models
from openerp.exceptions import Warning as UserError
class SQLRequestMixin(models.Model):
class SQLRequestMixin(models.AbstractModel):
_name = 'sql.request.mixin'
_clean_query_enabled = True
@ -60,7 +60,7 @@ class SQLRequestMixin(models.Model):
query = fields.Text(
string='Query', required=True, help="You can't use the following words"
": DELETE, DROP, CREATE, INSERT, ALTER, TRUNCATE, EXECUTE, UPDATE")
": DELETE, DROP, CREATE, INSERT, ALTER, TRUNCATE, EXECUTE, UPDATE.")
state = fields.Selection(
string='State', selection=STATE_SELECTION, default='draft',
@ -82,7 +82,7 @@ class SQLRequestMixin(models.Model):
# Action Section
@api.multi
def button_clean_check_request(self):
def button_validate_sql_expression(self):
for item in self:
if item._clean_query_enabled:
item._clean_query()
@ -198,7 +198,10 @@ class SQLRequestMixin(models.Model):
self.env.cr.execute("SHOW server_version;")
res = self.env.cr.fetchone()[0].split('.')
minor_version = float('.'.join(res[:2]))
return minor_version >= 9.3
if minor_version < 9.3:
raise UserError(_(
"Materialized View requires PostgreSQL 9.3 or greater but"
" PostgreSQL %s is currently installed.") % (minor_version))
@api.multi
def _clean_query(self):

2
sql_request_abstract/security/ir_module_category.xml

@ -3,7 +3,7 @@
<openerp><data>
<record model="ir.module.category" id="category_sql_abstract">
<field name="name">Sql Request</field>
<field name="name">SQL Request</field>
</record>
</data></openerp>
Loading…
Cancel
Save