Merge lp:~openerp-dev/openobject-server/trunk-many2oneview-dle into lp:openobject-server

Proposed by Denis Ledoux (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-server/trunk-many2oneview-dle
Merge into: lp:openobject-server
Diff against target: 35 lines (+25/-0)
1 file modified
openerp/osv/orm.py (+25/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-many2oneview-dle
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+207241@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

5081. By Denis Ledoux (OpenERP)

[ADD] orm: move method get_formview_action from mail to orm, add factorised method get_formview_id, to add the possibility to open a specific view_id depending on the model

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/osv/orm.py'
2--- openerp/osv/orm.py 2014-02-14 14:52:19 +0000
3+++ openerp/osv/orm.py 2014-02-19 16:28:18 +0000
4@@ -1906,6 +1906,31 @@
5 }
6 return result
7
8+ def get_formview_id(self, cr, uid, id, context=None):
9+ """ Return an view id to open the document with. This method is meant to be
10+ overridden in addons that want to give specific view ids for example.
11+
12+ :param int id: id of the document to open
13+ """
14+ return False
15+
16+ def get_formview_action(self, cr, uid, id, context=None):
17+ """ Return an action to open the document. This method is meant to be
18+ overridden in addons that want to give specific view ids for example.
19+
20+ :param int id: id of the document to open
21+ """
22+ view_id = self.get_formview_id(cr, uid, id, context=context)
23+ return {
24+ 'type': 'ir.actions.act_window',
25+ 'res_model': self._name,
26+ 'view_type': 'form',
27+ 'view_mode': 'form',
28+ 'views': [(view_id, 'form')],
29+ 'target': 'current',
30+ 'res_id': id,
31+ }
32+
33 def _view_look_dom_arch(self, cr, uid, node, view_id, context=None):
34 return self['ir.ui.view'].postprocess_and_fields(
35 cr, uid, self._name, node, view_id, context=context)