源代码位置:openerp/addons/base/ir/ir_actions.py
根类型:ir.actions.actions
1 class actions(osv.osv): 2 _name = 'ir.actions.actions' 3 _table = 'ir_actions' 4 _order = 'name' 5 _columns = { 6 'name': fields.char('Name', required=True), 7 'type': fields.char('Action Type', required=True), 8 'usage': fields.char('Action Usage'), 9 'help': fields.text('Action description', 10 help='Optional help text for the users with a description of the target view, such as its usage and purpose.', 11 translate=True), 12 }
继承自ir.actions.actions 的类型有:ir.actions.report.xml,ir.actions.act_window,ir.actions.act_window_close,ir.actions.act_url,ir.actions.server,ir.actions.client 6种
1 .ir.actions.report.xml :用于打印报表的动作 在定义中可知,8.0中支持的报表类型有以下几种:
1 'report_type': fields.selection([('qweb-pdf', 'PDF'), 2 ('qweb-html', 'HTML'), 3 ('controller', 'Controller'), 4 ('pdf', 'RML pdf (deprecated)'), 5 ('sxw', 'RML sxw (deprecated)'), 6 ('webkit', 'Webkit (deprecated)'), 7 ],
2.ir.actions.act_window:用于展现页面的动作
1 'name': fields.char('Action Name', required=True, translate=True), 2 'type': fields.char('Action Type', required=True), 3 'view_id': fields.many2one('ir.ui.view', 'View Ref.', ondelete='set null'), 4 'domain': fields.char('Domain Value', 5 help="Optional domain filtering of the destination data, as a Python expression"), 6 'context': fields.char('Context Value', required=True, 7 help="Context dictionary as Python expression, empty by default (Default: {})"), 8 'res_id': fields.integer('Record ID', help="Database ID of record to open in form view, when ``view_mode`` is set to 'form' only"), 9 'res_model': fields.char('Destination Model', required=True, 10 help="Model name of the object to open in the view window"), 11 'src_model': fields.char('Source Model', 12 help="Optional model name of the objects on which this action should be visible"), 13 'target': fields.selection([('current','Current Window'),('new','New Window'),('inline','Inline Edit'),('inlineview','Inline View')], 'Target Window'), 14 'view_mode': fields.char('View Mode', required=True, 15 help="Comma-separated list of allowed view modes, such as 'form', 'tree', 'calendar', etc. (Default: tree,form)"), 16 'view_type': fields.selection((('tree','Tree'),('form','Form')), string='View Type', required=True, 17 help="View type: Tree type to use for the tree view, set to 'tree' for a hierarchical tree view, or 'form' for a regular list view"), 18 'usage': fields.char('Action Usage', 19 help="Used to filter menu and home actions from the user form."), 20 'view_ids': fields.one2many('ir.actions.act_window.view', 'act_window_id', 'Views'), 21 'views': fields.function(_views_get_fnc, type='binary', string='Views', 22 help="This function field computes the ordered list of views that should be enabled " \ 23 "when displaying the result of an action, federating view mode, views and " \ 24 "reference view. The result is returned as an ordered list of pairs (view_id,view_mode)."), 25 'limit': fields.integer('Limit', help='Default limit for the list view'), 26 'auto_refresh': fields.integer('Auto-Refresh', 27 help='Add an auto-refresh on the view'), 28 'groups_id': fields.many2many('res.groups', 'ir_act_window_group_rel', 29 'act_id', 'gid', 'Groups'), 30 'search_view_id': fields.many2one('ir.ui.view', 'Search View Ref.'), 31 'filter': fields.boolean('Filter'), 32 'auto_search':fields.boolean('Auto Search'), 33 'search_view' : fields.function(_search_view, type='text', string='Search View'), 34 'multi': fields.boolean('Restrict to lists', help="If checked and the action is bound to a model, it will only appear in the More menu on list views"), 35 }
比较重要的列:
target:current(在当前页面显示),new(在新页面中显示,即弹窗方式),inline(内嵌),inlineview(内嵌视图).
view_mode:视图模式 可选值:tree,form,graph,calendar,gantt,kanban
view_type:视图类型 可选值:tree,form tree是指分层的树形视图,form是传统的列表类型
view_ids:指定绑定的视图id
limit:指定默认列表视图的显示行数
multi:True 如果绑定了model,将只在列表视图的more按钮列表中显示.
3.ir.actions.act_window_close
关闭窗口的动作
4.ir.actions.act_url
1 _name = 'ir.actions.act_url' 2 _table = 'ir_act_url' 3 _inherit = 'ir.actions.actions' 4 _sequence = 'ir_actions_id_seq' 5 _order = 'name' 6 _columns = { 7 'name': fields.char('Action Name', required=True, translate=True), 8 'type': fields.char('Action Type', required=True), 9 'url': fields.text('Action URL',required=True), 10 'target': fields.selection(( 11 ('new', 'New Window'), 12 ('self', 'This Window')), 13 'Action Target', required=True 14 ) 15 } 16 _defaults = { 17 'type': 'ir.actions.act_url', 18 'target': 'new' 19 }
暂不清楚,还没遇见过,应该是指定URL跳转之类的动作
5.ir.actions.server
执行服务器动作:可用的动作包括
执行python代码块,触发工作流,执行客户端动作,创建并复制一条新记录,修改记录,执行多个服务器动作等.
可以利用ir.actions.server在视图的more加入自定义按钮.
6.ir.actions.client
1 _columns = { 2 'name': fields.char('Action Name', required=True, translate=True), 3 'tag': fields.char('Client action tag', required=True, 4 help="An arbitrary string, interpreted by the client" 5 " according to its own needs and wishes. There " 6 "is no central tag repository across clients."), 7 'res_model': fields.char('Destination Model', 8 help="Optional model, mostly used for needactions."), 9 'context': fields.char('Context Value', required=True, 10 help="Context dictionary as Python expression, empty by default (Default: {})"), 11 'params': fields.function(_get_params, fnct_inv=_set_params, 12 type='binary', 13 string="Supplementary arguments", 14 help="Arguments sent to the client along with" 15 "the view tag"), 16 'params_store': fields.binary("Params storage", readonly=True) 17 } 18 _defaults = { 19 'type': 'ir.actions.client', 20 'context': '{}', 21 22 }
客户端动作