[IMP] crm: dynamic_help
authorChristophe Matthieu <chm@openerp.com>
Tue, 5 Feb 2013 16:10:02 +0000 (17:10 +0100)
committerChristophe Matthieu <chm@openerp.com>
Tue, 5 Feb 2013 16:10:02 +0000 (17:10 +0100)
bzr revid: chm@openerp.com-20130205161002-3dxect9a9x43852z

addons/crm/crm_lead.py
addons/project/project.py

index 4455663..d675753 100644 (file)
@@ -84,6 +84,30 @@ class crm_lead(base_stage, format_address, osv.osv):
         },
     }
 
+    def dynamic_help(self, cr, uid, help, context=None):
+        alias_txt = ""
+        if context.get('default_section_id'):
+            project_id = self.pool.get('crm.case.section').browse(cr, uid, context.get('default_section_id'), context=context)
+            alias = project_id.alias_id and project_id.alias_id.name_get() or False
+            if alias and alias[0] and alias[0][1]:
+                alias_txt =  alias[0][1]
+        else:
+            model_id = self.pool.get('ir.model').search(cr, uid, [("model", "=", self._name)], context=context)[0]
+            alias_obj = self.pool.get('mail.alias')
+            alias_nb = 0
+            alias_ids = alias_obj.search(cr, uid, [("alias_model_id", "=", model_id)], context=context, limit=5)
+            if alias_ids:
+                for alias in alias_obj.browse(cr, uid, alias_ids, context=context):
+                    email = "%s@%s" % (alias.alias_name, alias.alias_domain)
+                    alias_txt = "%s%s%s" % (alias_txt, (alias_nb and ", " or " "), email)
+                    alias_nb += 1
+        if alias_txt:
+            if context.get('default_type', False) == "opportunity":
+                help = "%s %s" % (help, _("<div class='oe_view_nocontent_create_alias'>You can also create opportunities by sending an email to: <b>%s</b></div>" % alias_txt))
+            else:
+                help = "%s %s" % (help, _("<div class='oe_view_nocontent_create_alias'>You can also create lead by sending an email to: <b>%s</b></div>" % alias_txt))
+        return help
+
     def create(self, cr, uid, vals, context=None):
         if context is None:
             context = {}
index 244def5..91dfc85 100644 (file)
@@ -908,7 +908,7 @@ class task(base_stage, osv.osv):
                     alias_txt = "%s%s%s" % (alias_txt, (alias_nb and ", " or " "), email)
                     alias_nb += 1
         if alias_txt:
-            help = "%s %s" % (help, _("<div class='oe_view_nocontent_create_alias'>You can also create documents by sending an email to: <b>%s</b></div>" % alias_txt))
+            help = "%s %s" % (help, _("<div class='oe_view_nocontent_create_alias'>You can also create tasks by sending an email to: <b>%s</b></div>" % alias_txt))
         return help
        
     # ----------------------------------------