translate: port to pythonic logging, filename in a message
[odoo/odoo.git] / addons / survey / survey.py
index c86f13b..5343ef3 100644 (file)
@@ -27,9 +27,9 @@ import netsvc
 from tools.translate import _
 
 from time import strftime
-import datetime
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
 import copy
-from mx.DateTime import *
 import os
 
 class survey_type(osv.osv):
@@ -55,11 +55,12 @@ class survey(osv.osv):
         'page_ids': fields.one2many('survey.page', 'survey_id', 'Page'),
         'date_open': fields.datetime('Survey Open Date', readonly=1),
         'date_close': fields.datetime('Survey Close Date', readonly=1),
-        'max_response_limit': fields.integer('Maximum Answer Limit'),
+        'max_response_limit': fields.integer('Maximum Answer Limit',
+                     help="Set to one if survey is answerable only once"),
         'response_user': fields.integer('Maximum Answer per User',
                      help="Set to one if  you require only one Answer per user"),
         'state': fields.selection([('draft', 'Draft'), ('open', 'Open'), ('close', 'Closed'), ('cancel', 'Cancelled')], 'Status', readonly=True),
-        'responsible_id': fields.many2one('res.users', 'Responsible'),
+        'responsible_id': fields.many2one('res.users', 'Responsible', help="User responsible for survey"),
         'tot_start_survey': fields.integer("Total Started Survey", readonly=1),
         'tot_comp_survey': fields.integer("Total Completed Survey", readonly=1),
         'note': fields.text('Description', size=128),
@@ -67,6 +68,7 @@ class survey(osv.osv):
         'users': fields.many2many('res.users', 'survey_users_rel', 'sid', 'uid', 'Users'),
         'send_response': fields.boolean('E-mail Notification on Answer'),
         'type': fields.many2one('survey.type', 'Type'),
+        'invited_user_ids': fields.many2many('res.users', 'survey_invited_user_rel', 'sid', 'uid', 'Invited User'),
     }
     _defaults = {
         'state': lambda * a: "draft",
@@ -124,8 +126,8 @@ class survey(osv.osv):
                 'type': 'ir.actions.report.xml',
                 'report_name': 'survey.browse.response',
                 'datas': datas,
-                'nodestroy': True,
-                'context' : context
+                'context' : context,
+                'nodestroy':True,
             }
         else:
 
@@ -135,8 +137,8 @@ class survey(osv.osv):
                 'type': 'ir.actions.report.xml',
                 'report_name': 'survey.form',
                 'datas': datas,
+                'context' : context,
                 'nodestroy':True,
-                'context' : context
             }
         return report
 survey()
@@ -211,8 +213,8 @@ class survey_question(osv.osv):
             return {}
         val = {}
         cr.execute("select question_id, count(id) as Total_response from \
-                survey_response_line where state='done' and question_id in (%s)\
-                 group by question_id" % ",".join(map(str, map(int, ids))))
+                survey_response_line where state='done' and question_id IN %s\
+                 group by question_id" ,(tuple(ids),))
         ids1 = copy.deepcopy(ids)
         for rec in  cr.fetchall():
             ids1.remove(rec[0])
@@ -571,7 +573,7 @@ class survey_answer(osv.osv):
         'in_visible_answer_type': fields.boolean('Is Answer Type Invisible??')
     }
     _defaults = {
-         'sequence' : lambda * a: 1,
+#         'sequence' : lambda * a: 1,
          'type' : lambda * a: 'char',
          'in_visible_answer_type':_get_in_visible_answer_type,
     }
@@ -693,7 +695,7 @@ class survey_request(osv.osv):
     }
     _defaults = {
         'state': lambda * a: 'draft',
-        'date_deadline': lambda * a :  (now() + RelativeDateTime(months=+1)).strftime("%Y-%m-%d %H:%M:%S")
+#        'date_deadline': lambda * a :  (datetime.now() + relativedelta(months=+1)).strftime("%Y-%m-%d %H:%M:%S")
     }
     def survey_req_waiting_answer(self, cr, uid, ids, arg):
         self.write(cr, uid, ids, { 'state' : 'waiting_answer'})