[IMP]: crm*: Improvements for "Add note" wizard,
authorrpa (Open ERP) <rpa@tinyerp.com>
Tue, 7 Sep 2010 13:21:40 +0000 (18:51 +0530)
committerrpa (Open ERP) <rpa@tinyerp.com>
Tue, 7 Sep 2010 13:21:40 +0000 (18:51 +0530)
* Added field for attachment to add attachment in Notes
* Put proper icon
* Improvement in Display text when we add a new Note
* Added button for this wizard in all crm related modules

bzr revid: rpa@tinyerp.com-20100907132140-9a9y8sigcktvdqk3

13 files changed:
addons/crm/crm_lead_view.xml
addons/crm/crm_opportunity_view.xml
addons/crm/crm_view.xml
addons/crm/wizard/__init__.py
addons/crm/wizard/crm_add_note.py
addons/crm/wizard/crm_add_note_view.xml
addons/crm_claim/crm_claim_view.xml
addons/crm_fundraising/crm_fundraising_view.xml
addons/crm_helpdesk/crm_helpdesk_view.xml
addons/event/event_view.xml
addons/hr_recruitment/hr_recruitment_view.xml
addons/mail_gateway/mail_gateway.py
addons/project_issue/project_issue_view.xml

index 737bb55..9bbac94 100644 (file)
                             </notebook>
                         </form>
                     </field>
-                    <button string="Send New Email"
-                        name="%(crm.action_crm_send_mail)d"
-                        context="{'mail':'new', 'model': 'crm.lead'}"
-                        icon="terp-mail-message-new" type="action" />
                     <button string="Add New Note"
                         name="%(crm.action_crm_add_note)d"
                         context="{'model': 'crm.lead' }"
+                        icon="terp-document-new" type="action" />
+                    <button string="Send New Email"
+                        name="%(crm.action_crm_send_mail)d"
+                        context="{'mail':'new', 'model': 'crm.lead'}"
                         icon="terp-mail-message-new" type="action" />
                     <button string="Forward"
                         name="%(crm_lead_forward_to_partner_act)d"
index e0c0896..18ae114 100644 (file)
                                     </notebook>
                                 </form>
                             </field>
-                            <button string="Send New Email"
-                                name="%(crm.action_crm_send_mail)d"
-                                context="{'mail':'new', 'model': 'crm.lead'}"
-                                icon="terp-mail-message-new" type="action" />
                             <button string="Add New Note"
                                 name="%(crm.action_crm_add_note)d"
                                 context="{'model': 'crm.lead' }"
+                                icon="terp-document-new" type="action" />
+                            <button string="Send New Email"
+                                name="%(crm.action_crm_send_mail)d"
+                                context="{'mail':'new', 'model': 'crm.lead'}"
                                 icon="terp-mail-message-new" type="action" />
                             <button string="Forward"
                                 name="%(crm_lead_forward_to_partner_act)d"
index fb8bddb..eef605d 100644 (file)
                                            </notebook>
                                        </form>
                                    </field>
+                                   <button string="Add New Note"
+                                name="%(crm.action_crm_add_note)d"
+                                context="{'model': 'crm.lead' }"
+                                icon="terp-document-new" type="action" />
                             <button string="Send New Email"
                                 name="%(crm.action_crm_send_mail)d"
                                 context="{'mail':'new', 'model': 'crm.case.custom'}"
                                 icon="terp-mail-message-new" type="action" />
-                            <button string="Add New Note"
-                                name="%(crm.action_crm_add_note)d"
-                                context="{'model': 'crm.lead' }"
-                                icon="terp-mail-message-new" type="action" />
                             <button string="Forward to Partner"
                                 name="%(crm_lead_forward_to_partner_act)d"
                                 icon="terp-mail-forward" type="action" />
index 9c14905..9e2ccdb 100644 (file)
@@ -19,9 +19,9 @@
 #
 ##############################################################################
 
-import crm_add_note
 import crm_send_email
 import crm_forward_to_partner
+import crm_add_note
 
 import crm_lead_to_partner
 import crm_lead_to_opportunity
index 05ae3ab..9a8d4f2 100644 (file)
@@ -1,7 +1,7 @@
 from crm import crm
 from osv import fields, osv
 from tools.translate import _
-
+import base64
 
 AVAILABLE_STATES = crm.AVAILABLE_STATES + [('unchanged', 'Unchanged')]
 
@@ -14,7 +14,8 @@ 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'),
     }
 
     def action_add(self, cr, uid, ids, context=None):
@@ -33,8 +34,11 @@ class crm_add_note(osv.osv_memory):
             case = case_list[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, email_from=user_name)
+            attach = [
+                (x.name, base64.decodestring(x.binary)) for x in obj.attachment_ids
+            ]
+            case_pool.history(cr, uid, [case], _("Note"), history=False,
+                              details=obj.body, email_from=user_name, attach=attach)
 
             if obj.state == 'unchanged':
                 pass
index 1e122c1..f218a42 100644 (file)
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Add Note" col="4">
-                    <field name="body" nolabel="1" colspan="4" default_focus="1"/>
+                    <separator string="Add Note" colspan="6"/>
+                    <notebook colspan="6">
+                        <page string="Note">
+                            <field name="body" nolabel="1" colspan="4" default_focus="1"/>
+                        </page>
+                        <page string="Attachments">
+                            <field name="attachment_ids" colspan="4" nolabel="1">
+                                <form string="Attachment">
+                                    <field name="binary" filename="name" />
+                                    <field name="name" />
+                                </form>
+                                <tree string="Attachments">
+                                    <field name="name" />
+                                </tree>
+                            </field>
+                        </page>
+                    </notebook>
                     <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" />
