diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index ee458ca0076..39ffeb70eed 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -205,7 +205,7 @@ class account_analytic_account(osv.osv): def check_recursion(self, cr, uid, ids, parent=None): return super(account_analytic_account, self)._check_recursion(cr, uid, ids, parent=parent) - _order = 'date_start desc,parent_id desc,code' + _order = 'name asc' _constraints = [ (check_recursion, 'Error! You can not create recursive analytic accounts.', ['parent_id']), ] diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index f7b70ca9921..fb3a8f5e223 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -98,6 +98,27 @@ class crm_lead(crm_case, osv.osv): res[lead.id][field] = abs(int(duration)) return res + def _history_search(self, cr, uid, obj, name, args, context=None): + res = [] + msg_obj = self.pool.get('mailgate.message') + message_ids = msg_obj.search(cr, uid, [('history','=',True), ('name', args[0][1], args[0][2])], context=context) + lead_ids = self.search(cr, uid, [('message_ids', 'in', message_ids)], context=context) + + if lead_ids: + return [('id', 'in', lead_ids)] + else: + return [('id', '=', '0')] + + def _get_email_subject(self, cr, uid, ids, fields, args, context=None): + res = {} + for obj in self.browse(cr, uid, ids, context=context): + res[obj.id] = '' + for msg in obj.message_ids: + if msg.history: + res[obj.id] = msg.name + break + return res + _columns = { # Overridden from res.partner.address: 'partner_id': fields.many2one('res.partner', 'Partner', ondelete='set null', @@ -149,6 +170,7 @@ class crm_lead(crm_case, osv.osv): \nWhen the case is over, the state is set to \'Done\'.\ \nIf the case needs to be reviewed then the state is set to \'Pending\'.'), 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]), + 'subjects': fields.function(_get_email_subject, fnct_search=_history_search, string='Subject of Email', method=True, type='char', size=64), } @@ -289,17 +311,6 @@ class crm_lead(crm_case, osv.osv): self.log(cr, uid, case.id, message) return super(crm_lead,self).write(cr, uid, ids, vals, context) - def stage_historize(self, cr, uid, ids, stage, context=None): - stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context) - self.history(cr, uid, ids, _('Stage'), details=stage_obj.name) - for case in self.browse(cr, uid, ids, context=context): - if case.type == 'lead': - message = _("The stage of lead '%s' has been changed to '%s'.") % (case.name, stage_obj.name) - elif case.type == 'opportunity': - message = _("The stage of opportunity '%s' has been changed to '%s'.") % (case.name, stage_obj.name) - self.log(cr, uid, case.id, message) - return True - def stage_next(self, cr, uid, ids, context=None): stage = super(crm_lead, self).stage_next(cr, uid, ids, context=context) if stage: diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 2ea72155dbe..55be89c2252 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -183,7 +183,7 @@ - + + Forward to Partner crm.lead.forward.to.partner form form - + new + + + crm.new.mass.forward.mail.form + crm.lead.mass.forward.to.partner + form + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +