← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/trunk-bug-735348-rme into lp:openobject-addons

 

Ravindra Mekhiya(OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-bug-735348-rme into lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #735348 in OpenERP Addons: "Claim History having problem"
  https://bugs.launchpad.net/openobject-addons/+bug/735348

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-735348-rme/+merge/53581

Hello,

-crm_claim : stage of claim is not changing on button click due to context And history of change in stage should be appear in the claim's history.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-735348-rme/+merge/53581
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-735348-rme.
=== modified file 'crm_claim/crm_claim.py'
--- crm_claim/crm_claim.py	2011-02-15 09:42:10 +0000
+++ crm_claim/crm_claim.py	2011-03-16 08:52:36 +0000
@@ -24,6 +24,7 @@
 import time
 import binascii
 import tools
+from tools.translate import _
 
 CRM_CLAIM_PENDING_STATES = (
     crm.AVAILABLE_STATES[2][0], # Cancelled
@@ -81,6 +82,49 @@
         'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
     }
     
+    def write(self, cr, uid, ids, vals, context=None):
+        if not context:
+            context = {}
+            
+        if 'stage_id' in vals and vals['stage_id']:
+            type = context and context.get('stage_type', '')
+            stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, vals['stage_id'], context=context)
+            self.history(cr, uid, ids, _("Changed Stage to: ") + stage_obj.name, details=_("Changed Stage to: ") + stage_obj.name)
+            message=''
+            for case in self.browse(cr, uid, ids, context=context):
+                message = _("The stage of lead '%s' has been changed to '%s'.") % (case.name, stage_obj.name)
+                self.log(cr, uid, case.id, message)
+        return super(crm_claim,self).write(cr, uid, ids, vals, context)
+    
+    def stage_historize(self, cr, uid, ids, stage, context=None):
+        stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context)
+        self.history(cr, uid, ids, _('Stage'), details=stage_obj.name)
+        for case in self.browse(cr, uid, ids, context=context):
+            if case.type == 'lead':
+                message = _("The stage of lead '%s' has been changed to '%s'.") % (case.name, stage_obj.name)
+            elif case.type == 'opportunity':
+                message = _("The stage of opportunity '%s' has been changed to '%s'.") % (case.name, stage_obj.name)
+            self.log(cr, uid, case.id, message)
+        return True
+
+    def stage_next(self, cr, uid, ids, context=None):
+        stage = super(crm_claim, self).stage_next(cr, uid, ids, context=context)
+        if stage:
+            stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context)
+            if stage_obj.on_change:
+                data = {'probability': stage_obj.probability}
+                self.write(cr, uid, ids, data)
+        return stage
+
+    def stage_previous(self, cr, uid, ids, context=None):
+        stage = super(crm_claim, self).stage_previous(cr, uid, ids, context=context)
+        if stage:
+            stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context)
+            if stage_obj.on_change:
+                data = {'probability': stage_obj.probability}
+                self.write(cr, uid, ids, data)
+        return stage
+    
     def _get_stage_id(self, cr, uid, context=None):
         """Finds type of stage according to object.
         @param self: The object pointer

=== modified file 'crm_claim/crm_claim_view.xml'
--- crm_claim/crm_claim_view.xml	2011-03-09 13:03:45 +0000
+++ crm_claim/crm_claim_view.xml	2011-03-16 08:52:36 +0000
@@ -102,8 +102,12 @@
 
                         <group colspan="2" col="4">
                             <field name="stage_id" domain="[('type','=','claim')]"/>
-                            <button name="stage_previous" string="" type="object" icon="gtk-go-back" />
-                            <button icon="gtk-go-forward" string="" name="stage_next" type="object"/>
+                        <button name="stage_previous" string=""
+                            states="open,pending,draft" type="object"
+                            icon="gtk-go-back" context="{'stage_type': 'claim'}" />
+                        <button name="stage_next" string=""
+                            states="open,pending,draft" type="object"
+                            icon="gtk-go-forward" context="{'stage_type': 'claim'}" />
                         </group>
                         <newline />
                         <field name="priority"/>


Follow ups