From 2138f7608d6061eaebfac460e688fc6f649a1a77 Mon Sep 17 00:00:00 2001 From: "HDA (OpenERP)" Date: Tue, 23 Feb 2010 12:03:50 +0530 Subject: [PATCH 1/6] Added customer price field in product list view bzr revid: hda@tinyerp.com-20100223063350-y1ngdbpys6tfzs2v --- addons/product/product_view.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index 1f7fc3f3c72..9b13ceaf152 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -37,6 +37,7 @@ + From 97d59720514d5c2f3526f8ccefeb5b0d6f1be787 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 23 Feb 2010 08:38:48 +0100 Subject: [PATCH 2/6] [IMP] Scrum views bzr revid: fp@tinyerp.com-20100223073848-gvv82ngbndzepf0a --- addons/project/project_view.xml | 25 ++- addons/project_gtd/project_gtd_view.xml | 2 - addons/scrum/scrum.py | 58 ++--- addons/scrum/scrum_demo.xml | 71 +++--- addons/scrum/scrum_view.xml | 261 +++++++++------------- addons/scrum/scrum_wizard.xml | 2 +- addons/scrum/security/ir.model.access.csv | 4 - addons/scrum/wizard/backlog_to_task.py | 4 +- 8 files changed, 175 insertions(+), 252 deletions(-) diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 945eec1f46c..6daed1f7a0d 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -23,14 +23,22 @@ - - - - - - - - + + + + + + + + + + + + + + + + @@ -411,6 +419,7 @@ + diff --git a/addons/project_gtd/project_gtd_view.xml b/addons/project_gtd/project_gtd_view.xml index 05172675a9a..6e43f96b1ab 100644 --- a/addons/project_gtd/project_gtd_view.xml +++ b/addons/project_gtd/project_gtd_view.xml @@ -90,10 +90,8 @@ - - diff --git a/addons/scrum/scrum.py b/addons/scrum/scrum.py index b1740f433cf..1dd158e39e9 100644 --- a/addons/scrum/scrum.py +++ b/addons/scrum/scrum.py @@ -26,31 +26,16 @@ from osv import fields, osv, orm from mx import DateTime import re -class scrum_team(osv.osv): - _name = 'scrum.team' - _description = 'Scrum Team' - _columns = { - 'name' : fields.char('Team Name', size=64), - 'users_id' : fields.many2many('res.users', 'scrum_team_users_rel', 'team_id','user_id', 'Users'), - } -scrum_team() - class scrum_project(osv.osv): - _name = 'scrum.project' _inherit = 'project.project' - _table = 'project_project' - _description = 'Scrum Project' _columns = { 'product_owner_id': fields.many2one('res.users', 'Product Owner'), - 'tasks': fields.one2many('scrum.task', 'project_id', 'Scrum Tasks'), 'sprint_size': fields.integer('Sprint Days'), - 'scrum': fields.integer('Is Scrum'), - 'parent_id': fields.many2one('scrum.project', 'Parent project'), + 'scrum': fields.integer('Is a Scrum Project'), } _defaults = { 'product_owner_id': lambda self,cr,uid,context={}: uid, - 'warn_manager': lambda *a: 1, - 'sprint_size': lambda *a: 14, + 'sprint_size': lambda *a: 15, 'scrum': lambda *a: 1 } scrum_project() @@ -88,10 +73,10 @@ class scrum_sprint(osv.osv): 'name' : fields.char('Sprint Name', required=True, size=64), 'date_start': fields.date('Starting Date', required=True), 'date_stop': fields.date('Ending Date', required=True), - 'project_id': fields.many2one('scrum.project', 'Project', required=True, domain=[('scrum','=',1)]), + 'project_id': fields.many2one('project.project', 'Project', required=True, domain=[('scrum','=',1)]), 'product_owner_id': fields.many2one('res.users', 'Product Owner', required=True), 'scrum_master_id': fields.many2one('res.users', 'Scrum Master', required=True), - 'meetings_id': fields.one2many('scrum.meeting', 'sprint_id', 'Daily Scrum'), + 'meeting_ids': fields.one2many('scrum.meeting', 'sprint_id', 'Daily Scrum'), 'review': fields.text('Sprint Review'), 'retrospective': fields.text('Sprint Retrospective'), 'backlog_ids': fields.one2many('scrum.product.backlog', 'sprint_id', 'Sprint Backlog'), @@ -107,9 +92,9 @@ class scrum_sprint(osv.osv): def onchange_project_id(self, cr, uid, ids, project_id): v = {} if project_id: - proj = self.pool.get('scrum.project').browse(cr, uid, [project_id])[0] - v['product_owner_id']= proj.product_owner_id.id - v['scrum_master_id']= proj.manager.id + proj = self.pool.get('project.project').browse(cr, uid, [project_id])[0] + v['product_owner_id']= proj.product_owner_id and proj.product_owner_id.id or False + v['scrum_master_id']= proj.user_id and proj.user_id.id or False v['date_stop'] = (DateTime.now() + DateTime.RelativeDateTime(days=int(proj.sprint_size or 14))).strftime('%Y-%m-%d') return {'value':v} @@ -160,36 +145,27 @@ class scrum_product_backlog(osv.osv): 'name' : fields.char('Feature', size=64, required=True), 'note' : fields.text('Note'), 'active' : fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the product backlog without removing it."), - 'project_id': fields.many2one('scrum.project', 'Scrum Project', required=True, domain=[('scrum','=',1)]), - 'user_id': fields.many2one('res.users', 'User'), + 'project_id': fields.many2one('project.project', 'Project', required=True, domain=[('scrum','=',1)]), + 'user_id': fields.many2one('res.users', 'Responsible'), 'sprint_id': fields.many2one('scrum.sprint', 'Sprint'), 'sequence' : fields.integer('Sequence', help="Gives the sequence order when displaying a list of product backlog."), - 'priority' : fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Priority'), - 'tasks_id': fields.one2many('scrum.task', 'product_backlog_id', 'Tasks Details'), - 'state': fields.selection([('draft','Draft'),('open','Open'),('done','Done')], 'State', required=True), - 'progress': fields.function(_calc_progress, method=True, string='Progress (0-100)'), + 'tasks_id': fields.one2many('project.task', 'product_backlog_id', 'Tasks Details'), + 'state': fields.selection([('draft','Draft'),('open','Open'),('done','Done'),('cancel','Cancelled')], 'State', required=True), + 'progress': fields.function(_calc_progress, method=True, string='Progress'), 'effective_hours': fields.function(_calc_effective, method=True, string='Effective hours'), 'planned_hours': fields.function(_calc_planned, method=True, string='Planned Hours') } _defaults = { - 'priority': lambda *a: '4', 'state': lambda *a: 'draft', 'active': lambda *a: 1 } - _order = "priority,sequence" + _order = "sequence" scrum_product_backlog() class scrum_task(osv.osv): - _name = 'scrum.task' _inherit = 'project.task' - _table = 'project_task' - _description = 'Scrum Task' _columns = { 'product_backlog_id': fields.many2one('scrum.product.backlog', 'Product Backlog'), - 'scrum': fields.integer('Is Scrum'), - } - _defaults = { - 'scrum': lambda *a: 1, } def onchange_backlog_id(self, cr, uid, backlog_id): if not backlog_id: @@ -208,19 +184,13 @@ class scrum_meeting(osv.osv): 'question_yesterday': fields.text('Tasks since yesterday'), 'question_today': fields.text('Tasks for today'), 'question_blocks': fields.text('Blocks encountered'), - # - # Should be more formal. - # 'question_backlog': fields.text('Backlog Accurate'), } # - # Find the right sprint thanks to users and date + # TODO: Find the right sprint thanks to users and date # _defaults = { 'date' : lambda *a:time.strftime('%Y-%m-%d'), } scrum_meeting() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/scrum/scrum_demo.xml b/addons/scrum/scrum_demo.xml index fd82337ea24..edb7e1f5857 100644 --- a/addons/scrum/scrum_demo.xml +++ b/addons/scrum/scrum_demo.xml @@ -2,9 +2,9 @@ - + - + [24, 25, 28, 26, 27, 29, 30, 31, 32, 33, 34, 35, 37, 36, 38] @@ -24,10 +24,7 @@ open - - - - + 3 @@ -79,111 +76,111 @@ - + - + 4.0 - + Review all English Terms - + 4.0 - + Review all french terms - + 24.0 - + Analytic Accounting features - + 6.0 - + Test and improve automatic migration system - + 24.0 - + General accounting features - + 24.0 - + Accounting Budgets - + 24.0 - + Cash book, general ledger, accounts list, aged trial balance Accounting Report General - + 7.0 - + Accounting Report Budget - + 8.0 - + Accounting Report Analytic - + 4.0 - + Bugfix - memory leak - + 2.0 - + Bugfix - Translations - + 4.0 - + Finish the automated plugin system - + 4.0 - + Reshape the complete menu structure - + 5.0 - + Test 3.2.0 before releasing - + 12.0 - + default values, onchange, required, add on top or bottom and shortcuts (Ctrl S, Ctrl X, ...) Editable trees diff --git a/addons/scrum/scrum_view.xml b/addons/scrum/scrum_view.xml index 521f2c53838..b3605d4270b 100644 --- a/addons/scrum/scrum_view.xml +++ b/addons/scrum/scrum_view.xml @@ -2,63 +2,28 @@ - - - + - - scrum.project.form - scrum.project + + project.project.form + project.project form - - - - - - + + + + + + + - - scrum.project.tree - scrum.project - tree - child_id - - - - - - - - - - - - Projects - scrum.project - tree - - [('parent_id','=',False),('scrum','=',1)] - - - - - Edit Projects - scrum.project - form - - [('scrum','=',1)] - - - - @@ -68,12 +33,13 @@ scrum.product.backlog tree - - - + + + - + + @@ -86,59 +52,76 @@ scrum.product.backlog form -
+ + + + + + + - - - - - - - - - - + + + + +
- scrum.product.backlog.search - scrum.product.backlog - search - - - - - - - - - - - - - - - + scrum.product.backlog.search + scrum.product.backlog + search + + + + + + + + + + + + + + + + +
- Backlogs + Product Backlogs scrum.product.backlog form - + @@ -349,64 +338,28 @@ --> - scrum.task.form - scrum.task + project.task.scrum.form + project.task form - - - + - scrum.task.search - scrum.task + project.task.scrum.search + project.task search - - - + + + - - All Tasks - scrum.task - form - tree,form - [('scrum','=',1)] - - - - - - tree - - - - - - - form - - - - - - - - Opened tasks - scrum.task - form - tree,form - [('state','=','open'),('scrum','=',1)] - - -
diff --git a/addons/scrum/scrum_wizard.xml b/addons/scrum/scrum_wizard.xml index 5c8020d15a3..9a15c1e5829 100644 --- a/addons/scrum/scrum_wizard.xml +++ b/addons/scrum/scrum_wizard.xml @@ -1,6 +1,6 @@ - + diff --git a/addons/scrum/security/ir.model.access.csv b/addons/scrum/security/ir.model.access.csv index 2c139b10b26..a52a9c2f3f2 100644 --- a/addons/scrum/security/ir.model.access.csv +++ b/addons/scrum/security/ir.model.access.csv @@ -1,11 +1,7 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_scrum_team","scrum.team","model_scrum_team","project.group_project_user",1,1,1,1 -"access_scrum_project","scrum.project","model_scrum_project","project.group_project_user",1,1,1,1 "access_scrum_sprint","scrum.sprint","model_scrum_sprint","project.group_project_user",1,,, "access_scrum_product_backlog","scrum.product.backlog","model_scrum_product_backlog","project.group_project_user",1,1,1,1 -"access_scrum_task","scrum.task","model_scrum_task","project.group_project_user",1,1,1,1 "access_scrum_meeting","scrum.meeting","model_scrum_meeting","project.group_project_user",1,,, "access_scrum_meeting_manager","scrum.meeting.manager","model_scrum_meeting","project.group_project_manager",1,1,1,1 "access_scrum_sprint_manager","scrum.sprint.manager","model_scrum_sprint","project.group_project_manager",1,1,1,1 "access_scrum_product_backlog_manager","scrum.product.backlog manager","model_scrum_product_backlog","project.group_project_manager",1,1,1,1 -"access_scrum_project_manager","scrum.project manager","model_scrum_project","project.group_project_manager",1,1,1,1 diff --git a/addons/scrum/wizard/backlog_to_task.py b/addons/scrum/wizard/backlog_to_task.py index 284d5b1a5f4..79742a8e43b 100644 --- a/addons/scrum/wizard/backlog_to_task.py +++ b/addons/scrum/wizard/backlog_to_task.py @@ -42,7 +42,7 @@ def _do_create(self, cr, uid, data, context): id = mod_obj.read(cr, uid, result, ['res_id']) ids = [] for backlog in backlogs: - task = pooler.get_pool(cr.dbname).get('scrum.task') + task = pooler.get_pool(cr.dbname).get('project.task') ids.append(task.create(cr, uid, { 'product_backlog_id': backlog.id, 'name': backlog.name, @@ -58,7 +58,7 @@ def _do_create(self, cr, uid, data, context): 'name': 'Open Backlog Tasks', 'view_type': 'form', 'view_mode': 'tree,form', - 'res_model': 'scrum.task', + 'res_model': 'project.task', 'view_id': False, 'type': 'ir.actions.act_window', 'search_view_id': id['res_id'] From 111d3563b07c8fd0a4b52ccb5f70b78272e05489 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Tue, 23 Feb 2010 15:02:23 +0530 Subject: [PATCH 3/6] [IMP]:survey,crm_hr,hr_evaluation.(Ref-YSA,APA) -Rename Defination into Definition. -When you click on test, answer or edit survey, remove the first screen with the selection box to select the survey. -Add survey Types in demo data: Human Resources, Customer Feeback, Supplier Selection. -In search view of surveys, remove the vertical separator between draft and open buttons, for type field set widget=selection. -The button for responsible=my in the search view must be default="1". -change demo data so that some surveys belongs to admin and some to demo user. -The browse Response report must be renamed into "Print Answers". -Browse the answer in the screen instead of printing a PDF. -In the history one2many, first put the date and then the user. -I started a survey but did not finished it. so that's normal but I was not able to restart the survey (it says I already answered). -Removed the "Que: " prefix in each report. bzr revid: apa@tinyerp.com-20100223093223-vwhgkn8kmdo8e6mo --- addons/crm_hr/crm_hr_data.xml | 2 + addons/hr_evaluation/hr_evaluation_data.xml | 4 + .../survey/report/survey_analysis_report.py | 2 +- .../survey/report/survey_browse_response.py | 4 +- addons/survey/report/survey_form.py | 2 +- addons/survey/survey.py | 200 +++++++++++++----- addons/survey/survey_demo.xml | 26 ++- addons/survey/survey_que_wizard.xml | 32 +++ addons/survey/survey_report.xml | 2 +- addons/survey/survey_view.xml | 28 +-- addons/survey/survey_wizard.xml | 3 +- 11 files changed, 228 insertions(+), 77 deletions(-) diff --git a/addons/crm_hr/crm_hr_data.xml b/addons/crm_hr/crm_hr_data.xml index d52a35f5bae..845b58684aa 100644 --- a/addons/crm_hr/crm_hr_data.xml +++ b/addons/crm_hr/crm_hr_data.xml @@ -82,6 +82,8 @@ draft 20 + + diff --git a/addons/hr_evaluation/hr_evaluation_data.xml b/addons/hr_evaluation/hr_evaluation_data.xml index b7ef9777ffd..7f0e6fc7e4c 100644 --- a/addons/hr_evaluation/hr_evaluation_data.xml +++ b/addons/hr_evaluation/hr_evaluation_data.xml @@ -5,6 +5,8 @@ Employee Evaluation 20 + + @@ -12,6 +14,8 @@ Employee Opinion 20 + + diff --git a/addons/survey/report/survey_analysis_report.py b/addons/survey/report/survey_analysis_report.py index 3f0bb345503..e95270bf80b 100755 --- a/addons/survey/report/survey_analysis_report.py +++ b/addons/survey/report/survey_analysis_report.py @@ -137,7 +137,7 @@ class survey_analysis(report_rml): for que in page.question_ids: rml +=""" - Que : """ + to_xml(tools.ustr(que.question)) + """ + """ + to_xml(tools.ustr(que.question)) + """ """ cols_widhts = [] diff --git a/addons/survey/report/survey_browse_response.py b/addons/survey/report/survey_browse_response.py index 40c75755e1f..2cc9fd0de8b 100644 --- a/addons/survey/report/survey_browse_response.py +++ b/addons/survey/report/survey_browse_response.py @@ -203,7 +203,7 @@ class survey_browse_response(report_rml): """ + to_xml(time.strftime('%d-%m-%Y %I:%M:%S %p', time.strptime(response.date_create.split('.')[0], '%Y-%m-%d %H:%M:%S'))) + """ Response By:- - """ + to_xml(response.user_id.name) + """ + """ + to_xml(response.user_id.login) + """ """ status = "Not Finished" @@ -232,7 +232,7 @@ class survey_browse_response(report_rml): for que in page.question_ids: rml += """ - Que : """ + to_xml(to_xml(que.question)) + """ + """ + to_xml(to_xml(que.question)) + """ """ answer = surv_resp_line_obj.browse(cr ,uid, surv_resp_line_obj.search(cr, uid, [('question_id', '=', que.id),('response_id', '=', response.id)])) if que.type in ['descriptive_text']: diff --git a/addons/survey/report/survey_form.py b/addons/survey/report/survey_form.py index d06be9dc44c..6d62726fff5 100644 --- a/addons/survey/report/survey_form.py +++ b/addons/survey/report/survey_form.py @@ -174,7 +174,7 @@ class survey_form(report_rml): rml +=""" - Que : """ + to_xml(tools.ustr(que.question)) + """ + """ + to_xml(tools.ustr(que.question)) + """ """ if que.type in ['descriptive_text']: diff --git a/addons/survey/survey.py b/addons/survey/survey.py index cd3584f5361..66ee537bfbb 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -49,7 +49,6 @@ class survey(osv.osv): def default_get(self, cr, uid, fields, context={}): data = super(survey, self).default_get(cr, uid, fields, context) - data['responsible_id'] = uid return data _columns = { @@ -68,7 +67,7 @@ class survey(osv.osv): 'history' : fields.one2many('survey.history', 'survey_id', 'History Lines', readonly=True), 'users': fields.many2many('res.users', 'survey_users_rel', 'sid', 'uid', 'Users'), 'send_response' : fields.boolean('E-mail Notification on Response'), - 'type' : fields.many2one('survey.type', 'Type') + 'type' : fields.many2one('survey.type', 'Type'), } _defaults = { 'state' : lambda * a: "draft", @@ -97,6 +96,7 @@ class survey(osv.osv): def copy(self, cr, uid, id, default=None,context={}): raise osv.except_osv(_('Error !'),_('You cannot duplicate the resource!')) + survey() class survey_history(osv.osv): @@ -177,7 +177,6 @@ class survey_question(osv.osv): for id in ids1: val[id] = 0 return val - _columns = { 'page_id' : fields.many2one('survey.page', 'Survey Page', ondelete='cascade', required=1), 'question' : fields.char('Question', size=128, required=1), @@ -519,6 +518,7 @@ class survey_response(osv.osv): 'state' : lambda * a: "skip", 'response_type' : lambda * a: "manually", } + def copy(self, cr, uid, id, default=None,context={}): raise osv.except_osv(_('Error !'),_('You cannot duplicate the resource!')) @@ -577,6 +577,8 @@ class survey_name_wiz(osv.osv_memory): _name = 'survey.name.wiz' def default_get(self, cr, uid, fields, context={}): + if not context: + context = {} data = super(survey_name_wiz, self).default_get(cr, uid, fields, context) if context.has_key('survey_id'): data['survey_id'] = context['survey_id'] @@ -620,20 +622,16 @@ class survey_name_wiz(osv.osv_memory): sur_id = self.read(cr, uid, ids, [])[0] survey_id = sur_id['survey_id'] context.update({'survey_id' : survey_id, 'sur_name_id' : sur_id['id']}) - if not context.has_key('active'): - cr.execute('select count(id) from survey_history where user_id=%s\ - and survey_id=%s' % (uid,survey_id)) - res = cr.fetchone()[0] - user_limit = self.pool.get('survey').read(cr, uid, survey_id, ['response_user'])['response_user'] - if user_limit and res >= user_limit: - raise osv.except_osv(_('Warning !'),_("You can not give response for this survey more than %s times") % (user_limit)) - his_id = self.pool.get('survey.history').create(cr, uid, {'user_id': uid, \ - 'date': strftime('%Y-%m-%d %H:%M:%S'), 'survey_id': survey_id}) - survey_obj = self.pool.get('survey') - sur_rec = survey_obj.read(cr,uid,self.read(cr,uid,ids)[0]['survey_id']) - if sur_rec['max_response_limit'] and sur_rec['max_response_limit'] <= sur_rec['tot_start_survey']: - raise osv.except_osv(_('Warning !'),_("You can not give more response. Please contact the author of this survey for further assistance.")) - survey_obj.write(cr, uid, survey_id, {'tot_start_survey' : sur_rec['tot_start_survey'] + 1}) + cr.execute('select count(id) from survey_history where user_id=%s\ + and survey_id=%s' % (uid,survey_id)) + res = cr.fetchone()[0] + user_limit = self.pool.get('survey').read(cr, uid, survey_id, ['response_user'])['response_user'] + if user_limit and res >= user_limit: + raise osv.except_osv(_('Warning !'),_("You can not give response for this survey more than %s times") % (user_limit)) + survey_obj = self.pool.get('survey') + sur_rec = survey_obj.read(cr,uid,self.read(cr,uid,ids)[0]['survey_id']) + if sur_rec['max_response_limit'] and sur_rec['max_response_limit'] <= sur_rec['tot_start_survey']: + raise osv.except_osv(_('Warning !'),_("You can not give more response. Please contact the author of this survey for further assistance.")) search_obj = self.pool.get('ir.ui.view') search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')]) return { @@ -662,7 +660,15 @@ class survey_question_wiz(osv.osv_memory): result = super(survey_question_wiz, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) surv_name_wiz = self.pool.get('survey.name.wiz') if view_type in ['form']: - sur_name_rec = surv_name_wiz.read(cr, uid, context['sur_name_id']) + wiz_id = 0 + if not context.has_key('sur_name_id'): + wiz_id = surv_name_wiz.create(cr,uid, {'survey_id' : context['survey_id'],'page_no' :-1,'page':'next','transfer' :1,'response':0}) + sur_name_rec = surv_name_wiz.read(cr, uid, wiz_id, []) + context.update({'sur_name_id' :wiz_id}) + else: + sur_name_rec = surv_name_wiz.read(cr, uid, context['sur_name_id']) + + if context.has_key('active_id'): context.pop('active_id') survey_id = context['survey_id'] survey_obj = self.pool.get('survey') sur_rec = survey_obj.read(cr, uid, survey_id, []) @@ -674,6 +680,9 @@ class survey_question_wiz(osv.osv_memory): p_id = sur_rec['page_ids'] total_pages = len(p_id) pre_button = False + readonly = 0 + if context.has_key('response_id'): + readonly = 1 if not sur_name_rec['page_no'] + 1 : surv_name_wiz.write(cr, uid, [context['sur_name_id']], {'store_ans':{}}) sur_name_read = surv_name_wiz.read(cr, uid, context['sur_name_id']) @@ -681,6 +690,7 @@ class survey_question_wiz(osv.osv_memory): if sur_name_read['transfer'] or not sur_name_rec['page_no'] + 1: surv_name_wiz.write(cr, uid, [context['sur_name_id']], {'transfer':False}) flag = False + fields = {} if sur_name_read['page'] == "next" or sur_name_rec['page_no'] == - 1 : if len(p_id) > sur_name_rec['page_no'] + 1 : if sur_rec['max_response_limit'] and sur_rec['max_response_limit'] <= sur_rec['tot_start_survey'] and not sur_name_rec['page_no'] + 1: @@ -700,10 +710,13 @@ class survey_question_wiz(osv.osv_memory): if sur_name_rec['page_no'] > 1: pre_button = True if flag: - fields = {} pag_rec = page_obj.read(cr, uid, p_id) xml_form = etree.Element('form', {'string': _(tools.ustr(pag_rec['title']))}) xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'}) + if wiz_id: + fields["wizardid_" + str(wiz_id)] = {'type':'char', 'size' : 255, 'string':"", 'views':{}} + etree.SubElement(xml_form, 'field', {'invisible':'1','name': "wizardid_" + str(wiz_id),'default':str(lambda *a: 0)}) + if pag_rec['note']: for que_test in pag_rec['note'].split('\n'): etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_test)), 'align':"0.0"}) @@ -736,12 +749,12 @@ class survey_question_wiz(osv.osv_memory): for ans in ans_ids: selection.append((tools.ustr(ans['id']), ans['answer'])) xml_group = etree.SubElement(xml_group, 'group', {'col': '2', 'colspan': '2'}) - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_selection"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_selection"}) fields[tools.ustr(que) + "_selection"] = {'type':'selection', 'selection' :selection, 'string':"Answer"} elif que_rec['type'] == 'multiple_choice_multiple_ans': xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'}) for ans in ans_ids: - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(ans['id'])}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_" + tools.ustr(ans['id'])}) fields[tools.ustr(que) + "_" + tools.ustr(ans['id'])] = {'type':'boolean', 'string':ans['answer']} elif que_rec['type'] in ['matrix_of_choices_only_one_ans', 'rating_scale']: if que_rec['comment_column']: @@ -753,14 +766,14 @@ class survey_question_wiz(osv.osv_memory): xml_group = etree.SubElement(xml_group, 'group', {'col': tools.ustr(col), 'colspan': tools.ustr(colspan)}) for row in ans_ids: etree.SubElement(xml_group, 'newline') - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_selection_" + tools.ustr(row['id']),'string':to_xml(tools.ustr(row['answer']))}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_selection_" + tools.ustr(row['id']),'string':to_xml(tools.ustr(row['answer']))}) selection = [('','')] for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']): selection.append((str(col['id']), col['title'])) fields[tools.ustr(que) + "_selection_" + tools.ustr(row['id'])] = {'type':'selection', 'selection' : selection, 'string': "Answer"} if que_rec['comment_column']: fields[tools.ustr(que) + "_commentcolumn_"+tools.ustr(row['id']) + "_field"] = {'type':'char', 'size' : 255, 'string':tools.ustr(que_rec['column_name']), 'views':{}} - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_commentcolumn_"+tools.ustr(row['id'])+ "_field"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_commentcolumn_"+tools.ustr(row['id'])+ "_field"}) elif que_rec['type'] == 'matrix_of_choices_only_multi_ans': xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec['column_heading_ids']) + 1), 'colspan': '4'}) etree.SubElement(xml_group, 'separator', {'string': '.','colspan': '1'}) @@ -769,7 +782,7 @@ class survey_question_wiz(osv.osv_memory): for row in ans_ids: etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(row['answer'])) +' :-', 'align': '0.0'}) for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']): - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id']), 'nolabel':"1"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id']), 'nolabel':"1"}) fields[tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id'])] = {'type':'boolean', 'string': col['title']} elif que_rec['type'] == 'matrix_of_drop_down_menus': xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec['column_heading_ids']) + 1), 'colspan': '4'}) @@ -783,7 +796,7 @@ class survey_question_wiz(osv.osv_memory): if col['menu_choice']: for item in col['menu_choice'].split('\n'): if item and not item.strip() == '': selection.append((item ,item)) - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id']),'nolabel':'1'}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id']),'nolabel':'1'}) fields[tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id'])] = {'type':'selection', 'string': col['title'], 'selection':selection} elif que_rec['type'] == 'multiple_textboxes': xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'}) @@ -796,7 +809,7 @@ class survey_question_wiz(osv.osv_memory): elif que_rec['validation_type'] in ['must_be_date']: type = "date" for ans in ans_ids: - etree.SubElement(xml_group, 'field', {'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"}) if type == "char" : fields[tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"] = {'type':'char', 'size':255, 'string':ans['answer']} else: @@ -804,26 +817,26 @@ class survey_question_wiz(osv.osv_memory): elif que_rec['type'] == 'numerical_textboxes': xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'}) for ans in ans_ids: - etree.SubElement(xml_group, 'field', {'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_numeric"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_numeric"}) fields[tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_numeric"] = {'type':'integer', 'string':ans['answer']} elif que_rec['type'] == 'date': xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'}) for ans in ans_ids: - etree.SubElement(xml_group, 'field', {'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id'])}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id'])}) fields[tools.ustr(que) + "_" + tools.ustr(ans['id'])] = {'type':'date', 'string':ans['answer']} elif que_rec['type'] == 'date_and_time': xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'}) for ans in ans_ids: - etree.SubElement(xml_group, 'field', {'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id'])}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id'])}) fields[tools.ustr(que) + "_" + tools.ustr(ans['id'])] = {'type':'datetime', 'string':ans['answer']} elif que_rec['type'] == 'descriptive_text': for que_test in que_rec['descriptive_text'].split('\n'): etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_test)), 'align':"0.0"}) elif que_rec['type'] == 'single_textbox': - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_single", 'nolabel':"1" ,'colspan':"4"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_single", 'nolabel':"1" ,'colspan':"4"}) fields[tools.ustr(que) + "_single"] = {'type':'char', 'size' : 255, 'string':"single_textbox", 'views':{}} elif que_rec['type'] == 'comment': - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_comment", 'nolabel':"1" ,'colspan':"4"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_comment", 'nolabel':"1" ,'colspan':"4"}) fields[tools.ustr(que) + "_comment"] = {'type':'text', 'string':"Comment/Eassy Box", 'views':{}} elif que_rec['type'] == 'table': xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec['column_heading_ids'])), 'colspan': '4'}) @@ -831,16 +844,16 @@ class survey_question_wiz(osv.osv_memory): etree.SubElement(xml_group, 'separator', {'string': tools.ustr(col['title']),'colspan': '1'}) for row in range(0,que_rec['no_of_rows']): for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']): - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_table_" + tools.ustr(col['id']) +"_"+ tools.ustr(row), 'nolabel':"1"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_table_" + tools.ustr(col['id']) +"_"+ tools.ustr(row), 'nolabel':"1"}) fields[tools.ustr(que) + "_table_" + tools.ustr(col['id']) +"_"+ tools.ustr(row)] = {'type':'char','size':255,'views':{}} elif que_rec['type'] == 'multiple_textboxes_diff_type': xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'}) for ans in ans_ids: if ans['type'] == "email" : fields[tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"] = {'type':'char', 'size':255, 'string':ans['answer']} - etree.SubElement(xml_group, 'field', {'widget':'email','width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'widget':'email','width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"}) else: - etree.SubElement(xml_group, 'field', {'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"}) if ans['type'] == "char" : fields[tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"] = {'type':'char', 'size':255, 'string':ans['answer']} elif ans['type'] in ['integer','float','date','datetime']: @@ -853,22 +866,22 @@ class survey_question_wiz(osv.osv_memory): fields[tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"] = {'type':'selection', 'selection' : selection, 'string':ans['answer']} if que_rec['type'] in ['multiple_choice_only_one_ans', 'multiple_choice_multiple_ans', 'matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'matrix_of_drop_down_menus', 'rating_scale'] and que_rec['is_comment_require']: if que_rec['type'] in ['multiple_choice_only_one_ans', 'multiple_choice_multiple_ans'] and que_rec['comment_field_type'] in ['char','text'] and que_rec['make_comment_field']: - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_otherfield", 'colspan':"4"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_otherfield", 'colspan':"4"}) fields[tools.ustr(que) + "_otherfield"] = {'type':'boolean', 'string':que_rec['comment_label'], 'views':{}} if que_rec['comment_field_type'] == 'char': - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"}) fields[tools.ustr(que) + "_other"] = {'type': 'char', 'string': '', 'size':255, 'views':{}} elif que_rec['comment_field_type'] == 'text': - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"}) fields[tools.ustr(que) + "_other"] = {'type': 'text', 'string': '', 'views':{}} else: if que_rec['comment_field_type'] == 'char': etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_rec['comment_label'])),'colspan':"4"}) - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"}) fields[tools.ustr(que) + "_other"] = {'type': 'char', 'string': '', 'size':255, 'views':{}} elif que_rec['comment_field_type'] == 'text': etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_rec['comment_label'])),'colspan':"4"}) - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"}) + etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"}) fields[tools.ustr(que) + "_other"] = {'type': 'text', 'string': '', 'views':{}} etree.SubElement(xml_form, 'separator', {'colspan': '4'}) xml_group = etree.SubElement(xml_form, 'group', {'col': '6', 'colspan': '4'}) @@ -878,7 +891,7 @@ class survey_question_wiz(osv.osv_memory): etree.SubElement(xml_group, 'button', {'icon': "gtk-cancel", 'special': "cancel",'string':"Cancel"}) if pre_button: etree.SubElement(xml_group, 'button', {'colspan':"1",'icon':"gtk-go-back",'name':"action_previous",'string':"Previous",'type':"object"}) - etree.SubElement(xml_group, 'button', {'icon': "gtk-go-forward", 'name':"action_next",'string':"Next",'type':"object"}) + etree.SubElement(xml_group, 'button', {'icon': "gtk-go-forward", 'name':"action_next",'string':"Next",'type':"object",'context' : tools.ustr(context)}) if context.has_key('active') and context.has_key('edit'): etree.SubElement(xml_form, 'separator', {'string' : '','colspan': '4'}) context.update({'page_id' : tools.ustr(p_id),'page_number' : sur_name_rec['page_no'] , 'transfer' : sur_name_read['transfer']}) @@ -959,15 +972,54 @@ class survey_question_wiz(osv.osv_memory): tot_page_id = self.pool.get('survey').browse(cr, uid, context['survey_id']) tot_per = (float(100) * (int(field.split('_')[2]) + 1) / len(tot_page_id.page_ids)) value[field] = tot_per - if context.has_key('active') and context['active']: - return value - surv_name_wiz = self.pool.get('survey.name.wiz') - sur_name_read = surv_name_wiz.read(cr, uid, context['sur_name_id']) - ans_list = [] - for key,val in sur_name_read['store_ans'].items(): - for field in fields_list: - if field in list(val): - value[field] = val[field] + if context.has_key('response_id'): + response_obj = self.pool.get('survey.response') + response_ans = response_obj.browse(cr, uid, context['response_id']) + fields_list.sort() + for que in response_ans.question_ids: + for field in fields_list: + if field.split('_')[0] != "progress" and field.split('_')[0] == str(que.question_id.id): + if que.response_answer_ids and len(field.split('_')) == 4 and field.split('_')[1] == "commentcolumn" and field.split('_')[3] == "field": + for ans in que.response_answer_ids: + if str(field.split('_')[2]) == str(ans.answer_id.id): + value[field] = ans.comment_field + if que.response_table_ids and len(field.split('_')) == 4 and field.split('_')[1] == "table": + for ans in que.response_table_ids: + if str(field.split('_')[2]) == str(ans.column_id.id) and str(field.split('_')[3]) == str(ans.name): + value[field] = ans.value + if que.comment and (field.split('_')[1] == "comment" or field.split('_')[1] == "other"): + value[field] = str(que.comment) + elif que.single_text and field.split('_')[1] == "single": + value[field] = str(que.single_text) + elif que.response_answer_ids and len(field.split('_')) == 3 and field.split('_')[1] == "selection": + for ans in que.response_answer_ids: + if str(field.split('_')[2]) == str( ans.answer_id.id): + value[field] = str(ans.column_id.id) + elif que.response_answer_ids and len(field.split('_')) == 2 and field.split('_')[1] == "selection": + value[field] = str(que.response_answer_ids[0].answer_id.id) + elif que.response_answer_ids and len(field.split('_')) == 3 and field.split('_')[2] != "multi" and field.split('_')[2] != "numeric": + for ans in que.response_answer_ids: + if str(field.split('_')[1]) == str( ans.answer_id.id) and str(field.split('_')[2]) == str(ans.column_id.id): + if ans.value_choice: + value[field] = ans.value_choice + else: + value[field] = True + else: + for ans in que.response_answer_ids: + if str(field.split('_')[1]) == str( ans.answer_id.id): + value[field] = ans.answer + else: + if not context.has_key('sur_name_id'): + return value + if context.has_key('active') and context['active']: + return value + surv_name_wiz = self.pool.get('survey.name.wiz') + sur_name_read = surv_name_wiz.read(cr, uid, context['sur_name_id']) + ans_list = [] + for key,val in sur_name_read['store_ans'].items(): + for field in fields_list: + if field in list(val): + value[field] = val[field] return value def create(self, cr, uid, vals, context=None): @@ -976,13 +1028,15 @@ class survey_question_wiz(osv.osv_memory): for key,val in vals.items(): if key.split('_')[0] == "progress": vals.pop(key) - break + if not context.has_key('sur_name_id') and key.split('_')[0] == "wizardid": + context.update({'sur_name_id': int(key.split('_')[1])}) + vals.pop(key) click_state = True click_update = [] surv_name_wiz = self.pool.get('survey.name.wiz') surv_all_resp_obj = self.pool.get('survey.response') surv_tbl_column_obj = self.pool.get('survey.tbl.column.heading') - sur_name_read = surv_name_wiz.read(cr, uid, context['sur_name_id']) + sur_name_read = surv_name_wiz.read(cr, uid, context['sur_name_id'], []) response_id = 0 if not sur_name_read['response']: response_id = surv_all_resp_obj.create(cr, uid, {'response_type':'link', 'user_id':uid, 'date_create':datetime.datetime.now(), 'survey_id' : context['survey_id']}) @@ -992,6 +1046,13 @@ class survey_question_wiz(osv.osv_memory): if response_id not in surv_all_resp_obj.search(cr, uid, []): response_id = surv_all_resp_obj.create(cr, uid, {'response_type':'link', 'user_id':uid, 'date_create':datetime.datetime.now(), 'survey_id' : context['survey_id']}) surv_name_wiz.write(cr, uid, [context['sur_name_id']], {'response' : tools.ustr(response_id)}) + #click first time on next button then increemnet on total start suvey + if not sur_name_read['store_ans']: + his_id = self.pool.get('survey.history').create(cr, uid, {'user_id': uid, \ + 'date': strftime('%Y-%m-%d %H:%M:%S'), 'survey_id': sur_name_read['survey_id']}) + survey_obj = self.pool.get('survey') + sur_rec = survey_obj.read(cr, uid, sur_name_read['survey_id']) + survey_obj.write(cr, uid, sur_name_read['survey_id'], {'tot_start_survey' : sur_rec['tot_start_survey'] + 1}) for key,val in sur_name_read['store_ans'].items(): for field in vals: if field.split('_')[0] == val['question_id']: @@ -1530,4 +1591,39 @@ class survey_request(osv.osv): survey_request() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + +class survey_print_answer(osv.osv_memory): + _name = 'survey.print.answer' + + def _get_survey(self, cr, uid, context=None): + surv_obj = self.pool.get("survey") + surv_resp_obj = self.pool.get("survey.response") + result = [] + for sur in surv_obj.browse(cr, uid, surv_obj.search(cr, uid, [])): + if surv_resp_obj.search(cr, uid, [('survey_id', '=', sur.id)]): + result.append((sur.id, sur.title)) + return result + + _columns = { + 'survey_id': fields.selection(_get_survey, "Survey", required="1"), + 'response_id': fields.many2one("survey.response", "Survey Response", required="1"), + } + + def action_next(self, cr, uid, ids, context=None): + response_id = self.read(cr, uid, ids, [])[0] + context.update({'active' : True,'survey_id' : response_id['survey_id'], 'response_id' : response_id['response_id']}) + search_obj = self.pool.get('ir.ui.view') + search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')]) + return { + 'view_type': 'form', + "view_mode": 'form', + 'res_model': 'survey.question.wiz', + 'type': 'ir.actions.act_window', + 'target': 'new', + 'search_view_id':search_id[0], + 'context' : context + } + +survey_print_answer() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/survey/survey_demo.xml b/addons/survey/survey_demo.xml index a65abbc9e96..6cc5a1acc59 100644 --- a/addons/survey/survey_demo.xml +++ b/addons/survey/survey_demo.xml @@ -2,12 +2,25 @@ + + Human Resources + Human Resources + + + Customer Feeback + Customer Feeback + + + Supplier Selection + Supplier Selection + + Open ERP Partner Feedback - - Que + 20 + @@ -476,9 +489,9 @@ Odoo Feedback - Que - + 20 + @@ -1264,9 +1277,9 @@ - - Que + 20 + @@ -2143,6 +2156,7 @@ + diff --git a/addons/survey/survey_que_wizard.xml b/addons/survey/survey_que_wizard.xml index e9b313775e6..6b52bc66c23 100644 --- a/addons/survey/survey_que_wizard.xml +++ b/addons/survey/survey_que_wizard.xml @@ -77,6 +77,38 @@ form new + + + + + + Survey + survey.print.answer + form + +
+ + + + +