[ADD] *: replace overriden methods get_formview_action by get_formview_id

Methods to override to specify the view/action to launch for many2one links
get_formview_action use get_formview_id to find the view to open. Therefore, it is simplier to override get_formview_id to tell which view should be opened

bzr revid: dle@openerp.com-20140416143755-07slguqn6zadqsg5
This commit is contained in:
Denis Ledoux 2014-04-16 16:37:55 +02:00
parent ecd96fc0a6
commit 75850c8f95
3 changed files with 7 additions and 40 deletions

View File

@ -672,25 +672,14 @@ class account_invoice(osv.osv):
self.create_workflow(cr, uid, ids)
return True
# ----------------------------------------
# Mail related methods
# ----------------------------------------
def _get_formview_action(self, cr, uid, id, context=None):
def get_formview_id(self, cr, uid, id, context=None):
""" Update form view id of action to open the invoice """
action = super(account_invoice, self)._get_formview_action(cr, uid, id, context=context)
obj = self.browse(cr, uid, id, context=context)
if obj.type == 'in_invoice':
model, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'invoice_supplier_form')
action.update({
'views': [(view_id, 'form')],
})
else:
model, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'invoice_form')
action.update({
'views': [(view_id, 'form')],
})
return action
return view_id
# Workflow stuff
#################

View File

@ -972,15 +972,13 @@ class crm_lead(format_address, osv.osv):
return [lead.section_id.message_get_reply_to()[0] if lead.section_id else False
for lead in self.browse(cr, SUPERUSER_ID, ids, context=context)]
def _get_formview_action(self, cr, uid, id, context=None):
action = super(crm_lead, self)._get_formview_action(cr, uid, id, context=context)
def get_formview_id(self, cr, uid, id, context=None):
obj = self.browse(cr, uid, id, context=context)
if obj.type == 'opportunity':
model, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'crm_case_form_view_oppor')
action.update({
'views': [(view_id, 'form')],
})
return action
else:
view_id = super(crm_lead, self).get_formview_id(cr, uid, id, model=model, context=context)
return view_id
def message_get_suggested_recipients(self, cr, uid, ids, context=None):
recipients = super(crm_lead, self).message_get_suggested_recipients(cr, uid, ids, context=context)

View File

@ -588,23 +588,6 @@ class mail_thread(osv.AbstractModel):
model_obj.check_access_rights(cr, uid, check_operation)
model_obj.check_access_rule(cr, uid, mids, check_operation, context=context)
def _get_formview_action(self, cr, uid, id, model=None, 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
:param string model: specific model that overrides self._name
"""
return {
'type': 'ir.actions.act_window',
'res_model': model or self._name,
'view_type': 'form',
'view_mode': 'form',
'views': [(False, 'form')],
'target': 'current',
'res_id': id,
}
def _get_inbox_action_xml_id(self, cr, uid, context=None):
""" When redirecting towards the Inbox, choose which action xml_id has
to be fetched. This method is meant to be inherited, at least in portal
@ -647,10 +630,7 @@ class mail_thread(osv.AbstractModel):
if model_obj.check_access_rights(cr, uid, 'read', raise_exception=False):
try:
model_obj.check_access_rule(cr, uid, [res_id], 'read', context=context)
if not hasattr(model_obj, '_get_formview_action'):
action = self.pool.get('mail.thread')._get_formview_action(cr, uid, res_id, model=model, context=context)
else:
action = model_obj._get_formview_action(cr, uid, res_id, context=context)
action = model_obj.get_formview_action(cr, uid, res_id, context=context)
except (osv.except_osv, orm.except_orm):
pass
action.update({