diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/addons/base/ir/ir.xml | 8 | ||||
| -rwxr-xr-x | bin/addons/base/ir/ir_actions.py | 18 |
2 files changed, 16 insertions, 10 deletions
diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml index 2492f70d37d..d16402f9bc7 100755 --- a/bin/addons/base/ir/ir.xml +++ b/bin/addons/base/ir/ir.xml @@ -1066,15 +1066,15 @@ <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="otype"/> - <field name="srcmodel_id" select="2" attrs="{'readonly':[('type','!=','new'),('type','!=','object_create')]}"/> + <field name="srcmodel_id" select="2" attrs="{'readonly':[('type','=','copy'),('state','=','write_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)]"/> + <field name="col1" domain="[('model_id','=',parent.srcmodel_id or parent.model_id)]"/> <field name="type"/> - <field name="value"/> + <field name="value" colsapan="4"/> </tree> <form string="Field Mapping"> - <field name="col1" domain="[('model_id','=',parent.srcmodel_id)]"/> + <field name="col1" domain="[('model_id','=',parent.srcmodel_id or parent.model_id)]"/> <field name="type"/> <field name="value" colsapan="4"/> </form> diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 38a30888929..78abfa54ed0 100755 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -385,7 +385,7 @@ class actions_server(osv.osv): 'otype': fields.selection([ ('copy','Create in Same Model'), ('new','Create in Other Model') - ], 'Create Model', required=True, size=32, change_default=True), + ], 'Create Model', size=32, change_default=True), } _defaults = { 'state': lambda *a: 'dummy', @@ -399,7 +399,8 @@ class actions_server(osv.osv): # - uid # - ids # If you plan to return an action, assign: action = {...} -""" +""", + 'otype': lambda *a: 'copy', } def get_field_value(self, cr, uid, action, context): @@ -496,7 +497,6 @@ class actions_server(osv.osv): logger.notifyChannel('sms', netsvc.LOG_INFO, 'SMS successfully send to : %s' % (action.address)) else: logger.notifyChannel('sms', netsvc.LOG_ERROR, 'Failed to send SMS to : %s' % (action.address)) - if action.state == 'other': localdict = { 'self': self.pool.get(action.model_id.model), @@ -535,9 +535,15 @@ class actions_server(osv.osv): 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) + + 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) return False actions_server() |
