Mayur Maheshwari(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-addons_issue16_tools-mma into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons_issue16_tools-mma/+merge/129152

Hello 

 I Have fixed following things:-

- Improve warning message as per specification [Survey: change warning "You 
must enter one or more column headings." => "You must enter one or more column 
headings for question <question name> of page <page name>." ]
- Self Appraisal survey: test survey => in step 4/5, 1. Professional 
Development Objectives is misaligned -> set it by newline from label
-Create New Survey -> edit survey or test survey trace back [ProgrammingError: 
operator does not exist: integer = boolean] 

Thanks
Mayur
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons_issue16_tools-mma/+merge/129152
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-addons_issue16_tools-mma.
=== modified file 'survey/survey.py'
--- survey/survey.py	2012-10-02 10:29:15 +0000
+++ survey/survey.py	2012-10-11 10:50:53 +0000
@@ -163,19 +163,43 @@
             'context': context
         }
     def test_survey(self, cr, uid, ids, context=None):
-        sur_obj = self.read(cr, uid, ids,['title'], context=context)
-        for sur in sur_obj:
-            name = sur['title']
-            context.update({'active':True,'survey_id': ids[0]})
-        return {
-            'view_type': 'form',
-            'view_mode': 'form',
-            'res_model': 'survey.question.wiz',
-            'type': 'ir.actions.act_window',
-            'target': 'new',
-            'name': name,
-            'context': context
-        }
+        sur_obj = self.read(cr, uid, ids,['title','page_ids'], context=context)
+        for sur in sur_obj:
+            name = sur['title']
+            pages = sur['page_ids']
+            if not pages:
+                raise osv.except_osv(_('Warning!'), _('This survey has no question defined. Please define the questions and answers first.'))
+            else:
+                context.update({'active':False,'survey_id': ids[0]})
+        return {
+            'view_type': 'form',
+            'view_mode': 'form',
+            'res_model': 'survey.question.wiz',
+            'type': 'ir.actions.act_window',
+            'target': 'new',
+            'name': name,
+            'context': context
+        }
+
+    def edit_survey(self, cr, uid, ids, context=None):
+        sur_obj = self.read(cr, uid, ids,['title','page_ids'], context=context)
+        for sur in sur_obj:
+            name = sur['title']
+            pages = sur['page_ids']
+            if not pages:
+                raise osv.except_osv(_('Warning!'), _('This survey has no question defined. Please define the questions and answers first.'))
+            else:
+                context.update({'survey_id': ids[0]})
+        return {
+            'view_type': 'form',
+            'view_mode': 'form',
+            'res_model': 'survey.question.wiz',
+            'type': 'ir.actions.act_window',
+            'target': 'new',
+            'name': name,
+            'context': context
+        }
+
 survey()
 
 class survey_history(osv.osv):
@@ -383,7 +407,7 @@
 
     def write(self, cr, uid, ids, vals, context=None):
         questions = self.read(cr,uid, ids, ['answer_choice_ids', 'type', 'required_type',\
-                        'req_ans', 'minimum_req_ans', 'maximum_req_ans', 'column_heading_ids'])
+                        'req_ans', 'minimum_req_ans', 'maximum_req_ans', 'column_heading_ids', 'page_id', 'question'])
         for question in questions:
             col_len = len(question['column_heading_ids'])
             if vals.has_key('column_heading_ids'):
@@ -401,7 +425,7 @@
             if que_type in ['matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans',\
                              'matrix_of_drop_down_menus', 'rating_scale']:
                 if not col_len:
-                    raise osv.except_osv(_('Warning!'),_("You must enter one or more column headings."))
+                    raise osv.except_osv(_('Warning!'),_("You must enter one or more column headings for question %s of page %s.") % (question['question'], question['page_id'][1]))
             ans_len = len(question['answer_choice_ids'])
 
             if vals.has_key('answer_choice_ids'):
@@ -413,7 +437,7 @@
 
             if que_type not in ['descriptive_text', 'single_textbox', 'comment','table']:
                 if not ans_len:
-                    raise osv.except_osv(_('Warning!'),_("You must enter one or more Answers."))
+                    raise osv.except_osv(_('Warning!'),_("You must enter one or more Answers for question %s of page %s.") % (question['question'], question['page_id'][1]))
             req_type = ""
 
             if vals.has_key('required_type'):
@@ -484,11 +508,11 @@
         maximum_ans = 0
         if vals.has_key('answer_choice_ids') and  not len(vals['answer_choice_ids']):
             if vals.has_key('type') and vals['type'] not in ['descriptive_text', 'single_textbox', 'comment','table']:
-                raise osv.except_osv(_('Warning!'),_("You must enter one or more answers."))
+                raise osv.except_osv(_('Warning!'),_("You must enter one or more answers for question %s.") % (vals['question']))
 
         if vals.has_key('column_heading_ids') and  not len(vals['column_heading_ids']):
             if vals.has_key('type') and vals['type'] in ['matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'matrix_of_drop_down_menus', 'rating_scale']:
-                raise osv.except_osv(_('Warning!'),_("You must enter one or more column heading."))
+                raise osv.except_osv(_('Warning!'),_("You must enter one or more column heading for question %s.")% (vals['question']))
 
         if vals['type'] in ['multiple_choice_multiple_ans','matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'matrix_of_drop_down_menus', 'rating_scale','multiple_textboxes','numerical_textboxes','date','date_and_time']:
             if vals.has_key('is_require_answer') and vals.has_key('required_type') and vals['required_type'] in ['at least', 'at most', 'exactly']:

=== modified file 'survey/survey_view.xml'
--- survey/survey_view.xml	2012-10-04 14:24:48 +0000
+++ survey/survey_view.xml	2012-10-11 10:50:53 +0000
@@ -31,8 +31,8 @@
                         <button name="test_survey" states="open,draft,close,cancel" string="Test Survey" type="object" icon="gtk-new" context="{'survey_id': active_id}" attrs="{'invisible':[('id','=',0)]}"/>
                         <button name="fill_survey" states="open" string="Answer Survey" type="object" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>
                         <button name="action_print_survey" states="open,draft,close,cancel" string="Print Answer" type="object"/>
-                        <button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
-                            string="Edit Survey" type="action" context="{'active':True,'edit' : True,'survey_id': active_id}"/>
+                        <button name="edit_survey" states="open,draft,close,cancel"
+                            string="Edit Survey" type="object" context="{'active':True,'edit' : True,'survey_id': active_id}"/>
 
                     </div>
                     <div class="oe_title">

=== modified file 'survey/wizard/survey_answer.py'
--- survey/wizard/survey_answer.py	2012-10-02 10:29:15 +0000
+++ survey/wizard/survey_answer.py	2012-10-11 10:50:53 +0000
@@ -198,6 +198,7 @@
                             etree.SubElement(xml_group1, 'button', {'string':'','icon': "gtk-edit", 'type' :'object', 'name':"action_edit_question", 'context' : tools.ustr(context)})
                             etree.SubElement(xml_group1, 'button', {'string':'','icon': "gtk-delete", 'type' :'object','name':"action_delete_question", 'context' : tools.ustr(context)})
                         else:
+                            etree.SubElement(xml_form, 'newline')
                             etree.SubElement(xml_form, 'separator', {'string': star+to_xml(separator_string)})
 
                         ans_ids = que_rec.answer_choice_ids

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to