[IMP] crm_phoncall : remove the visibilty of the draft from phonecall
[odoo/odoo.git] / addons / crm / crm_phonecall.py
index b9e34d9..d6f6457 100644 (file)
@@ -50,25 +50,21 @@ class crm_phonecall(crm_case, osv.osv):
         'company_id': fields.many2one('res.company', 'Company'), 
         'description': fields.text('Description'), 
         'state': fields.selection([
-                                    ('draft', 'Todo'), 
                                     ('open', 'Todo'), 
                                     ('cancel', 'Cancelled'), 
                                     ('done', 'Held'), 
-                                    ('pending', 'Not Held'),
+                                    ('pending', 'Pending'),
                                 ], 'State', size=16, readonly=True, 
-                                  help='The state is set to \'Draft\', when a case is created.\
+                                  help='The state is set to \'Todo\', when a case is created.\
                                   \nIf the case is in progress the state is set to \'Open\'.\
                                   \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\'.'), 
         'email_from': fields.char('Email', size=128, help="These people will receive email."), 
-        'stage_id': fields.many2one('crm.case.stage', 'Stage', \
-                            domain="[('section_id','=',section_id),\
-                            ('object_id.model', '=', 'crm.phonecall')]"), 
         'date_open': fields.datetime('Opened', readonly=True),
         # phonecall fields
         'duration': fields.float('Duration', help="Duration in Minutes"), 
         'categ_id': fields.many2one('crm.case.categ', 'Category', \
-                        domain="[('section_id','=',section_id),\
+                        domain="['|',('section_id','=',section_id),('section_id','=',False),\
                         ('object_id.model', '=', 'crm.phonecall')]"), 
         'partner_phone': fields.char('Phone', size=32), 
         'partner_contact': fields.related('partner_address_id', 'name', \
@@ -82,16 +78,21 @@ class crm_phonecall(crm_case, osv.osv):
                          the canall which is this opportunity source."), 
         'date_closed': fields.datetime('Closed', readonly=True), 
         'date': fields.datetime('Date'), 
-        'opportunity_id': fields.many2one ('crm.lead', 'Opportunity'), 
+        'opportunity_id': fields.many2one ('crm.lead', 'Lead/Opportunity'), 
         'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
     }
 
+    def _get_default_state(self, cr, uid, context=None):
+        if context and context.get('default_state', False):
+            return context.get('default_state')
+        return 'open'
+
     _defaults = {
         'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), 
-        'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0], 
-        'state': lambda *a: 'open', 
+        'priority': crm.AVAILABLE_PRIORITIES[2][0], 
+        'state':  _get_default_state, 
         'user_id': lambda self,cr,uid,ctx: uid,
-        'active': lambda *a: 1, 
+        'active': 1, 
     }
     
     # From crm.case
@@ -124,14 +125,14 @@ class crm_phonecall(crm_case, osv.osv):
         return res
 
     def case_reset(self, cr, uid, ids, *args):
-        """Resets case as draft
+        """Resets case as Todo
         @param self: The object pointer
         @param cr: the current row, from the database cursor,
         @param uid: the current user’s ID for security checks,
         @param ids: List of case Ids
         @param *args: Tuple Value for additional Params
         """
-        res = super(crm_phonecall, self).case_reset(cr, uid, ids, args)
+        res = super(crm_phonecall, self).case_reset(cr, uid, ids, args, 'crm.phonecall')
         self.write(cr, uid, ids, {'duration': 0.0})
         return res
 
@@ -160,7 +161,7 @@ class crm_phonecall(crm_case, osv.osv):
         @return : Dictionary value for created Meeting view
         """
         value = {}
-        for phonecall in self.browse(cr, uid, ids):
+        for phonecall in self.browse(cr, uid, ids, context=context):
             data_obj = self.pool.get('ir.model.data')
 
             # Get meeting views