From 5ee1dff04cca5d6c0dd502208d432ea1a890b54a Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Thu, 11 Dec 2008 20:31:47 +0530 Subject: [PATCH] improvement in the server action bzr revid: mga@tinyerp.com-20081211150147-5j2bnp04h3g640bq --- bin/addons/base/ir/ir.xml | 4 ++-- bin/addons/base/ir/ir_actions.py | 27 +++++++++++++-------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml index fa541535dd7..4230d63c0b7 100644 --- a/bin/addons/base/ir/ir.xml +++ b/bin/addons/base/ir/ir.xml @@ -1177,8 +1177,7 @@ - - + @@ -1191,6 +1190,7 @@ + diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index fb7b187e92c..0bd04398bb9 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -396,10 +396,7 @@ class actions_server(osv.osv): 'type': fields.char('Report Type', size=32, required=True), 'srcmodel_id': fields.many2one('ir.model', 'Model'), 'fields_lines': fields.one2many('ir.server.object.lines', 'server_id', 'Fields Mapping'), - 'otype': fields.selection([ - ('copy','Create in Same Model'), - ('new','Create in Other Model') - ], 'Create Model', size=32, change_default=True), + 'record_id':fields.many2one('ir.model.fields', 'Record Id') } _defaults = { 'state': lambda *a: 'dummy', @@ -414,7 +411,6 @@ class actions_server(osv.osv): # - ids # If you plan to return an action, assign: action = {...} """, - 'otype': lambda *a: 'copy', } @@ -558,9 +554,15 @@ class actions_server(osv.osv): else: expr = exp.value res[exp.col1.name] = expr - obj_pool = self.pool.get(action.model_id.model) - obj_pool.write(cr, uid, [context.get('active_id')], res) + if not action.srcmodel_id: + obj_pool = self.pool.get(action.model_id.model) + obj_pool.write(cr, uid, [context.get('active_id')], res) + else: + obj_pool = self.pool.get(action.srcmodel_id.model) + id = self.pool.get(action.model_id.model).read(cr, uid, [context.get('active_id')], [action.record_id.name]) + obj_pool.write(cr, uid, [int(id[0][action.record_id.name])], res) + if action.state == 'object_create': res = {} for exp in action.fields_lines: @@ -574,13 +576,10 @@ class actions_server(osv.osv): res[exp.col1.name] = expr obj_pool = None - if action.state == 'object_create' and action.otype == 'new': - obj_pool = self.pool.get(action.srcmodel_id.model) - obj_pool.create(cr, uid, res) - else: - obj_pool = self.pool.get(action.model_id.model) - id = context.get('active_id') - obj_pool.copy(cr, uid, id, res) + res_id = False + obj_pool = self.pool.get(action.srcmodel_id.model) + res_id = obj_pool.create(cr, uid, res) + self.pool.get(action.model_id.model).write(cr, uid, [context.get('active_id')], {action.record_id.name:res_id}) return False actions_server()