Odoo ir actions分析

31506 ワード

ソースコードの場所: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_Windows:ページを表示するためのアクション
 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モデルをバインドと、リストビューの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
≪サーバー・アクションの実行|Perform Server Action|ldap≫:使用可能なアクションは次のとおりです.
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     }

クライアントアクション