From 42025a6af50991238a2a7e9c42c2b42e748b60a4 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 16 Apr 2014 16:34:31 +0200 Subject: [PATCH] [ADD] osv: add get_formview_action and get_formview_id methods return an action to open the document. This method is meant to be overridden in addons that want to give specific view ids for example bzr revid: dle@openerp.com-20140416143431-syqu1ko74xt04oo5 --- openerp/osv/orm.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 6f3adf66216..a198e013746 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -1915,6 +1915,31 @@ class BaseModel(object): } return result + def get_formview_id(self, cr, uid, id, context=None): + """ Return an view id to open the document with. This method is meant to be + overridden in addons that want to give specific view ids for example. + + :param int id: id of the document to open + """ + return False + + def get_formview_action(self, cr, uid, id, context=None): + """ Return an action to open the document. This method is meant to be + overridden in addons that want to give specific view ids for example. + + :param int id: id of the document to open + """ + view_id = self.get_formview_id(cr, uid, id, context=context) + return { + 'type': 'ir.actions.act_window', + 'res_model': self._name, + 'view_type': 'form', + 'view_mode': 'form', + 'views': [(view_id, 'form')], + 'target': 'current', + 'res_id': id, + } + def _view_look_dom_arch(self, cr, uid, node, view_id, context=None): return self.pool['ir.ui.view'].postprocess_and_fields( cr, uid, self._name, node, view_id, context=context)