[IMP] account_invoice: now have its _get_formview_action method. _get_formview_action...
authorThibault Delavallée <tde@openerp.com>
Fri, 26 Apr 2013 14:40:19 +0000 (16:40 +0200)
committerThibault Delavallée <tde@openerp.com>
Fri, 26 Apr 2013 14:40:19 +0000 (16:40 +0200)
bzr revid: tde@openerp.com-20130426144019-w4tq4of7rdkyqbah

addons/account/account_invoice.py
addons/crm/crm_lead.py
addons/mail/mail_thread.py

index c47cf70..701ede7 100644 (file)
@@ -635,6 +635,26 @@ 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):
+        """ 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
+
     # Workflow stuff
     #################
 
index 8724b73..c2ea6f0 100644 (file)
@@ -982,8 +982,8 @@ class crm_lead(base_stage, 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, uid, ids, context=context)]
 
-    def _get_document_action(self, cr, uid, id, context=None):
-        action = super(crm_lead, self)._get_document_action(cr, uid, id, 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)
         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')
index 38a2f86..4af6048 100644 (file)
@@ -449,7 +449,7 @@ class mail_thread(osv.AbstractModel):
         ir_attachment_obj.unlink(cr, uid, attach_ids, context=context)
         return True
 
-    def _get_document_action(self, cr, uid, id, model=None, context=None):
+    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.
 
@@ -498,10 +498,10 @@ class mail_thread(osv.AbstractModel):
             try:
                 model_obj = self.pool.get(msg.model)
                 model_obj.check_access_rule(cr, uid, [msg.res_id], 'read', context=context)
-                if not hasattr(model_obj, '_get_document_action'):
-                    action = self.pool.get('mail.thread')._get_document_action(cr, uid, msg.res_id, model=msg.model, context=context)
+                if not hasattr(model_obj, '_get_formview_action'):
+                    action = self.pool.get('mail.thread')._get_formview_action(cr, uid, msg.res_id, model=msg.model, context=context)
                 else:
-                    action = model_obj._get_document_action(cr, uid, msg.res_id, context=context)
+                    action = model_obj._get_formview_action(cr, uid, msg.res_id, context=context)
             except (osv.except_osv, orm.except_orm):
                 action.update({
                     'context': {