Change for the View

Implement the Create operation for the Server Action

bzr revid: mga@tinyerp.com-20080826085110-1jrladvftq7hs45k
This commit is contained in:
mga@tinyerp.com 2008-08-26 14:21:10 +05:30
parent a33736084a
commit 570f34b49f
2 changed files with 15 additions and 4 deletions

View File

@ -1065,7 +1065,7 @@
<page string="Create / Write" attrs="{'invisible':[('state','=','python'),('state','=','dummy'),('state','=','trigger'), ('state','=','sms'), ('state','=','email'), ('state','=','client_action'), ('state','=','other')]}">
<separator colspan="4" string="Fields Mapping"/>
<field name="srcmodel_id" select="2"/>
<field name="srcmodel_id" select="2" attrs="{'invisible':[('state','!=','object_create')]}"/>
<field name="fields_lines" nolabel="1" select="2" colspan="4">
<tree string="Field Mappings" editable="top">
<field name="col1" domain="[('model_id','=',parent.srcmodel_id)]"/>
@ -1075,7 +1075,7 @@
<form string="Field Mapping">
<field name="col1" domain="[('model_id','=',parent.srcmodel_id)]"/>
<field name="type"/>
<field name="value" colapsn="4"/>
<field name="value" colsapan="4"/>
</form>
</field>
</page>

View File

@ -380,7 +380,7 @@ class actions_server(osv.osv):
'child_ids': fields.one2many('ir.actions.actions', 'parent_id', 'Others Actions'),
'usage': fields.char('Action Usage', size=32),
'type': fields.char('Report Type', size=32, required=True),
'srcmodel_id': fields.many2one('ir.model', 'Model', required=True),
'srcmodel_id': fields.many2one('ir.model', 'Model'),
'fields_lines': fields.one2many('ir.server.object.lines', 'server_id', 'Fields Mapping'),
}
_defaults = {
@ -522,7 +522,18 @@ class actions_server(osv.osv):
obj_pool.write(cr, uid, [context.get('active_id')], res)
if action.state == 'object_create':
pass
res = {}
for exp in action.fields_lines:
euq = exp.value
if exp.type == 'equation':
expr = self.merge_message(cr, uid, euq, action, context)
expr = eval(expr)
else:
expr = exp.value
res[exp.col1.name] = expr
obj_pool = self.pool.get(action.model_id.model)
id = context.get('active_id')
obj_pool.copy(cr, uid, id, res)
return False
actions_server()