Chandni Gandhi has proposed merging lp:~openerp-dev/openobject-addons/trunk-bug-1103057-cga into lp:openobject-addons.
Requested reviews: OpenERP Core Team (openerp) Related bugs: Bug #1103057 in OpenERP Addons: "[7.0/trunk] Survey - Can not delete anwsers" https://bugs.launchpad.net/openobject-addons/+bug/1103057 For more details, see: https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1103057-cga/+merge/146564 Hello, Add unlink for survey answers. Thanks. -- https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1103057-cga/+merge/146564 Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-1103057-cga.
=== modified file 'survey/survey.py' --- survey/survey.py 2012-12-06 14:56:32 +0000 +++ survey/survey.py 2013-02-05 06:26:20 +0000 @@ -400,7 +400,10 @@ val.update({'in_visible_rating_weight':True, 'in_visible_menu_choice':True,\ 'in_visible_answer_type':True}) return {'value': val} - + + def unlink(self, cr, uid, ids, context=None): + return osv.osv.unlink(self, cr, uid, ids, context=context) + 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', 'page_id', 'question']) @@ -428,8 +431,6 @@ for ans in vals['answer_choice_ids']: if type(ans[2]) == type({}): ans_len += 1 - else: - ans_len -= 1 if que_type not in ['descriptive_text', 'single_textbox', 'comment','table']: if not ans_len: @@ -650,7 +651,14 @@ context = {} data = super(survey_answer, self).default_get(cr, uid, fields, context) return data - + + def unlink(self, cr, uid, ids, context=None): + q = self.browse(cr,uid,ids[0]).question_id + res = osv.osv.unlink(self, cr, uid, ids, context=context) + + if not len(q.answer_choice_ids): + raise osv.except_osv(_('Warning!'),_('You must enter at least one Answers for question "%s"') % (q.question)) + return res survey_answer() class survey_response(osv.osv):
_______________________________________________ Mailing list: https://launchpad.net/~openerp-dev-gtk Post to : openerp-dev-gtk@lists.launchpad.net Unsubscribe : https://launchpad.net/~openerp-dev-gtk More help : https://help.launchpad.net/ListHelp