diff --git a/addons/crm/wizard/crm_add_note.py b/addons/crm/wizard/crm_add_note.py index 80e6fc6cad2..e9919c059db 100644 --- a/addons/crm/wizard/crm_add_note.py +++ b/addons/crm/wizard/crm_add_note.py @@ -5,6 +5,16 @@ import base64 AVAILABLE_STATES = crm.AVAILABLE_STATES + [('unchanged', 'Unchanged')] +class crm_send_new_email_attachment(osv.osv_memory): + _name = 'crm.send.mail.attachment' + + _columns = { + 'binary' : fields.binary('Attachment', required=True), + 'name' : fields.char('Name', size=128, required=True), + 'wizard_id' : fields.many2one('crm.add.note', 'Wizard', required=True), + } + +crm_send_new_email_attachment() class crm_add_note(osv.osv_memory): """Adds a new note to the case.""" @@ -14,7 +24,7 @@ class crm_add_note(osv.osv_memory): _columns = { 'body': fields.text('Note Body', required=True), 'state': fields.selection(AVAILABLE_STATES, string='Set New State To', - required=True), + required=True), 'attachment_ids' : fields.one2many('crm.send.mail.attachment', 'wizard_id'), } diff --git a/addons/crm/wizard/crm_send_email.py b/addons/crm/wizard/crm_send_email.py index 0882b79067a..d1604b1aaa8 100644 --- a/addons/crm/wizard/crm_send_email.py +++ b/addons/crm/wizard/crm_send_email.py @@ -31,18 +31,6 @@ import re AVAILABLE_STATES = crm.AVAILABLE_STATES + [('unchanged', 'Unchanged')] - -class crm_send_new_email_attachment(osv.osv_memory): - _name = 'crm.send.mail.attachment' - - _columns = { - 'binary' : fields.binary('Attachment', required=True), - 'name' : fields.char('Name', size=128, required=True), - 'wizard_id' : fields.many2one('crm.send.mail', 'Wizard', required=True), - } - -crm_send_new_email_attachment() - class crm_send_new_email(osv.osv_memory): """ Sends new email for the case""" _name = "crm.send.mail" diff --git a/addons/crm_partner_assign/wizard/crm_forward_to_partner.py b/addons/crm_partner_assign/wizard/crm_forward_to_partner.py index 53d6da3762a..ae653ec9c92 100644 --- a/addons/crm_partner_assign/wizard/crm_forward_to_partner.py +++ b/addons/crm_partner_assign/wizard/crm_forward_to_partner.py @@ -30,10 +30,10 @@ from tools.translate import _ class crm_lead_forward_to_partner(osv.osv_memory): """Forwards lead history""" _name = 'crm.lead.forward.to.partner' - _inherit = "crm.send.mail" + _inherit = "email.compose.message" _columns = { - 'name': fields.selection([('user', 'User'), ('partner', 'Partner'), \ + 'send_to': fields.selection([('user', 'User'), ('partner', 'Partner'), \ ('email', 'Email Address')], 'Send to', required=True), 'user_id': fields.many2one('res.users', "User"), 'partner_id' : fields.many2one('res.partner', 'Partner'), @@ -42,7 +42,7 @@ class crm_lead_forward_to_partner(osv.osv_memory): } _defaults = { - 'name' : 'email', + 'send_to' : 'email', 'history': 'latest', 'email_from': lambda self, cr, uid, *a: self.pool.get('res.users')._get_email_from(cr, uid, uid)[uid] } @@ -110,7 +110,7 @@ class crm_lead_forward_to_partner(osv.osv_memory): res_id = context.get('active_id') msg_val = self._get_case_history(cr, uid, history_type, res_id, context=context) if msg_val: - res = {'value': {'body' : '\n\n' + msg_val}} + res = {'value': {'description' : '\n\n' + msg_val}} return res def _get_case_history(self, cr, uid, history_type, res_id, context=None): @@ -165,6 +165,20 @@ class crm_lead_forward_to_partner(osv.osv_memory): email = self.pool.get('res.partner.address').browse(cr, uid, address_id).email return {'value': {'email_to' : email}} + def save_to_drafts(self, cr, uid, ids, context=None): + if context is None: + context = {} + super(crm_lead_forward_to_partner, self).save_to_drafts(cr, uid, ids, context=context) + self.action_forward(cr, uid, ids, context) + return {} + + def send_mail(self, cr, uid, ids, context=None): + if context is None: + context = {} + super(crm_lead_forward_to_partner, self).send_mail(cr, uid, ids, context=context) + self.action_forward(cr, uid, ids, context) + return {} + def action_forward(self, cr, uid, ids, context=None): """ Forward the lead to a partner @@ -175,15 +189,13 @@ class crm_lead_forward_to_partner(osv.osv_memory): case_pool = self.pool.get(context.get('active_model')) res_id = context and context.get('active_id', False) or False case = case_pool.browse(cr, uid, res_id, context=context) - context.update({'mail': 'forward'}) - super(crm_lead_forward_to_partner, self).action_send(cr, uid, ids, context=context) to_write = {'date_assign': time.strftime('%Y-%m-%d')} - if (this.name == 'partner' and this.partner_id): + if (this.send_to == 'partner' and this.partner_id): to_write['partner_assigned_id'] = this.partner_id.id - if this.name == 'user': + if this.send_to == 'user': to_write.update({'user_id' : this.user_id.id}) email_re = r'([^ ,<@]+@[^> ,]+)' email_cc = re.findall(email_re, case.email_cc or '') @@ -197,7 +209,6 @@ class crm_lead_forward_to_partner(osv.osv_memory): new_cc.append(to) to_write.update({'email_cc' : ', '.join(new_cc) }) case_pool.write(cr, uid, case.id, to_write, context=context) - return {'type': 'ir.actions.act_window_close'} def get_lead_details(self, cr, uid, lead_id, context=None): @@ -268,8 +279,8 @@ class crm_lead_forward_to_partner(osv.osv_memory): body = self._get_case_history(cr, uid, defaults.get('history', 'latest'), lead.id, context=context) defaults.update({ - 'subject' : '%s: %s' % (_('Fwd'), lead.name), - 'body' : body, + 'name' : '%s: %s' % (_('Fwd'), lead.name), + 'description' : body, 'email_cc' : '' }) return defaults diff --git a/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml b/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml index 9ee2870335a..2a56e6e14d7 100644 --- a/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml +++ b/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml @@ -1,49 +1,64 @@ + + crm_lead_forward_to_partner crm.lead.forward.to.partner form - - +
- - + + - - + + - + + + + + + + + + + + + + + + + + + + -
Forward to Partner crm.lead.forward.to.partner form form - + new