parent
7650d15b17
commit
395071a27e
|
@ -1,6 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Values -->
|
||||
|
||||
<record id="values_view_form_action" model="ir.ui.view">
|
||||
<field name="name">ir.values.form.action</field>
|
||||
<field name="model">ir.values</field>
|
||||
<field name="type">form</field>
|
||||
<field name="priority">20</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Connect Events to Actions">
|
||||
<field name="name" select="1" required="1"/>
|
||||
<newline/>
|
||||
<group col="2" colspan="2">
|
||||
<separator string="Action Source" colspan="2"/>
|
||||
<field name="model_id" on_change="onchange_object_id(model_id)"/>
|
||||
<field name="model" select="1" required="1"/>
|
||||
<field name="res_id"/>
|
||||
<field name="key2" select="2" required="1"/>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<separator string="Action To Launch" colspan="2"/>
|
||||
<field name="action_id" on_change="onchange_action_id(action_id)"/>
|
||||
<field name="value_unpickle" required="1"/>
|
||||
<field name="object" readonly="1"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="act_values_form_action" model="ir.actions.act_window">
|
||||
<field name="name">Connect Actions To Client Events</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">ir.values</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form,tree</field>
|
||||
<field name="view_id" ref="values_view_form_action"/>
|
||||
<field name="domain">[('key','=','action')]</field>
|
||||
<field name="context">{'read':'default','default_object':1}</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="act_values_form_action" id="menu_values_form_action" parent="base.menu_custom_action"/>
|
||||
|
||||
|
||||
<!-- Values -->
|
||||
|
||||
|
|
|
@ -49,19 +49,45 @@ class ir_values(osv.osv):
|
|||
value = pickle.dumps(eval(value))
|
||||
self.write(cursor, user, id, {name[:-9]: value}, context=ctx)
|
||||
|
||||
def onchange_object_id(self, cr, uid, ids, object_id, context={}):
|
||||
if not object_id: return {}
|
||||
act = self.pool.get('ir.model').browse(cr, uid, object_id, context=context)
|
||||
return {
|
||||
'value': {'model': act.model}
|
||||
}
|
||||
|
||||
def onchange_action_id(self, cr, uid, ids, action_id, context={}):
|
||||
if not action_id: return {}
|
||||
act = self.pool.get('ir.actions.actions').browse(cr, uid, action_id, context=context)
|
||||
return {
|
||||
'value': {'value_unpickle': act.type+','+str(act.id)}
|
||||
}
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=128),
|
||||
'model': fields.char('Object', size=128),
|
||||
'model_id': fields.many2one('ir.model', 'Object', size=128,
|
||||
help="This field is not used, it only helps you to select a good model."),
|
||||
'model': fields.char('Object Name', size=128),
|
||||
'action_id': fields.many2one('ir.actions.actions', 'Action',
|
||||
help="This field is not used, it only helps you to select the right action."),
|
||||
'value': fields.text('Value'),
|
||||
'value_unpickle': fields.function(_value_unpickle, fnct_inv=_value_pickle,
|
||||
method=True, type='text', string='Value'),
|
||||
'object': fields.boolean('Is Object'),
|
||||
'key': fields.char('Type', size=128),
|
||||
'key2': fields.char('Value', size=256),
|
||||
'key': fields.selection([('action','Action'),('default','Default')], 'Type', size=128),
|
||||
'key2': fields.selection([
|
||||
('client_action_multi', 'Wizard in Forms'),
|
||||
('client_action_relate', 'Relate on Object'),
|
||||
('client_print_multi', 'Print'),
|
||||
('tree_but_action', 'Wizard in Tree'),
|
||||
('tree_but_open', 'Open on Tree'),
|
||||
('','/')
|
||||
], string='Event Type', size=256,
|
||||
help="The kind of action or button in the client side that will trigger the action."),
|
||||
'meta': fields.text('Meta Datas'),
|
||||
'meta_unpickle': fields.function(_value_unpickle, fnct_inv=_value_pickle,
|
||||
method=True, type='text', string='Meta Datas'),
|
||||
'res_id': fields.integer('Resource ID'),
|
||||
'res_id': fields.integer('Object ID', help="Keep 0 if the action must appear on all resources."),
|
||||
'user_id': fields.many2one('res.users', 'User', ondelete='cascade'),
|
||||
'company_id': fields.many2one('res.company', 'Company')
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ class Cursor(object):
|
|||
|
||||
@check
|
||||
def execute(self, query, params=None):
|
||||
self.count+=1
|
||||
if params is None:
|
||||
params=()
|
||||
if not isinstance(params, (tuple, list)):
|
||||
|
|
Loading…
Reference in New Issue