+                        <button name="action_add" type="object" string="_Add" icon="gtk-ok" />
                     </group>
                 </form>
             </field>
index 1938b6b..44b1eb3 100644 (file)
                                         </notebook>
                                     </form>
                                 </field>
-                                <button colspan="4" string="Send New Email"
-                                name="%(crm.action_crm_send_mail)d"
-                                context="{'mail':'new', 'model': 'crm.claim'}"
-                                icon="terp-mail-message-new" type="action" />
+                                <button string="Add New Note"
+                                    name="%(crm.action_crm_add_note)d"
+                                    context="{'model': 'crm.lead' }"
+                                    icon="terp-document-new" type="action" />
+                                <button string="Send New Email"
+                                    name="%(crm.action_crm_send_mail)d"
+                                    context="{'mail':'new', 'model': 'crm.claim'}"
+                                    icon="terp-mail-message-new" type="action" />
                             </page>
                             <page string="Extra Info" groups="base.group_extended">
                                 <field name="id" select="1"/>
index 326c4f7..84af1b1 100644 (file)
                                     </notebook>
                                 </form>
                             </field>
-                            <button colspan="4" string="Send New Email"
+                             <button string="Add New Note"
+                                name="%(crm.action_crm_add_note)d"
+                                context="{'model': 'crm.lead' }"
+                                icon="terp-document-new" type="action" />
+                            <button string="Send New Email"
                                 name="%(crm.action_crm_send_mail)d"
                                 context="{'mail':'new', 'model': 'crm.fundraising'}"
                                 icon="terp-mail-message-new" type="action" />
index b537c1a..375b758 100644 (file)
                                     </notebook>
                                 </form>
                             </field>
-                            <button colspan="4" string="Send New Email"
+                             <button string="Add New Note"
+                                name="%(crm.action_crm_add_note)d"
+                                context="{'model': 'crm.lead' }"
+                                icon="terp-document-new" type="action" />
+                            <button string="Send New Email"
                                 name="%(crm.action_crm_send_mail)d"
                                 context="{'mail':'new', 'model': 'crm.helpdesk'}"
                                 icon="terp-mail-message-new" type="action" />
index 532d26e..deb11c1 100644 (file)
                                     </notebook>
                                 </form>
                             </field>
-                              <button colspan="4" string="Send New Email"
+                             <button string="Add New Note"
+                                name="%(crm.action_crm_add_note)d"
+                                context="{'model': 'crm.lead' }"
+                                icon="terp-document-new" type="action" />
+                              <button string="Send New Email"
                                 name="%(crm.action_crm_send_mail)d"
                                 context="{'mail':'new', 'model': 'event.registration'}"
                                 icon="terp-mail-message-new" type="action" />
index 67d9056..6138bf4 100644 (file)
                                 </notebook>
                             </form>
                         </field>
-                       <button colspan="2" string="Send New Email"
+                         <button string="Add New Note"
+                                name="%(crm.action_crm_add_note)d"
+                                context="{'model': 'crm.lead' }"
+                                icon="terp-document-new" type="action" />
+                        <button string="Send New Email"
                            name="%(crm.action_crm_send_mail)d"
                            context="{'mail':'new', 'model': 'hr.applicant'}"
                            icon="terp-mail-message-new" type="action" />
-                       <button colspan="2" string="Forward"
+                        <button string="Forward"
                            name="%(crm.crm_lead_forward_to_partner_act)d"
                            icon="terp-mail-forward" type="action" />
                  </page>
index 1a1b48e..b0bc9b3 100644 (file)
@@ -122,19 +122,22 @@ class mailgate_thread(osv.osv):
         obj = self.pool.get('mailgate.message')
 
         for case in cases:
+            attachments = []
+            for att in attach:
+                    attachments.append(att_obj.create(cr, uid, {'name': att[0], 'datas': base64.encodestring(att[1])}))
+
             data = {
                 'name': keyword,
                 'user_id': uid,
                 'model' : case._name,
                 'res_id': case.id,
                 'date': time.strftime('%Y-%m-%d %H:%M:%S'),
-                'message_id': message_id,
+                'message_id': message_id, 
+                'description': details or (hasattr(case, 'description') and case.description or False), 
+                'attachment_ids': [(6, 0, attachments)]
             }
-            attachments = []
-            if history:
-                for att in attach:
-                    attachments.append(att_obj.create(cr, uid, {'name': att[0], 'datas': base64.encodestring(att[1])}))
 
+            if history:
                 for param in (email, email_cc, email_bcc):
                     if isinstance(param, list):
                         param = ", ".join(param)
@@ -187,6 +190,8 @@ class mailgate_message(osv.osv):
                 msg_txt = (message.user_id.name or '/') + _('  on ') + format_date_tz(message.date, tz) + ':\n\t'
                 if message.name == _('Opportunity'):
                     msg_txt += _("Converted to Opportunity")
+                elif message.name == _('Note'):
+                    msg_txt += _("Added Note: ") + (message.description or '')
                 else:
                     msg_txt += _("Changed Status to: ") + message.name
             result[message.id] = msg_txt
index ce3e131..f3dcca1 100644 (file)
                                 </form>
                             </field>
                            <separator colspan="4"/>
-                           <button colspan="4" string="Send New Email"
+                            <button string="Add New Note"
+                                name="%(crm.action_crm_add_note)d"
+                                context="{'model': 'crm.lead' }"
+                                icon="terp-document-new" type="action" />
+                            <button string="Send New Email"
                                name="%(crm.action_crm_send_mail)d"
                                context="{'mail':'new', 'model': 'project.issue'}"
                                icon="terp-mail-message-new" type="action" />