Wizard to create menusZZ
bzr revid: fp@tinyerp.com-f46663f5b464d79b413c63ab769edc0e69fa7fa2
This commit is contained in:
parent
0d094852c4
commit
0851792aa9
|
@ -238,7 +238,6 @@ def load_module_graph(cr, graph, status=None, **kwargs):
|
|||
pool = pooler.get_pool(cr.dbname)
|
||||
cr.execute('select * from ir_model where state=%s', ('manual',))
|
||||
for model in cr.dictfetchall():
|
||||
print 'INSTANCIATE', model['model']
|
||||
pool.get('ir.model').instanciate(cr, 1, model['model'], {})
|
||||
|
||||
pool.get('ir.model.data')._process_end(cr, 1, package_todo)
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
],
|
||||
"update_xml" : [
|
||||
"base_update.xml",
|
||||
"ir/wizard/wizard_menu_view.xml",
|
||||
"ir/ir.xml",
|
||||
"ir/workflow/workflow_view.xml",
|
||||
"module/module_data.xml",
|
||||
|
|
|
@ -41,3 +41,4 @@ import ir_translation
|
|||
import ir_exports
|
||||
import workflow
|
||||
import ir_rule
|
||||
import wizard
|
||||
|
|
|
@ -659,32 +659,48 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Model Description">
|
||||
<field name="name" select="1"/>
|
||||
<field name="model" select="1"/>
|
||||
<separator string="Information" colspan="4"/>
|
||||
<field name="info" select="1" colspan="4" nolabel="1"/>
|
||||
<separator string="Fields" colspan="4"/>
|
||||
<field name="field_id" colspan="4" nolabel="1" context="{'manual':True}">
|
||||
<form string="Fields Description">
|
||||
<field name="name" select="1"/>
|
||||
<field name="field_description" select="1" colspan="4"/>
|
||||
<field name="ttype" select="1"/>
|
||||
<field name="relation" select="1"/>
|
||||
<notebook>
|
||||
<page string="Object">
|
||||
<field name="name" select="1"/>
|
||||
<field name="model" select="1"/>
|
||||
<separator string="Fields" colspan="4"/>
|
||||
<field name="field_id" colspan="4" nolabel="1" context="{'manual':True}">
|
||||
<tree string="Fields Description">
|
||||
<field name="name"/>
|
||||
<field name="field_description"/>
|
||||
<field name="ttype"/>
|
||||
<field name="required"/>
|
||||
<field name="readonly"/>
|
||||
<field name="select_level"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
<form string="Fields Description">
|
||||
<field name="name" select="1"/>
|
||||
<field name="field_description" select="1" colspan="4"/>
|
||||
<field name="ttype" select="1"/>
|
||||
<field name="relation" select="1"/>
|
||||
|
||||
<field name="required" select="2"/>
|
||||
<field name="readonly" select="2"/>
|
||||
<field name="required" select="2"/>
|
||||
<field name="readonly" select="2"/>
|
||||
|
||||
<field name="size" select="1"/>
|
||||
<field name="on_delete" select="1"/>
|
||||
<field name="select_level" select="2"/>
|
||||
<field name="translate"/>
|
||||
<field name="selection"/>
|
||||
<field name="domain"/>
|
||||
<field name="state" readonly="1"/>
|
||||
</form>
|
||||
</field>
|
||||
<separator string="Status" colspan="4"/>
|
||||
<field name="state"/>
|
||||
<field name="size" select="1"/>
|
||||
<field name="on_delete" select="1"/>
|
||||
<field name="select_level" select="2"/>
|
||||
<field name="translate"/>
|
||||
<field name="selection"/>
|
||||
<field name="domain"/>
|
||||
<field name="state" readonly="1"/>
|
||||
</form>
|
||||
</field>
|
||||
<separator string="Status" colspan="4"/>
|
||||
<field name="state"/>
|
||||
<group col="2" colspan="2">
|
||||
<button name="%(act_menu_create)d" string="Create a Menu" colspan="2" type="action"/>
|
||||
</group>
|
||||
</page><page string="Information">
|
||||
<field name="info" select="1" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
##############################################################################
|
||||
|
||||
from osv import fields,osv
|
||||
import ir
|
||||
import ir, re
|
||||
import netsvc
|
||||
from osv.orm import except_orm
|
||||
|
||||
|
@ -45,30 +45,42 @@ class ir_model(osv.osv):
|
|||
_description = "Objects"
|
||||
_rec_name = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Model name', size=64, translate=True),
|
||||
'model': fields.char('Object name', size=64, required=True, search=1),
|
||||
'name': fields.char('Model Name', size=64, translate=True, required=True),
|
||||
'model': fields.char('Object Name', size=64, required=True, search=1),
|
||||
'info': fields.text('Information'),
|
||||
'field_id': fields.one2many('ir.model.fields', 'model_id', 'Fields', required=True),
|
||||
'state': fields.selection([('manual','Custom Field'),('base','Base Field')],'Manualy Created',readonly=1),
|
||||
'state': fields.selection([('manual','Custom Object'),('base','Base Field')],'Manualy Created',readonly=1),
|
||||
}
|
||||
_defaults = {
|
||||
'name': lambda *a: 'No Name',
|
||||
'model': lambda *a: 'x_',
|
||||
'state': lambda self,cr,uid,ctx={}: (ctx and ctx.get('manual',False)) and 'manual' or 'base',
|
||||
}
|
||||
|
||||
def _check_model_name(self, cr, uid, ids):
|
||||
for model in self.browse(cr, uid, ids):
|
||||
if model.state=='manual':
|
||||
if not model.model.startswith('x_'):
|
||||
return False
|
||||
if not re.match('^[a-z_A-Z0-9]+$',model.model):
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_model_name, 'The model name must start with x_ and not contain any special character !', ['model']),
|
||||
]
|
||||
def unlink(self, cr, user, ids, context=None):
|
||||
for model in self.browse(cr, user, ids, context):
|
||||
if model.state <> 'manual':
|
||||
raise except_orm('Error', "You can not remove the model '%s' !" %(field.name,))
|
||||
return super(ir_model, self).unlink(cr, user, ids, context)
|
||||
res = super(ir_model, self).unlink(cr, user, ids, context)
|
||||
pooler.restart_pool(cr.dbname)
|
||||
return res
|
||||
|
||||
def create(self, cr, user, vals, context=None):
|
||||
if context and context.get('manual',False):
|
||||
vals['state']='manual'
|
||||
res = super(ir_model,self).create(cr, user, vals, context)
|
||||
if vals.get('state','base')=='manual':
|
||||
if not vals['model'].startswith('x_'):
|
||||
raise except_orm('Error', "Custom models must have an object name that starts with 'x_' !")
|
||||
pooler.restart_pool(cr.dbname)
|
||||
return res
|
||||
|
||||
|
@ -77,8 +89,11 @@ class ir_model(osv.osv):
|
|||
pass
|
||||
x_custom_model._name = model
|
||||
x_custom_model._module = False
|
||||
x_custom_model._rec_name = 'id'
|
||||
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]
|
||||
ir_model()
|
||||
|
||||
class ir_model_fields(osv.osv):
|
||||
|
@ -139,8 +154,9 @@ class ir_model_fields(osv.osv):
|
|||
if vals.get('state','base')=='manual':
|
||||
if not vals['name'].startswith('x_'):
|
||||
raise except_orm('Error', "Custom fields must have a name that starts with 'x_' !")
|
||||
self.pool.get(vals['model']).__init__(self.pool, cr)
|
||||
self.pool.get(vals['model'])._auto_init(cr,{})
|
||||
if self.pool.get(vals['model']):
|
||||
self.pool.get(vals['model']).__init__(self.pool, cr)
|
||||
self.pool.get(vals['model'])._auto_init(cr,{})
|
||||
return res
|
||||
ir_model_fields()
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ class wkf_activity(osv.osv):
|
|||
'split_mode': fields.selection([('XOR', 'Xor'), ('OR','Or'), ('AND','And')], 'Split Mode', size=3, required=True),
|
||||
'join_mode': fields.selection([('XOR', 'Xor'), ('AND', 'And')], 'Join Mode', size=3, required=True),
|
||||
'kind': fields.selection([('dummy', 'Dummy'), ('function', 'Function'), ('subflow', 'Subflow'), ('stopall', 'Stop All')], 'Kind', size=64, required=True),
|
||||
'action': fields.char('Python Action', size=256),
|
||||
'action': fields.text('Python Action'),
|
||||
'action_id': fields.many2one('ir.actions.server', 'Server Action', ondelete='set null'),
|
||||
'flow_start': fields.boolean('Flow Start'),
|
||||
'flow_stop': fields.boolean('Flow Stop'),
|
||||
|
|
Loading…
Reference in New Issue