[IMP] crm: add probability field in crm.case.stage instead of crm.case.categ
authorHarry (Open ERP) <hmo@tinyerp.com>
Tue, 23 Feb 2010 10:35:15 +0000 (16:05 +0530)
committerHarry (Open ERP) <hmo@tinyerp.com>
Tue, 23 Feb 2010 10:35:15 +0000 (16:05 +0530)
bzr revid: hmo@tinyerp.com-20100223103515-eonqz3zkwfnrsoyw

addons/crm/crm.py
addons/crm/crm_claims_view.xml
addons/crm/crm_fund_view.xml
addons/crm/crm_helpdesk_view.xml
addons/crm/crm_lead_view.xml
addons/crm/crm_opportunity.py
addons/crm/crm_opportunity_view.xml
addons/crm/crm_phonecall_view.xml
addons/crm/crm_view.xml
addons/crm_hr/crm_hr_view.xml

index 0702868..179daf0 100644 (file)
@@ -111,8 +111,7 @@ class crm_case_categ(osv.osv):
     _description = "Category of case"
 
     _columns = {
-        'name': fields.char('Case Category Name', size=64, required=True, translate=True),
-        'probability': fields.float('Probability (%)', required=True),
+        'name': fields.char('Case Category Name', size=64, required=True, translate=True),        
         'section_id': fields.many2one('crm.case.section', 'Case Section'),
         'object_id': fields.many2one('ir.model','Object Name'),        
     }
@@ -120,8 +119,7 @@ class crm_case_categ(osv.osv):
         object_id = context and context.get('object_id', False) or False
         ids =self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
         return ids and ids[0] 
-    _defaults = {
-        'probability': lambda *args: 0.0,
+    _defaults = {        
         'object_id' : _find_object_id
     }
 #               
@@ -156,6 +154,7 @@ class crm_case_stage(osv.osv):
         'section_id': fields.many2one('crm.case.section', 'Case Section'),
         'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of case stages."),
         'object_id': fields.many2one('ir.model','Object Name'),
+        'probability': fields.float('Probability (%)', required=True),
     }
     def _find_object_id(self, cr, uid, context=None):
         object_id = context and context.get('object_id', False) or False
@@ -163,6 +162,7 @@ class crm_case_stage(osv.osv):
         return ids and ids[0]     
     _defaults = {
         'sequence': lambda *args: 1,
+        'probability': lambda *args: 0.0,
         'object_id' : _find_object_id
     }
     
@@ -319,13 +319,8 @@ class crm_case(osv.osv):
                 s[section] = dict([(v, k) for (k, v) in s[section].iteritems()])
                 if st in s[section]:
                     self.write(cr, uid, [case.id], {'stage_id': s[section][st]})
-        return True
+        return True  
     
-    def onchange_categ_id(self, cr, uid, ids, categ, context={}):
-        if not categ:
-            return {'value':{}}
-        cat = self.pool.get('crm.case.categ').browse(cr, uid, categ, context).probability
-        return {'value':{'probability':cat}}
 
     def onchange_case_id(self, cr, uid, ids, case_id, name, partner_id, context={}):
         if not case_id:
index e97221f..cfaaacb 100644 (file)
@@ -78,8 +78,7 @@
                                <field name="stage_id" select="1" nolabel="1"/>
                                <button icon="gtk-go-forward" string="" name="stage_next" type="object"/>
                            </group>
-                       <field name="categ_id" select="1" widget="selection"
-                               on_change="onchange_categ_id(categ_id)"
+                       <field name="categ_id" select="1" widget="selection"                                    
                                domain="[('object_id.model', '=', 'crm.claim')]" />
                        <field name="type_id" string="Type of Action" select="1"
                                domain="[('object_id.model', '=', 'crm.claim')]" />
index 6467242..250f747 100644 (file)
@@ -81,7 +81,7 @@
                        <field name="user_id" select="2" string="Responsible"/>
                         <field name="section_id" colspan="1" widget="selection"/>
                        <field name="categ_id" select="1"
-                               on_change="onchange_categ_id(categ_id)"  widget="selection"
+                               widget="selection"
                                domain="[('object_id.model', '=', 'crm.fundraising')]" />
                        <field name="date"/>
                            <field name="duration"/>
index b1c8568..ec00259 100644 (file)
@@ -65,7 +65,7 @@
                     <page string="History" groups="base.group_extended">
                         <field name="id" select="1"/>
                         <field name="active" select="2"/>
-                        <field name="categ_id" on_change="onchange_categ_id(categ_id)" select="2"/>
+                        <field name="categ_id" select="2"/>
                         <field name="som" select="2"/>
                         <separator colspan="4" string="Dates"/>
                         <field name="create_date"/>
