diff --git a/addons/account/account.py b/addons/account/account.py index 6aa47551a98..45d3cb4377c 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2684,6 +2684,15 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'position_id' : new_fp, } obj_ac_fp.create(cr, uid, vals_acc) + + #fially inactive the demo chart of accounts + data_id = data_pool.search(cr, uid, [('model','=','account.account'), ('name','=','chart0')]) + if data_id: + data = data_pool.browse(cr, uid, data_id[0]) + account_id = data.res_id + if account_id: + cr.execute("update account_account set active='f' where id=%s" % (account_id)) + wizard_multi_charts_accounts() class account_bank_accounts_wizard(osv.osv_memory): diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 6fe0182b584..e9c66c3036d 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -207,7 +207,7 @@ + + Forward to Partner crm.lead.forward.to.partner form form + new diff --git a/addons/crm/wizard/crm_send_email.py b/addons/crm/wizard/crm_send_email.py index bc2b5357c15..58aa729e454 100644 --- a/addons/crm/wizard/crm_send_email.py +++ b/addons/crm/wizard/crm_send_email.py @@ -20,11 +20,12 @@ # ############################################################################## +from crm import crm from osv import osv, fields from tools.translate import _ import base64 +import itertools import tools -from crm import crm class crm_send_new_email_attachment(osv.osv_memory): _name = 'crm.send.mail.attachment' @@ -49,29 +50,23 @@ class crm_send_new_email(osv.osv_memory): 'email_cc' : fields.char('CC', size=512, help="Carbon Copy: list of recipients that will receive"\ " a copy of this mail, and future communication related to this case"), 'subject': fields.char('Subject', size=512, required=True), - 'text': fields.text('Message', required=True), + 'body': fields.text('Message Body', required=True), 'state': fields.selection(crm.AVAILABLE_STATES, string='Set New State To', required=True), 'attachment_ids' : fields.one2many('crm.send.mail.attachment', 'wizard_id'), } - def action_cancel(self, cr, uid, ids, context=None): - """ Closes Phonecall to Opportunity form - """ - return {'type':'ir.actions.act_window_close'} - def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """ - hist_obj = self.pool.get('mailgate.message') if not context: context = {} - if not context.get('model'): + if not context.get('active_model'): raise osv.except_osv(_('Error'), _('Can not send mail!')) - model = context.get('model') + model = context.get('active_model') case_pool = self.pool.get(model) res_id = context and context.get('active_id', False) or False @@ -83,24 +78,38 @@ class crm_send_new_email(osv.osv_memory): message_id = None ref_id = None - case = case_pool.browse(cr, uid, res_id) + case = case_pool.browse(cr, uid, res_id, context=context) if context.get('mail', 'new') == 'new': if case.message_ids: message_id = case.message_ids[0].message_id + elif context.get('mail') == 'forward': + # extract attachements from case and emails according to mode + attachments = [] + attach_pool = self.pool.get('ir.attachment') + direct_attachments = attach_pool.search(cr, uid, [('res_model', '=', 'crm.lead'), ('res_id', '=', res_id)], context=context) + attachments += attach_pool.browse(cr, uid, direct_attachments, context=context) + if obj.history in ['latest', 'whole'] and case.message_ids: + msgs = case.message_ids + if obj.history == 'latest': + msgs = msgs[:1] + attachments.extend(itertools.chain(*[m.attachment_ids for m in msgs])) + attach_all = [(a.datas_fname or a.name, base64.decodestring(a.datas)) for a in attachments if a.datas] + attach += attach_all + else: - hist = hist_obj.browse(cr, uid, res_id) + hist = hist_obj.browse(cr, uid, res_id, context=context) message_id = hist.message_id model = hist.model - model_pool = self.pool.get(model) + case_pool = self.pool.get(model) res_id = hist.res_id ref_id = hist.ref_id - case = model_pool.browse(cr, uid, res_id) + case = case_pool.browse(cr, uid, res_id, context=context) emails = [obj.email_to] email_cc = obj.email_cc and obj.email_cc.split(',') or '' emails = filter(None, emails) - body = obj.text + body = obj.body - body = case_pool.format_body(body) + body = body and tools.ustr(body) or '' email_from = getattr(obj, 'email_from', False) x_headers = {} if message_id: @@ -121,10 +130,11 @@ class crm_send_new_email(osv.osv_memory): if not flag: raise osv.except_osv(_('Error!'), _('Unable to send mail. Please check SMTP is configured properly.')) - case_pool.history(cr, uid, [case], _('Send'), history=True, \ + msg_dict = {'new': 'Send', 'reply': 'Reply', 'forward': 'Forward'} + case_pool.history(cr, uid, [case], _(msg_dict[context.get('mail', 'new')]), history=True, \ email=obj.email_to, details=body, \ subject=obj.subject, email_from=email_from, \ - email_cc=email_cc, message_id=message_id, \ + email_cc=', '.join(email_cc), message_id=message_id, \ references=ref_id or message_id, attach=attach) if obj.state == 'unchanged': pass @@ -145,7 +155,7 @@ class crm_send_new_email(osv.osv_memory): if not context: context = {} - if not context.get('model'): + if not context.get('active_model'): raise osv.except_osv(_('Error'), _('Can not send mail!')) res = super(crm_send_new_email, self).default_get(cr, uid, fields, context=context) @@ -154,7 +164,7 @@ class crm_send_new_email(osv.osv_memory): res.update(self.get_reply_defaults(cr, uid, fields, context=context)) return res - model = context.get('model') + model = context.get('active_model') mod_obj = self.pool.get(model) res_id = context and context.get('active_ids', []) or [] @@ -172,8 +182,8 @@ class crm_send_new_email(osv.osv_memory): res.update({'subject': tools.ustr(context.get('subject', case.name) or '')}) if 'email_cc' in fields: res.update({'email_cc': tools.ustr(case.email_cc or '')}) - if 'text' in fields: - res.update({'text': u'\n'+(tools.ustr(case.user_id.signature or ''))}) + if 'body' in fields: + res.update({'body': u'\n'+(tools.ustr(case.user_id.signature or ''))}) if 'state' in fields: res.update({'state': u'pending'}) @@ -209,7 +219,7 @@ class crm_send_new_email(osv.osv_memory): signature = u'\n' + (tools.ustr(case.user_id.signature or '')) + u'\n' original = [signature] - if include_original == True and 'text' in fields: + if include_original == True and 'body' in fields: header = u'-------- Original Message --------' sender = u'From: %s' %(tools.ustr(hist.email_from or '')) to = u'To: %s' % (tools.ustr(hist.email_to or '')) @@ -218,10 +228,14 @@ class crm_send_new_email(osv.osv_memory): original = [signature, header, sender, to, sentdate, desc] - res['text']= u'\n' + u'\n'.join(original) + res['body']= u'\n' + u'\n'.join(original) if 'subject' in fields: res.update({u'subject': u'Re: %s' %(tools.ustr(hist.name or ''))}) + if 'email_cc' in fields: + res.update({'email_cc': case.email_cc and tools.ustr(case.email_cc) or False}) + if 'reply_to' in fields: + res.update({'reply_to': case.section_id.reply_to}) if 'state' in fields: res['state'] = u'pending' return res @@ -239,7 +253,7 @@ class crm_send_new_email(osv.osv_memory): if not context: context = {} - if not context.get('model'): + if not context.get('active_model'): raise osv.except_osv(_('Error'), _('Can not send mail!')) return True diff --git a/addons/crm/wizard/crm_send_email_view.xml b/addons/crm/wizard/crm_send_email_view.xml index df7218cbc02..77202a19f6c 100644 --- a/addons/crm/wizard/crm_send_email_view.xml +++ b/addons/crm/wizard/crm_send_email_view.xml @@ -9,7 +9,7 @@ crm.send.mail form -
+ @@ -19,7 +19,7 @@ - + @@ -36,7 +36,7 @@ -