From bfcbb3f6198220e83a45b5d71ea6e8a07a8e288d Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 5 Feb 2013 17:10:02 +0100 Subject: [PATCH] [IMP] crm: dynamic_help bzr revid: chm@openerp.com-20130205161002-3dxect9a9x43852z --- addons/crm/crm_lead.py | 24 ++++++++++++++++++++++++ addons/project/project.py | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 4455663ca9a..d675753bcb2 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -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, _("
You can also create opportunities by sending an email to: %s
" % alias_txt)) + else: + help = "%s %s" % (help, _("
You can also create lead by sending an email to: %s
" % alias_txt)) + return help + def create(self, cr, uid, vals, context=None): if context is None: context = {} diff --git a/addons/project/project.py b/addons/project/project.py index 244def53c47..91dfc858113 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -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, _("
You can also create documents by sending an email to: %s
" % alias_txt)) + help = "%s %s" % (help, _("
You can also create tasks by sending an email to: %s
" % alias_txt)) return help # ----------------------------------------