* small change in the implementation of the object_create method

* change the condition in view

bzr revid: mga@tinyerp.com-20080901114801-6fe3wxchh5rq1o8o
This commit is contained in:
mga@tinyerp.com 2008-09-01 17:18:01 +05:30
parent 792ef8f269
commit 9906420093
2 changed files with 16 additions and 10 deletions

View File

@ -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>

View File

@ -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()