diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index f88d38734f2..454290c3c5f 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -241,6 +241,8 @@ class account_cash_statement(osv.osv): } def create(self, cr, uid, vals, context=None): + if 'journal_id' not in vals: + raise osv.except_osv('Error', _('You cannot create a bank or cash register without a journal!')) sql = [ ('journal_id', '=', vals['journal_id']), ('state', '=', 'open') @@ -381,4 +383,4 @@ class account_cash_statement(osv.osv): account_cash_statement() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index 4e53a895587..7c02334a9fb 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -732,12 +732,16 @@ class email_template_preview(osv.osv_memory): ref_obj_name = self.pool.get('ir.model').read(cr, uid, ref_obj_id['object_name'][0], ['model'], context)['model'] model_obj = self.pool.get(ref_obj_name) ref_obj_ids = model_obj.search(cr, uid, [], 0, 20, 'id desc', context=context) + if not ref_obj_ids: + ref_obj_ids = [] # also add the default one if requested, otherwise it won't be available for selection: default_id = context.get('default_rel_model_ref') if default_id and default_id not in ref_obj_ids: ref_obj_ids.insert(0, default_id) return model_obj.name_get(cr, uid, ref_obj_ids, context) + else: + return [] def default_get(self, cr, uid, fields, context=None): if context is None: @@ -761,7 +765,7 @@ class email_template_preview(osv.osv_memory): user, context['template_id'], ['object_name'], - context)['object_name'] + context)['object_name'] or False _columns = { 'ref_template':fields.many2one( @@ -788,7 +792,7 @@ class email_template_preview(osv.osv_memory): 'report':fields.char('Report Name', size=100, readonly=True), } _defaults = { - 'ref_template': lambda self, cr, uid, ctx:ctx['template_id'], + 'ref_template': lambda self, cr, uid, ctx:ctx['template_id'] or False, 'rel_model': _default_model, } def on_change_ref(self, cr, uid, ids, rel_model_ref, context=None): diff --git a/addons/product_expiry/product_expiry.py b/addons/product_expiry/product_expiry.py index fbfa7dc1610..01ce50dead8 100644 --- a/addons/product_expiry/product_expiry.py +++ b/addons/product_expiry/product_expiry.py @@ -40,7 +40,7 @@ class stock_production_lot(osv.osv): # set date to False when no expiry time specified on the product date = duration and (datetime.datetime.today() + datetime.timedelta(days=duration)) - return date and date.strftime('%Y-%m-%d %H:%M:%S') + return date and date.strftime('%Y-%m-%d %H:%M:%S') or False return calc_date _columns = { diff --git a/addons/project/report/project_report_view.xml b/addons/project/report/project_report_view.xml index 832967f115a..aec1296b3c4 100644 --- a/addons/project/report/project_report_view.xml +++ b/addons/project/report/project_report_view.xml @@ -149,7 +149,7 @@ This report allows you to analyse the performance of your projects and users. You can analyse the quantities of tasks, the hours spent compared to the planned hours, the average number of days to open or close a task, etc. - + diff --git a/addons/project/test/test_project.yml b/addons/project/test/test_project.yml index 8cf8e0afb19..d417debac8c 100644 --- a/addons/project/test/test_project.yml +++ b/addons/project/test/test_project.yml @@ -1,108 +1,108 @@ - Test project template feature -- +- Create project 'OpenERP Training Programme' -- +- !record {model: project.project, id: project_project_openerptrainingprogramme0}: company_id: base.main_company - name: OpenERP Training Programme -- + name: OpenERP Training Programme +- Create task 'Technical Training' for this project -- +- !record {model: project.task, id: project_task_technicaltraining0}: date_start: '2010-05-31 11:48:38' name: Technical Training planned_hours: 30.0 project_id: project_project_openerptrainingprogramme0 remaining_hours: 30.0 - state: draft -- + state: draft +- Create task 'Functional Training' for this project -- +- !record {model: project.task, id: project_task_functionaltraining0}: date_start: '2010-05-31 11:49:11' name: Functional Training planned_hours: 30.0 project_id: project_project_openerptrainingprogramme0 remaining_hours: 30.0 - state: draft -- + state: draft +- Set project as project template -- +- !python {model: project.project}: | self.set_template(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_model": "ir.ui.menu", "active_ids": [ref("project.menu_open_view_project_all")], "tz": False, "active_id": ref("project.menu_open_view_project_all"), }) -- +- Check if project in template state -- +- !assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in template state}: - - state == "template" -- + - state == "template" +- Create new project based on this template -- +- !python {model: project.project}: | new_prj = self.duplicate_template(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_model": "ir.ui.menu", "active_ids": [ref("project.menu_open_view_project_all")], "tz": False, "active_id": ref("project.menu_open_view_project_all"), }) if not new_prj: - raise Exception( "New project based on template not created") + raise Exception( "New project based on template not created") new_id = new_prj['res_id'] new_prj = self.read(cr, uid, [new_id], ['name', 'state'])[0] state = new_prj['state'] - name = new_prj['name'] - assert state == 'open', "Project in %s state. Project created from template project must be in open state"%state -- - Reset project template to normal project -- + name = new_prj['name'] + assert state == 'open', "Project in %s state. Project created from template project must be in open state"%state +- + Reset project template to normal project +- !python {model: project.project}: | self.reset_project(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_ids": [ref("project.menu_open_view_project_all")], "tz": False, "active_model": "ir.ui.menu", "project_id": False, "active_id": ref("project.menu_open_view_project_all"), }) -- +- Check if project in open state -- +- !assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in open state}: - state == "open" - - Test for different project-states -- + Test for different project-states +- Keep project pending -- +- !python {model: project.project}: | self.set_pending(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_ids": [ref("project.menu_open_view_project_all")], "tz": False, "active_model": "ir.ui.menu", "project_id": False, "active_id": ref("project.menu_open_view_project_all"), }) -- +- Check if project in pending state -- +- !assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in pending state}: - - state == "pending" -- + - state == "pending" +- Cancel the project -- +- !python {model: project.project}: | self.set_cancel(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_ids": [ref("project.menu_open_view_project_all")], "tz": False, "active_model": "ir.ui.menu", "project_id": False, "active_id": ref("project.menu_open_view_project_all"), }) -- +- Check if project in cancel state -- +- !assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in cancel state}: - state == "cancelled" -- +- Re-open the project -- +- !python {model: project.project}: | self.set_open(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_ids": [ref("project.menu_open_view_project_all")], "tz": False, "active_model": "ir.ui.menu", "project_id": False, "active_id": ref("project.menu_open_view_project_all"), }) -- +- Check if project in open state -- +- !assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in open state}: - state == "open" - @@ -124,16 +124,16 @@ self.compute_hours(cr, uid, [ref('project_task_technicaltraining_remainingwiz0')], {'active_id': ref("project_task_technicaltraining0"),'button_reactivate': True}) - | Check if task 'Technical Training' in open state and for other initial values -- +- !assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: Project is in open state}: - state == "open" - planned_hours == 30 - remaining_hours == 30 - delay_hours == 0.0 - - effective_hours == 0.0 -- + - effective_hours == 0.0 +- Make a work task entry 'Training on OpenERP modules, models and classes' of 10 hours -- +- !record {model: project.task, id: project_task_technicaltraining0}: work_ids: - date: '2010-05-31 15:04:22' @@ -146,9 +146,9 @@ !assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: After work task of 10 hours effective_hours must be equal to 10}: - remaining_hours == 20 - effective_hours == 10.0 -- +- Make a work task entry 'Training on OpenERP xml views' of 10 hours -- +- !record {model: project.task, id: project_task_technicaltraining0}: work_ids: - date: '2010-06-01 15:04:46' @@ -161,9 +161,9 @@ !assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: After one more work task of 10 hours effective_hours must be equal to 20}: - remaining_hours == 10 - effective_hours == 20.0 -- - Make a work task entry 'Training on workflows' of 10 hours -- +- + Make a work task entry 'Training on workflows' of 10 hours +- !record {model: project.task, id: project_task_technicaltraining0}: work_ids: - date: '2010-06-02 15:05:24' @@ -176,20 +176,20 @@ !assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: After one more work task of 10 hours effective_hours must be equal to 30}: - remaining_hours == 0 - effective_hours == 30.0 -- - Set remaining hours of 10 hours for reevaluating the task -- +- + Set remaining hours of 10 hours for reevaluating the task +- !record {model: project.task.reevaluate, id: config_compute_remaining_0}: remaining_hours: 10.0 - Reevaluate the task -- +- !python {model: project.task.reevaluate}: | self.compute_hours(cr, uid, [ref("config_compute_remaining_0")], {"lang": "en_US", "project_id": False, "tz": False, "active_model": "project.task", "search_default_project_id": False, "search_default_user_id": 1, "search_default_current": 1, "active_ids": [ref("project_task_technicaltraining0")], "active_id": ref("project_task_technicaltraining0"), }) - + - Check for effective hours and remaining hours, remaining_hours must be 10 while planned_hours remains 30 - @@ -197,9 +197,9 @@ - planned_hours == 30 - remaining_hours == 10.0 - effective_hours == 30.0 -- +- Make a work task entry 'Training on reports and wizards' of 10 hours -- +- !record {model: project.task, id: project_task_technicaltraining0}: work_ids: - date: '2010-05-31 15:08:40' @@ -213,28 +213,28 @@ - planned_hours == 30 - remaining_hours == 0 - effective_hours == 40.0 -- +- Close the task -- +- !python {model: project.task}: | self.do_close(cr, uid, [ref("project_task_technicaltraining0")], {'mail_send': False}) -- +- Check if task in done state -- +- !assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: Task is in done state}: - - state == "done" - - + - state == "done" + + - - Test for task reactivation + Test for task reactivation +- + Reactivate task - - Reactivate task -- !record {model: project.task.reevaluate, id: config_compute_remaining_1}: - remaining_hours: 10.0 -- + remaining_hours: 10.0 +- Reevaluate the task with 10 hours remaining -- +- !python {model: project.task.reevaluate}: | self.compute_hours(cr, uid, [ref("config_compute_remaining_1")], {"lang": "en_US", "project_id": False, "tz": False, "button_reactivate": True, "active_model": @@ -248,9 +248,9 @@ - planned_hours == 30 - remaining_hours == 10.0 - effective_hours == 40.0 -- +- Make a work task entry 'Training on yml' of 5 hours -- +- !record {model: project.task, id: project_task_technicaltraining0}: work_ids: - date: '2010-05-31 16:55:27' @@ -264,16 +264,16 @@ - planned_hours == 30 - remaining_hours == 5.0 - effective_hours == 45.0 -- +- Close the task -- +- !python {model: project.task}: | self.do_close(cr, uid, [ref("project_task_technicaltraining0")], {'mail_send': False}) -- +- Check if task in done state -- +- !assert {model: project.task, id: project_task_technicaltraining0, severity: error}: - - state == "done" + - state == "done" - Check for effective hours and remaining hours - @@ -281,16 +281,16 @@ - planned_hours == 30 - remaining_hours == 0.0 - effective_hours == 45.0 -- +- Close project 'OpenERP Training Programme' -- +- !python {model: project.project}: | self.set_done(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_ids": [ref("project.menu_open_view_project_all")], "tz": False, "active_model": "ir.ui.menu", "project_id": False, "active_id": ref("project.menu_open_view_project_all"), }) -- +- Check if project in close state -- +- !assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: "Project must be in closed state"}: - - state == "close" - + - state == "close" + diff --git a/addons/project_retro_planning/test/deadline_change.yml b/addons/project_retro_planning/test/deadline_change.yml index 3e778916792..012bc62a4eb 100644 --- a/addons/project_retro_planning/test/deadline_change.yml +++ b/addons/project_retro_planning/test/deadline_change.yml @@ -10,7 +10,7 @@ Create task 'Plan all projects' - !record {model: project.task, id: project_task_planallprojects0}: - date_deadline: '2010-06-07' + date_deadline: '2010-06-07 12:00:00' date_end: '2010-06-04 14:00:00' date_start: '2010-06-01 17:25:32' name: Plan all projects diff --git a/addons/sale_layout/sale_layout_view.xml b/addons/sale_layout/sale_layout_view.xml index f184f79da49..3eac7eb1f3f 100755 --- a/addons/sale_layout/sale_layout_view.xml +++ b/addons/sale_layout/sale_layout_view.xml @@ -10,7 +10,7 @@ form - + diff --git a/addons/survey/report/survey_browse_response.py b/addons/survey/report/survey_browse_response.py index a2ee95e417e..408a266d2cf 100644 --- a/addons/survey/report/survey_browse_response.py +++ b/addons/survey/report/survey_browse_response.py @@ -201,11 +201,11 @@ class survey_browse_response(report_rml): for survey in surv_obj.browse(cr, uid, [response.survey_id.id]): tbl_width = float(_tbl_widths.replace('cm', '')) colwidth = "4.6cm,5cm," + str(tbl_width - 16.4) +"cm,4cm,3cm" + resp_create = tools.ustr(time.strftime('%d-%m-%Y %I:%M:%S %p', time.strptime(response.date_create.split('.')[0], '%Y-%m-%d %H:%M:%S'))) rml += """ Answer Create Date:- - # *-* formatting hard coded, breaks with utf8 - """ + to_xml(time.strftime('%d-%m-%Y %I:%M:%S %p', time.strptime(response.date_create.split('.')[0], '%Y-%m-%d %H:%M:%S'))) + """ + """ + to_xml(resp_create) + """ Answer By:- """ + to_xml(response.user_id.login or '') + """ diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 109f4509d81..9e4c801af2d 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -76,29 +76,43 @@ class survey_question_wiz(osv.osv_memory): sur_name_rec = surv_name_wiz.browse(cr, uid, wiz_id) context.update({'sur_name_id' :wiz_id}) else: - sur_name_rec = surv_name_wiz.browse(cr, uid, context.get('sur_name_id', False)) + sur_name_rec = surv_name_wiz.browse(cr, uid, context['sur_name_id']) if context.has_key('active_id'): context.pop('active_id') survey_id = context.get('survey_id', False) + if not survey_id: + # Try one more time to find it + if sur_name_rec.survey_id: + survey_id = sur_name_rec.survey_id[0] + else: + # raise osv.except_osv(_('Error!'), _("Cannot locate survey for the question wizard!")) + # If this function is called without a survey_id in + # its context, it makes no sense to return any view. + # Just return the default, empty view for this object, + # in order to please random calls to this fn(). + return super(survey_question_wiz, self).\ + fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, + toolbar=toolbar, submenu=submenu) + sur_rec = survey_obj.browse(cr, uid, survey_id) p_id = map(lambda x:x.id, sur_rec.page_ids) total_pages = len(p_id) pre_button = False readonly = 0 - if context.has_key('response_id') and context.get('response_id', False) \ + if context.get('response_id', False) \ and int(context['response_id'][0]) > 0: readonly = 1 if not sur_name_rec.page_no + 1 : - surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'store_ans':{}}) + surv_name_wiz.write(cr, uid, [context['sur_name_id'],], {'store_ans':{}}) - sur_name_read = surv_name_wiz.browse(cr, uid, context.get('sur_name_id',False)) + sur_name_read = surv_name_wiz.browse(cr, uid, context['sur_name_id']) page_number = int(sur_name_rec.page_no) if sur_name_read.transfer or not sur_name_rec.page_no + 1: - surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'transfer':False}) + 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: @@ -119,7 +133,7 @@ class survey_question_wiz(osv.osv_memory): survey_obj.write(cr, uid, survey_id, {'state':'close', 'date_close':strftime("%Y-%m-%d %H:%M:%S")}) p_id = p_id[sur_name_rec.page_no + 1] - surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'page_no' : sur_name_rec.page_no + 1}) + surv_name_wiz.write(cr, uid, [context['sur_name_id'],], {'page_no' : sur_name_rec.page_no + 1}) flag = True page_number += 1 if sur_name_rec.page_no > - 1: @@ -127,7 +141,7 @@ class survey_question_wiz(osv.osv_memory): else: if sur_name_rec.page_no != 0: p_id = p_id[sur_name_rec.page_no - 1] - surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)],\ + surv_name_wiz.write(cr, uid, [context['sur_name_id'],],\ {'page_no' : sur_name_rec.page_no - 1}) flag = True page_number -= 1 @@ -140,6 +154,7 @@ class survey_question_wiz(osv.osv_memory): xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'}) if context.has_key('response_id') and context.get('response_id', False) \ and int(context.get('response_id',0)[0]) > 0: + # TODO: l10n, cleanup this code to make it readable. Or template? xml_group = etree.SubElement(xml_form, 'group', {'col': '40', 'colspan': '4'}) record = sur_response_obj.browse(cr, uid, context['response_id'][context['response_no']]) etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr('Answer Of :- ' + record.user_id.name + ', Date :- ' + record.date_create.split('.')[0] )), 'align':"0.0"}) diff --git a/addons/survey/wizard/survey_selection.py b/addons/survey/wizard/survey_selection.py index 0f7ca8628f0..2ef83d38fcf 100644 --- a/addons/survey/wizard/survey_selection.py +++ b/addons/survey/wizard/survey_selection.py @@ -27,7 +27,7 @@ from tools.translate import _ class survey_name_wiz(osv.osv_memory): _name = 'survey.name.wiz' - def default_get(self, cr, uid, fields, context={}): + def default_get(self, cr, uid, fields, context=None): """ Set the default value in survey_id field. if open this wizard in survey form then set the default value in survey_id = active survey id. @@ -38,7 +38,7 @@ class survey_name_wiz(osv.osv_memory): @param context: A standard dictionary for contextual values @return : Dictionary value for created survey statistics report """ - if not context: + if context is None: context = {} data = super(survey_name_wiz, self).default_get(cr, uid, fields, context) if context.has_key('survey_id'): @@ -75,7 +75,7 @@ class survey_name_wiz(osv.osv_memory): u_list.append(use.id) if uid in u_list: result.append((sur.id, sur.title)) - return result + return result for sur in surv_obj.browse(cr, uid, surv_obj.search(cr, uid, [])): if sur.state == 'open': res = False diff --git a/addons/wiki/web/widgets/wikimarkup/__init__.py b/addons/wiki/web/widgets/wikimarkup/__init__.py index 5eceea0e86d..ac63feacfbb 100644 --- a/addons/wiki/web/widgets/wikimarkup/__init__.py +++ b/addons/wiki/web/widgets/wikimarkup/__init__.py @@ -1977,9 +1977,9 @@ class Parser(BaseParser): if toclevel < wgMaxTocLevel: toc.append(u"\n") toc.append(u"\n\n" * max(0, toclevel - 1)) - #TODO: use gettext - #toc.insert(0, u'

' + _('Table of Contents') + '

') - toc.insert(0, u'

Table of Contents

') + #TODO: use gettext + #toc.insert(0, u'

' + _('Table of Contents') + '

') + toc.insert(0, u'

Table of Contents

') toc.append(u'\n
') # split up and insert constructed headlines