index 288ee84..ed8ad6a 100644 (file)
@@ -57,8 +57,7 @@
                     <separator colspan="4" string="Status and Categorization"/>
                     <group colspan="4" col="6">
                         <field name="stage_id" widget="selection" domain="[('object_id.model', '=', 'crm.lead')]"/>
-                        <field name="categ_id"
-                            on_change="onchange_categ_id(categ_id)"
+                        <field name="categ_id"                            
                             string="Lead Source" widget="selection"
                             domain="[('object_id.model', '=', 'crm.opportunity')]" />
                         <field name="type_id" string="Campaign" select="1"/>
index fc65455..8e34d00 100644 (file)
@@ -37,7 +37,7 @@ class crm_opportunity(osv.osv):
     _inherit = 'crm.case'
     _columns = {
         'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
-        'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
+        'categ_id': fields.many2one('crm.case.categ', 'Source', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
         'type_id': fields.many2one('crm.case.resource.type', 'Resource Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
         'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
         'probability': fields.float('Probability (%)'),
@@ -51,6 +51,11 @@ class crm_opportunity(osv.osv):
                                   \nWhen the case is over, the state is set to \'Done\'.\
                                   \nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
     }
+    def onchange_stage_id(self, cr, uid, ids, stage, context={}):
+        if not stage:
+            return {'value':{}}
+        probability = self.pool.get('crm.case.stage').browse(cr, uid, stage, context).probability
+        return {'value':{'probability':probability}}
 
 crm_opportunity()
 
index 8f9dcd7..247f551 100644 (file)
@@ -41,7 +41,7 @@
             <form string="Opportunities">
                 <group colspan="4" col="7">
                     <field name="name" string="Opportunity"/>
-                    <field name="stage_id" widget="selection" domain="[('object_id.model', '=', 'crm.opportunity')]"/>
+                    <field name="stage_id" on_change="onchange_stage_id(stage_id)" widget="selection" domain="[('object_id.model', '=', 'crm.opportunity')]"/>
                     <field name="user_id"/>
                     <button string="Schedule Meeting"
                         name="%(wizard_crm_opportunity_meeting_set)d" icon="gtk-redo" type="action" />
@@ -65,7 +65,7 @@
                         <field name="type_id" select="1" string="Campaign"/>
                         <field name="section_id" colspan="1" widget="selection"/>
                         <field name="priority" string="Priority"/>
-                        <field name="categ_id" select="1" on_change="onchange_categ_id(categ_id)" string="Source" widget="selection" domain="[('object_id.model', '=', 'crm.opportunity')]"/>
+                        <field name="categ_id" select="1" string="Source" widget="selection" domain="[('object_id.model', '=', 'crm.opportunity')]"/>
                     </group>
 
                     <separator colspan="4" string="Details"/>
index bb5187f..f690594 100644 (file)
         <field name="arch" type="xml">
             <calendar string="Phone Calls" date_start="date" color="user_id" date_delay="duration">
                 <field name="name"/>
-                <field name="partner_id"/>
-                <field name="categ_id"/>
+                <field name="partner_id"/>                
             </calendar>
         </field>
     </record>
index de9a6fa..e12ec19 100644 (file)
@@ -59,7 +59,9 @@
                 <tree string="Stages">
                     <field name="sequence"/>
                     <field name="name"/>
+                    <field name="probability"/>
                     <field name="section_id"/>
+                    
                 </tree>
             </field>
         </record>
@@ -73,6 +75,7 @@
                     <field name="section_id" select="1" widget="selection"/>
                     <field name="object_id" invisible="1" />
                     <field name="sequence"/>
+                    <field name="probability"/>
                 </form>
             </field>
         </record>
@@ -92,8 +95,7 @@
                 <form string="Case Category">
                     <field name="name" select="1"/>
                     <field name="section_id" select="1" widget="selection"/>
-                    <field name="object_id"  invisible="1" />
-                    <field name="probability"/>
+                    <field name="object_id"  invisible="1" />                    
                 </form>
             </field>
         </record>
             <field name="arch" type="xml">
                 <tree string="Case Category">
                     <field name="name"/>
-                    <field name="section_id"/>
-                    <field name="probability"/>
+                    <field name="section_id"/>                    
                 </tree>
             </field>
         </record>
index bb3ea95..95b13a0 100644 (file)
@@ -96,7 +96,7 @@
                         <newline/>
                         <field name="planned_cost" string="Expected Salary"/>
                         <field name="planned_revenue" string="Proposed Salary"/>
-                        <field name="categ_id" string="Applied Job" select="1" on_change="onchange_categ_id(categ_id)"/>
+                        <field name="categ_id" string="Applied Job" select="1" />
                         <field name="type_id" string="Degree" select="1"/>
                         <separator colspan="4" string="Qualication"/>
                         <field name="priority" string="Appreciation" select="2"/>