Initial 'Add Note' functionality.

bzr revid: daniel.watkins@credativ.co.uk-20100831150921-gc7d0yfr0s034wmg
This commit is contained in:
Daniel Watkins 2010-08-31 16:09:21 +01:00
parent d7849d322d
commit c5c5d8b0f4
7 changed files with 99 additions and 0 deletions

View File

@ -84,6 +84,7 @@ Create dashboard for CRM that includes:
'wizard/crm_partner_to_opportunity_view.xml',
'wizard/crm_send_email_view.xml',
'wizard/crm_add_note_view.xml',
'wizard/crm_forward_to_partner_view.xml',
'wizard/crm_custom_create_menu_view.xml',
'wizard/crm_merge_opportunities_view.xml',

View File

@ -214,6 +214,10 @@
name="%(crm.action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.lead'}"
icon="terp-mail-message-new" type="action" />
<button colspan="2" string="Add New Note"
name="%(crm.action_crm_add_note)d"
context="{'model': 'crm.lead' }"
icon="terp-mail-message-new" type="action" />
<button colspan="2" string="Forward"
name="%(crm_lead_forward_to_partner_act)d"
icon="terp-mail-forward" type="action" />

View File

@ -171,6 +171,10 @@
name="%(crm.action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.lead'}"
icon="terp-mail-message-new" type="action" />
<button colspan="2" string="Add New Note"
name="%(crm.action_crm_add_note)d"
context="{'model': 'crm.lead' }"
icon="terp-mail-message-new" type="action" />
<button colspan="2" string="Forward"
name="%(crm_lead_forward_to_partner_act)d"
icon="terp-mail-forward" type="action" />

View File

@ -571,6 +571,10 @@
name="%(crm.action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.case.custom'}"
icon="terp-mail-message-new" type="action" />
<button colspan="2" string="Add New Note"
name="%(crm.action_crm_add_note)d"
context="{'model': 'crm.lead' }"
icon="terp-mail-message-new" type="action" />
<button colspan="2" string="Forward to Partner"
name="%(crm_lead_forward_to_partner_act)d"
icon="terp-mail-forward" type="action" />

View File

@ -19,6 +19,7 @@
#
##############################################################################
import crm_add_note
import crm_send_email
import crm_forward_to_partner

View File

@ -0,0 +1,47 @@
from crm import crm
from osv import fields, osv
from tools.translate import _
class crm_add_note(osv.osv_memory):
"""Adds a new note to the case."""
_name = 'crm.add.note'
_description = "Add New Note"
_columns = {
'subject': fields.char('Subject', size=512, required=True),
'body': fields.text('Note Body', required=True),
'state': fields.selection(crm.AVAILABLE_STATES, string='Set New State To', required=True),
}
def action_add(self, cr, uid, ids, context=None):
if not context:
context = {}
if not context.get('active_model'):
raise osv.except_osv(_('Error'), _('Can not add note!'))
model = context.get('active_model')
case_pool = self.pool.get(model)
for obj in self.browse(cr, uid, ids, context=context):
case = case_pool.browse(cr, uid, context['active_ids'], context=context)[0]
user_obj = self.pool.get('res.users')
user_name = user_obj.browse(cr, uid, [uid], context=context)[0].name
case_pool.history(cr, uid, [case], _("Note"), history=True,
details=obj.body, subject=obj.subject,
email_from=user_name)
if obj.state == 'unchanged':
pass
elif obj.state == 'done':
case_pool.case_close(cr, uid, [case.id])
elif obj.state == 'draft':
case_pool.case_reset(cr, uid, [case.id])
elif obj.state in ['cancel', 'open', 'pending']:
act = 'case_' + obj.state
getattr(case_pool, act)(cr, uid, [case.id])
return {}
crm_add_note()

View File

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Add New Note view -->
<record model="ir.ui.view" id="crm_add_new_note_view">
<field name="name">crm.new.add.note.form</field>
<field name="model">crm.add.note</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Add Note" col="4">
<field name="subject"/>
<field name="body" nolabel="1" colspan="4" default_focus="1"/>
<separator string="" colspan="6"/>
<group colspan="6" col="4" >
<field name="state" />
<button string="_Cancel" icon="gtk-cancel" special="cancel" />
<button name="action_add" type="object" string="_Add" icon="gtk-go-forward" />
</group>
</form>
</field>
</record>
<!-- Send New Mail action -->
<record model="ir.actions.act_window" id="action_crm_add_note">
<field name="name">Add Note</field>
<field name="res_model">crm.add.note</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_add_new_note_view"/>
<field name="target">new</field>
</record>
</data>
</openerp>