summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormga@tinyerp.com <>2008-09-01 17:48:01 +0530
committermga@tinyerp.com <>2008-09-01 17:48:01 +0530
commitf58ce8d7b0184b1cb5fbbefd00e5dd86bde80bfc (patch)
tree6dc2fe3c10d5ac6fcbc6c6482e1367a75b22673e
parent42cbad9d4fc1f42330a6ad7838a4833000e0e4d7 (diff)
parent99064200930c5fd6d46f2d6a44dbc7a0b879b8d3 (diff)
merging the server action changes for the mga's branch
bzr revid: mga@tinyerp.com-20080901121801-ewcusp446tzwd6xo
-rwxr-xr-xbin/addons/base/ir/ir.xml8
-rwxr-xr-xbin/addons/base/ir/ir_actions.py18
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()