improved_customization
bzr revid: fp@tinyerp.com-20081125233317-e9f3f4v99gmyyen0
This commit is contained in:
parent
f9baf7471c
commit
843add7b69
|
@ -27,6 +27,7 @@ CREATE TABLE ir_model (
|
|||
id serial,
|
||||
model varchar(64) DEFAULT ''::varchar NOT NULL,
|
||||
name varchar(64),
|
||||
state varchar(16),
|
||||
info text,
|
||||
primary key(id)
|
||||
);
|
||||
|
|
|
@ -75,7 +75,10 @@ class ir_model(osv.osv):
|
|||
vals['state']='manual'
|
||||
res = super(ir_model,self).create(cr, user, vals, context)
|
||||
if vals.get('state','base')=='manual':
|
||||
pooler.restart_pool(cr.dbname)
|
||||
self.instanciate(cr, user, vals['model'], context)
|
||||
self.pool.get(vals['model']).__init__(self.pool, cr)
|
||||
self.pool.get(vals['model'])._auto_init(cr,{})
|
||||
#pooler.restart_pool(cr.dbname)
|
||||
return res
|
||||
|
||||
def instanciate(self, cr, user, model, context={}):
|
||||
|
@ -84,10 +87,7 @@ class ir_model(osv.osv):
|
|||
x_custom_model._name = model
|
||||
x_custom_model._module = False
|
||||
x_custom_model.createInstance(self.pool, '', cr)
|
||||
if 'x_name' in x_custom_model._columns:
|
||||
x_custom_model._rec_name = 'x_name'
|
||||
else:
|
||||
x_custom_model._rec_name = x_custom_model._columns.keys()[0]
|
||||
x_custom_model._rec_name = 'x_name'
|
||||
ir_model()
|
||||
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
</field>
|
||||
<label colspan="2" string=""/>
|
||||
<group col="2" colspan="2">
|
||||
<button special="cancel" string="Cancel"/>
|
||||
<button name="menu_create" string="Create Menu" type="object"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="menu_create" string="Create Menu" type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
@ -303,15 +303,17 @@ class orm_template(object):
|
|||
_invalids = set()
|
||||
|
||||
def _field_create(self, cr, context={}):
|
||||
cr.execute("SELECT id FROM ir_model_data WHERE name='%s'" % ('model_'+self._name.replace('.','_'),))
|
||||
cr.execute("SELECT id FROM ir_model WHERE model='%s'" % self._name)
|
||||
if not cr.rowcount:
|
||||
cr.execute('SELECT nextval(%s)', ('ir_model_id_seq',))
|
||||
id = cr.fetchone()[0]
|
||||
cr.execute("INSERT INTO ir_model (id,model, name, info) VALUES (%s, %s, %s, %s)", (id, self._name, self._description, self.__doc__))
|
||||
model_id = cr.fetchone()[0]
|
||||
cr.execute("INSERT INTO ir_model (id,model, name, info,state) VALUES (%s, %s, %s, %s,%s)", (model_id, self._name, self._description, self.__doc__, 'base'))
|
||||
if 'module' in context:
|
||||
cr.execute("INSERT INTO ir_model_data (name,date_init,date_update,module,model,res_id) VALUES (%s, now(), now(), %s, %s, %s)", \
|
||||
('model_'+self._name.replace('.','_'), context['module'], 'ir.model', id)
|
||||
('model_'+self._name.replace('.','_'), context['module'], 'ir.model', model_id)
|
||||
)
|
||||
else:
|
||||
model_id = cr.fetchone()[0]
|
||||
cr.commit()
|
||||
|
||||
cr.execute("SELECT * FROM ir_model_fields WHERE model=%s", (self._name,))
|
||||
|
@ -319,9 +321,6 @@ class orm_template(object):
|
|||
for rec in cr.dictfetchall():
|
||||
cols[rec['name']] = rec
|
||||
|
||||
cr.execute("SELECT id FROM ir_model WHERE model='%s'" % self._name)
|
||||
model_id = cr.fetchone()[0]
|
||||
|
||||
for (k, f) in self._columns.items():
|
||||
vals = {
|
||||
'model_id': model_id,
|
||||
|
@ -1030,6 +1029,9 @@ class orm_template(object):
|
|||
xml += "<newline/>"
|
||||
xml += "</form>"
|
||||
elif view_type == 'tree':
|
||||
_rec_name = self._rec_name
|
||||
if _rec_name not in self._columns:
|
||||
_rec_name = self._columns.keys()[0]
|
||||
xml = '''<?xml version="1.0" encoding="utf-8"?>''' \
|
||||
'''<tree string="%s"><field name="%s"/></tree>''' \
|
||||
% (self._description, self._rec_name)
|
||||
|
|
Loading…
Reference in New Issue