[IMP] crm: cleanup `add note` wizard

bzr revid: odo@openerp.com-20110912171530-2p5l211791schp6d
This commit is contained in:
Olivier Dony 2011-09-12 19:15:30 +02:00
parent 983a7d2fd2
commit 59b200ea85
1 changed files with 5 additions and 26 deletions

View File

@ -1,22 +1,10 @@
from crm import crm
from osv import fields, osv
from tools.translate import _
import base64
from mail.mail_message import truncate_text
AVAILABLE_STATES = crm.AVAILABLE_STATES + [('unchanged', 'Unchanged')]
class crm_add_note_email_attachment(osv.osv_memory):
_name = 'crm.add.note.email.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_add_note_email_attachment()
class crm_add_note(osv.osv_memory):
"""Adds a new note to the case."""
_name = 'crm.add.note'
@ -26,7 +14,10 @@ class crm_add_note(osv.osv_memory):
'body': fields.text('Note Body', required=True),
'state': fields.selection(AVAILABLE_STATES, string='Set New State To',
required=True),
'attachment_ids' : fields.one2many('crm.add.note.email.attachment', 'wizard_id'),
}
_defaults = {
'state': 'unchanged'
}
def action_add(self, cr, uid, ids, context=None):
@ -43,13 +34,8 @@ class crm_add_note(osv.osv_memory):
case_list = case_pool.browse(cr, uid, context['active_ids'],
context=context)
case = case_list[0]
user_obj = self.pool.get('res.users')
attach = dict(
(x.name, base64.decodestring(x.binary)) for x in obj.attachment_ids
)
case_pool.message_append(cr, uid, [case], truncate_text(obj.body),
body_text=obj.body, attachments=attach)
body_text=obj.body)
if obj.state == 'unchanged':
pass
elif obj.state == 'done':
@ -62,11 +48,4 @@ class crm_add_note(osv.osv_memory):
return {'type': 'ir.actions.act_window_close'}
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
"""
return {'state': u'unchanged'}
crm_add_note()