Browse Source

on_change shows the complete SQL name

pull/245/head
Guewen Baconnier 9 years ago
parent
commit
52e226eab5
  1. 12
      sql_view/models/sql_view.py
  2. 2
      sql_view/views/sql_view_views.xml

12
sql_view/models/sql_view.py

@ -35,11 +35,16 @@ PG_NAME_RE = re.compile(r'^[a-z_][a-z0-9_$]*$', re.I)
class SQLView(orm.Model):
_name = 'sql.view'
def _complete_from_sql_name(self, cr, uid, sql_name, context=None):
return SQL_VIEW_PREFIX + (sql_name or '')
def _compute_complete_sql_name(self, cr, uid, ids, name, args,
context=None):
res = {}
for sql_view in self.browse(cr, uid, ids, context=context):
res[sql_view.id] = SQL_VIEW_PREFIX + sql_view.sql_name
res[sql_view.id] = self._complete_from_sql_name(cr, uid,
sql_view.sql_name,
context=context)
return res
_columns = {
@ -156,3 +161,8 @@ class SQLView(orm.Model):
self._delete_sql_view(cr, uid, record, context=context)
result = super(SQLView, self).unlink(cr, uid, ids, context=context)
return result
def onchange_sql_name(self, cr, uid, ids, sql_name, context=None):
complete_name = self._complete_from_sql_name(cr, uid, sql_name,
context=context)
return {'value': {'complete_sql_name': complete_name}}

2
sql_view/views/sql_view_views.xml

@ -16,7 +16,7 @@
<sheet string="SQL View">
<group>
<field name="name"/>
<field name="sql_name"/>
<field name="sql_name" on_change="onchange_sql_name(sql_name)"/>
<field name="complete_sql_name"/>
</group>
<group string="Definition">

Loading…
Cancel
Save