From 3f96ef97a7406df2b839c1e532234f316fc66086 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 1 Feb 2011 22:08:39 +0100 Subject: [PATCH] [WIP] all: (work in progress) changing wizards to avoid using read() or at least take proper care of m2o fields This is in preparation of the fix for m2o.get() on osv_memory objects, to make it consistent with the regular read on osv objects. Previously on osv_memory objects it was only returned the id, instead of the pair (id, name) as is appropriate to avoid an additional name_get RPC call after each read. Unfortunately many wizards were using direct read() instead of browse() and relying on the fact that the returned dict contained a bare id value for many2one fields. bzr revid: odo@openerp.com-20110201210839-hwmk60ygksm805c4 --- .../wizard/account_automatic_reconcile.py | 5 ++++- .../account/wizard/account_change_currency.py | 6 +++--- addons/account/wizard/account_chart.py | 14 ++++++------- .../wizard/account_fiscalyear_close.py | 5 ++++- .../wizard/account_fiscalyear_close_state.py | 6 +++--- .../account/wizard/account_invoice_refund.py | 6 +++++- .../wizard/account_move_bank_reconcile.py | 8 ++++---- .../account_move_line_reconcile_select.py | 6 +++--- .../account_move_line_unreconcile_select.py | 6 +++--- addons/account/wizard/account_reconcile.py | 16 +++++++-------- addons/account/wizard/account_tax_chart.py | 18 ++++++++--------- .../wizard/account_crossovered_analytic.py | 4 +++- .../wizard/account_coda_import.py | 20 +++++++++---------- .../wizard/account_followup_print.py | 4 ++-- .../report/special_message_invoice.py | 5 ++++- .../wizard/hr_recruitment_phonecall.py | 10 +++++----- .../wizard/hr_timesheet_invoice_create.py | 18 ++++++++--------- addons/lunch/wizard/lunch_order_confirm.py | 4 ++-- addons/point_of_sale/wizard/pos_payment.py | 3 +++ addons/point_of_sale/wizard/pos_return.py | 4 ++-- addons/product/wizard/product_price.py | 2 ++ .../project/wizard/project_task_delegate.py | 2 ++ addons/project_gtd/wizard/project_gtd_fill.py | 6 +++--- .../wizard/project_compute_phases.py | 10 +++++----- .../wizard/project_compute_tasks.py | 4 ++-- addons/stock/wizard/stock_move.py | 8 ++++---- 26 files changed, 111 insertions(+), 89 deletions(-) diff --git a/addons/account/wizard/account_automatic_reconcile.py b/addons/account/wizard/account_automatic_reconcile.py index 432a430868c..13fef1fde0d 100644 --- a/addons/account/wizard/account_automatic_reconcile.py +++ b/addons/account/wizard/account_automatic_reconcile.py @@ -144,6 +144,9 @@ class account_automatic_reconcile(osv.osv_memory): if context is None: context = {} form = self.read(cr, uid, ids, [])[0] + for m2o_field in ['journal_id','period_id','writeoff_acc_id']: + if form[m2o_field] and isinstance(form[m2o_field], tuple): + form[m2o_field] = form[m2o_field][0] max_amount = form.get('max_amount', False) and form.get('max_amount') or 0.0 power = form['power'] allow_write_off = form['allow_write_off'] @@ -252,4 +255,4 @@ class account_automatic_reconcile(osv.osv_memory): account_automatic_reconcile() -# 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/account/wizard/account_change_currency.py b/addons/account/wizard/account_change_currency.py index d915a1cd34b..223ba327343 100644 --- a/addons/account/wizard/account_change_currency.py +++ b/addons/account/wizard/account_change_currency.py @@ -45,8 +45,8 @@ class account_change_currency(osv.osv_memory): obj_currency = self.pool.get('res.currency') if context is None: context = {} - data = self.read(cr, uid, ids)[0] - new_currency = data['currency_id'] + data = self.browse(cr, uid, ids)[0] + new_currency = data.currency_id.id invoice = obj_inv.browse(cr, uid, context['active_id'], context=context) if invoice.currency_id.id == new_currency: @@ -76,4 +76,4 @@ class account_change_currency(osv.osv_memory): account_change_currency() -# 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/account/wizard/account_chart.py b/addons/account/wizard/account_chart.py index e8f0e432d69..58526b30b0a 100644 --- a/addons/account/wizard/account_chart.py +++ b/addons/account/wizard/account_chart.py @@ -79,17 +79,17 @@ class account_chart(osv.osv_memory): fy_obj = self.pool.get('account.fiscalyear') if context is None: context = {} - data = self.read(cr, uid, ids, [], context=context)[0] + data = self.browse(cr, uid, ids, context=context)[0] result = mod_obj.get_object_reference(cr, uid, 'account', 'action_account_tree') id = result and result[1] or False result = act_obj.read(cr, uid, [id], context=context)[0] result['periods'] = [] - if data['period_from'] and data['period_to']: - result['periods'] = period_obj.build_ctx_periods(cr, uid, data['period_from'], data['period_to']) - result['context'] = str({'fiscalyear': data['fiscalyear'], 'periods': result['periods'], \ - 'state': data['target_move']}) - if data['fiscalyear']: - result['name'] += ':' + fy_obj.read(cr, uid, [data['fiscalyear']], context=context)[0]['code'] + if data.period_from and data.period_to: + result['periods'] = period_obj.build_ctx_periods(cr, uid, data.period_from.id, data.period_to.id) + result['context'] = str({'fiscalyear': data.fiscalyear.id, 'periods': result['periods'], \ + 'state': data.target_move}) + if data.fiscalyear: + result['name'] += ':' + fy_obj.read(cr, uid, [data.fiscalyear.id], context=context)[0]['code'] return result _defaults = { diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py index 6190f792c7f..bd635839afb 100644 --- a/addons/account/wizard/account_fiscalyear_close.py +++ b/addons/account/wizard/account_fiscalyear_close.py @@ -56,7 +56,10 @@ class account_fiscalyear_close(osv.osv_memory): obj_acc_account = self.pool.get('account.account') obj_acc_journal_period = self.pool.get('account.journal.period') - data = self.read(cr, uid, ids, context=context) + data = self.read(cr, uid, ids, context=context) + for m2o_field in ['fy_id','fy2_id','journal_id','period_id']: + if isinstance(data[0][m2o_field], tuple): + data[0][m2o_field] = data[0][m2o_field][0] if context is None: context = {} diff --git a/addons/account/wizard/account_fiscalyear_close_state.py b/addons/account/wizard/account_fiscalyear_close_state.py index abf054746ce..30edce42077 100644 --- a/addons/account/wizard/account_fiscalyear_close_state.py +++ b/addons/account/wizard/account_fiscalyear_close_state.py @@ -40,8 +40,8 @@ class account_fiscalyear_close_state(osv.osv_memory): @param ids: List of Account fiscalyear close state’s IDs """ - for data in self.read(cr, uid, ids, context=context): - fy_id = data['fy_id'] + for data in self.browse(cr, uid, ids, context=context): + fy_id = data.fy_id.id cr.execute('UPDATE account_journal_period ' \ 'SET state = %s ' \ @@ -61,4 +61,4 @@ class account_fiscalyear_close_state(osv.osv_memory): account_fiscalyear_close_state() -# 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/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index 672e2a28fba..edc2b1d99c9 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -95,6 +95,8 @@ class account_invoice_refund(osv.osv_memory): description = False company = res_users_obj.browse(cr, uid, uid, context=context).company_id journal_id = form.get('journal_id', False) + if isinstance(journal_id, tuple): + journal_id = journal_id[0] for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context): if inv.state in ['draft', 'proforma2', 'cancel']: raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode)) @@ -102,6 +104,8 @@ class account_invoice_refund(osv.osv_memory): raise osv.except_osv(_('Error !'), _('Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice') % (mode)) if form['period']: period = form['period'] + if isinstance(period, tuple): + period = period[0] else: period = inv.period_id and inv.period_id.id or False @@ -217,4 +221,4 @@ class account_invoice_refund(osv.osv_memory): account_invoice_refund() -# 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/account/wizard/account_move_bank_reconcile.py b/addons/account/wizard/account_move_bank_reconcile.py index 9be351ed440..266c6e764b4 100644 --- a/addons/account/wizard/account_move_bank_reconcile.py +++ b/addons/account/wizard/account_move_bank_reconcile.py @@ -41,15 +41,15 @@ class account_move_bank_reconcile(osv.osv_memory): """ if context is None: context = {} - data = self.read(cr, uid, ids, context=context)[0] + data = self.browse(cr, uid, ids, context=context)[0] cr.execute('select default_credit_account_id \ - from account_journal where id=%s', (data['journal_id'],)) + from account_journal where id=%s', (data.journal_id.id,)) account_id = cr.fetchone()[0] if not account_id: raise osv.except_osv(_('Error'), _('You have to define \ the bank account\nin the journal definition for reconciliation.')) return { - 'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (data['journal_id'], account_id), + 'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (data.journal_id.id, account_id), 'name': _('Standard Encoding'), 'view_type': 'form', 'view_mode': 'tree,form', @@ -61,4 +61,4 @@ the bank account\nin the journal definition for reconciliation.')) account_move_bank_reconcile() -# 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/account/wizard/account_move_line_reconcile_select.py b/addons/account/wizard/account_move_line_reconcile_select.py index 8e57c57884d..d0953bd83ba 100644 --- a/addons/account/wizard/account_move_line_reconcile_select.py +++ b/addons/account/wizard/account_move_line_reconcile_select.py @@ -39,9 +39,9 @@ class account_move_line_reconcile_select(osv.osv_memory): @return: dictionary of Open account move line window for reconcile on given account id """ - data = self.read(cr, uid, ids, context=context)[0] + data = self.browse(cr, uid, ids, context=context)[0] return { - 'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['account_id'], + 'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data.account_id.id, 'name': _('Reconciliation'), 'view_type': 'form', 'view_mode': 'tree,form', @@ -52,4 +52,4 @@ class account_move_line_reconcile_select(osv.osv_memory): account_move_line_reconcile_select() -# 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/account/wizard/account_move_line_unreconcile_select.py b/addons/account/wizard/account_move_line_unreconcile_select.py index ad59493503d..084b93cdaa2 100644 --- a/addons/account/wizard/account_move_line_unreconcile_select.py +++ b/addons/account/wizard/account_move_line_unreconcile_select.py @@ -28,9 +28,9 @@ class account_move_line_unreconcile_select(osv.osv_memory): 'account_id': fields.many2one('account.account','Account',required=True), } def action_open_window(self, cr, uid, ids, context=None): - data = self.read(cr, uid, ids, context=context)[0] + data = self.browse(cr, uid, ids, context=context)[0] return { - 'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['account_id'], + 'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data.account_id.id, 'name': 'Unreconciliation', 'view_type': 'form', 'view_mode': 'tree,form', @@ -41,4 +41,4 @@ class account_move_line_unreconcile_select(osv.osv_memory): account_move_line_unreconcile_select() -# 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/account/wizard/account_reconcile.py b/addons/account/wizard/account_reconcile.py index 8131f6a9668..07da76733e4 100644 --- a/addons/account/wizard/account_reconcile.py +++ b/addons/account/wizard/account_reconcile.py @@ -152,13 +152,13 @@ class account_move_line_reconcile_writeoff(osv.osv_memory): period_obj = self.pool.get('account.period') if context is None: context = {} - data = self.read(cr, uid, ids,context=context)[0] - account_id = data['writeoff_acc_id'] - context['date_p'] = data['date_p'] - journal_id = data['journal_id'] - context['comment'] = data['comment'] - if data['analytic_id']: - context['analytic_id'] = data['analytic_id'] + data = self.browse(cr, uid, ids,context=context)[0] + account_id = data.writeoff_acc_id.id + context['date_p'] = data.date_p + journal_id = data.journal_id.id + context['comment'] = data.comment + if data.analytic_id: + context['analytic_id'] = data.analytic_id.id if context['date_p']: date = context['date_p'] @@ -173,4 +173,4 @@ class account_move_line_reconcile_writeoff(osv.osv_memory): account_move_line_reconcile_writeoff() -# 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/account/wizard/account_tax_chart.py b/addons/account/wizard/account_tax_chart.py index 9e02931f34d..fd9b887ee2b 100644 --- a/addons/account/wizard/account_tax_chart.py +++ b/addons/account/wizard/account_tax_chart.py @@ -54,20 +54,20 @@ class account_tax_chart(osv.osv_memory): period_obj = self.pool.get('account.period') if context is None: context = {} - data = self.read(cr, uid, ids, [], context=context)[0] + data = self.browse(cr, uid, ids, context=context)[0] result = mod_obj.get_object_reference(cr, uid, 'account', 'action_tax_code_tree') id = result and result[1] or False result = act_obj.read(cr, uid, [id], context=context)[0] - if data['period_id']: - fiscalyear_id = period_obj.read(cr, uid, [data['period_id']], context=context)[0]['fiscalyear_id'][0] - result['context'] = str({'period_id': data['period_id'], \ + if data.period_id: + fiscalyear_id = period_obj.read(cr, uid, [data.period_id.id], context=context)[0]['fiscalyear_id'][0] + result['context'] = str({'period_id': data.period_id.id, \ 'fiscalyear_id': fiscalyear_id, \ - 'state': data['target_move']}) + 'state': data.target_move}) else: - result['context'] = str({'state': data['target_move']}) + result['context'] = str({'state': data.target_move}) - if data['period_id']: - period_code = period_obj.read(cr, uid, [data['period_id']], context=context)[0]['code'] + if data.period_id: + period_code = period_obj.read(cr, uid, [data.period_id.id], context=context)[0]['code'] result['name'] += period_code and (':' + period_code) or '' return result @@ -78,4 +78,4 @@ class account_tax_chart(osv.osv_memory): account_tax_chart() -# 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/account_analytic_plans/wizard/account_crossovered_analytic.py b/addons/account_analytic_plans/wizard/account_crossovered_analytic.py index 4eaca49e2ca..2974c160501 100644 --- a/addons/account_analytic_plans/wizard/account_crossovered_analytic.py +++ b/addons/account_analytic_plans/wizard/account_crossovered_analytic.py @@ -45,6 +45,8 @@ class account_crossovered_analytic(osv.osv_memory): acc_ids = [x[0] for x in res] data = self.read(cr, uid, ids, [], context=context)[0] + if isinstance(data['ref'],tuple): + data['ref'] = data['ref'][0] obj_acc = self.pool.get('account.analytic.account').browse(cr, uid, data['ref'], context=context) name = obj_acc.name @@ -72,4 +74,4 @@ class account_crossovered_analytic(osv.osv_memory): account_crossovered_analytic() -# 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/account_coda/wizard/account_coda_import.py b/addons/account_coda/wizard/account_coda_import.py index 6d3743116db..309a647ef47 100644 --- a/addons/account_coda/wizard/account_coda_import.py +++ b/addons/account_coda/wizard/account_coda_import.py @@ -69,14 +69,14 @@ class account_coda_import(osv.osv_memory): if context is None: context = {} - data = self.read(cr, uid, ids)[0] + data = self.browse(cr, uid, ids)[0] - codafile = data['coda'] - journal_code = journal_obj.browse(cr, uid, data['journal_id'], context=context).code + codafile = data.coda + journal_code = journal_obj.browse(cr, uid, data.journal_id.id, context=context).code period = account_period_obj.find(cr, uid, context=context)[0] - def_pay_acc = data['def_payable'] - def_rec_acc = data['def_receivable'] + def_pay_acc = data.def_payable.id + def_rec_acc = data.def_receivable.id err_log = "Errors:\n------\n" nb_err=0 @@ -96,7 +96,7 @@ class account_coda_import(osv.osv_memory): bank_statement["bank_statement_line"]={} bank_statement_lines = {} bank_statement['date'] = str2date(line[5:11]) - bank_statement['journal_id']=data['journal_id'] + bank_statement['journal_id']=data.journal_id.id period_id = account_period_obj.search(cr, uid, [('date_start', '<=', time.strftime('%Y-%m-%d', time.strptime(bank_statement['date'], "%y/%m/%d"))), ('date_stop', '>=', time.strftime('%Y-%m-%d', time.strptime(bank_statement['date'], "%y/%m/%d")))]) bank_statement['period_id'] = period_id and period_id[0] or False bank_statement['state']='draft' @@ -144,7 +144,7 @@ class account_coda_import(osv.osv_memory): bank_statement["bank_statement_line"]=bank_statement_lines elif line[1] == '2': st_line_name = line[2:6] - bank_statement_lines[st_line_name].update({'account_id': data['awaiting_account']}) + bank_statement_lines[st_line_name].update({'account_id': data.awaiting_account.id}) elif line[1] == '3': # movement data record 3.1 @@ -165,7 +165,7 @@ class account_coda_import(osv.osv_memory): else: nb_err += 1 err_log += _('The bank account %s is not defined for the partner %s.\n')%(cntry_number, contry_name) - bank_statement_lines[st_line_name].update({'account_id': data['awaiting_account']}) + bank_statement_lines[st_line_name].update({'account_id': data.awaiting_account.id}) bank_statement["bank_statement_line"]=bank_statement_lines elif line[0]=='3': @@ -296,7 +296,7 @@ class account_coda_import(osv.osv_memory): 'name': codafile, 'statement_ids': [(6, 0, bkst_list,)], 'note': str_log1+str_not+std_log+err_log, - 'journal_id': data['journal_id'], + 'journal_id': data.journal_id.id, 'date': time.strftime("%Y-%m-%d"), 'user_id': uid, }) @@ -336,4 +336,4 @@ class account_coda_import(osv.osv_memory): account_coda_import() -# 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/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index 5d9c2da860f..e8f5e976389 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -48,10 +48,10 @@ class account_followup_print(osv.osv_memory): if context is None: context = {} - data = self.read(cr, uid, ids, [], context=context)[0] + data = self.browse(cr, uid, ids, context=context)[0] model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] - context.update({'followup_id': data['followup_id'], 'date':data['date']}) + context.update({'followup_id': data.followup_id.id, 'date':data.date}) return { 'name': _('Select Partners'), 'view_type': 'form', diff --git a/addons/account_invoice_layout/report/special_message_invoice.py b/addons/account_invoice_layout/report/special_message_invoice.py index bac4a467ae1..81298bb6a06 100644 --- a/addons/account_invoice_layout/report/special_message_invoice.py +++ b/addons/account_invoice_layout/report/special_message_invoice.py @@ -37,7 +37,10 @@ class account_invoice_with_message(report_sxw.rml_parse): self.context = context def spcl_msg(self, form): - account_msg_data = pooler.get_pool(self.cr.dbname).get('notify.message').browse(self.cr, self.uid, form['message']) + msg_id = form['message'] + if isinstance(msg_id, (tuple,list)): + msg_id = msg_id[0] + account_msg_data = pooler.get_pool(self.cr.dbname).get('notify.message').browse(self.cr, self.uid, msg_id) msg = account_msg_data.msg return msg diff --git a/addons/hr_recruitment/wizard/hr_recruitment_phonecall.py b/addons/hr_recruitment/wizard/hr_recruitment_phonecall.py index ecb6a7cb3a4..becef387151 100644 --- a/addons/hr_recruitment/wizard/hr_recruitment_phonecall.py +++ b/addons/hr_recruitment/wizard/hr_recruitment_phonecall.py @@ -69,7 +69,7 @@ class job2phonecall(osv.osv_memory): phonecall_case_obj = self.pool.get('crm.phonecall') if context is None: context = {} - form = self.read(cr, uid, ids, [], context=context)[0] + form = self.browse(cr, uid, ids, context=context)[0] result = mod_obj._get_id(cr, uid, 'crm', 'view_crm_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id'], context=context) # Select the view @@ -85,10 +85,10 @@ class job2phonecall(osv.osv_memory): #TODO: Take other info from job new_phonecall_id = phonecall_case_obj.create(cr, uid, { 'name': job.name, - 'user_id': form['user_id'], - 'categ_id': form['category_id'], - 'description': form['note'], - 'date': form['deadline'], + 'user_id': form.user_id.id, + 'categ_id': form.category_id.id, + 'description': form.note, + 'date': form.deadline, 'description': job.description, 'partner_id': job.partner_id.id, 'partner_address_id': job.partner_address_id.id, diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py index f3f720687cf..b2c0b814375 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -63,13 +63,13 @@ class hr_timesheet_invoice_create(osv.osv_memory): if context is None: context = {} result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter') - data = self.read(cr, uid, ids, [], context=context)[0] + data = self.browse(cr, uid, ids, context=context)[0] account_ids = {} for line in self.pool.get('account.analytic.line').browse(cr, uid, context['active_ids'], context=context): account_ids[line.account_id.id] = True - account_ids = account_ids.keys() #data['accounts'] + account_ids = account_ids.keys() #data.accounts for account in analytic_account_obj.browse(cr, uid, account_ids, context=context): partner = account.partner_id if (not partner) or not (account.pricelist_id): @@ -121,17 +121,17 @@ class hr_timesheet_invoice_create(osv.osv_memory): factor_name = '' factor = invoice_factor_obj.browse(cr, uid, factor_id, context2) - if not data['product']: + if not data.product: if factor.customer_name: factor_name = product.name+' - '+factor.customer_name else: factor_name = product.name else: - factor_name = product_obj.name_get(cr, uid, [data['product']], context=context)[0][1] + factor_name = product_obj.name_get(cr, uid, [data.product.id], context=context)[0][1] if account.pricelist_id: pl = account.pricelist_id.id - price = pro_price_obj.price_get(cr,uid,[pl], data['product'] or product_id, qty or 1.0, account.partner_id.id)[pl] + price = pro_price_obj.price_get(cr,uid,[pl], data.product.id or product_id, qty or 1.0, account.partner_id.id)[pl] else: price = 0.0 @@ -145,7 +145,7 @@ class hr_timesheet_invoice_create(osv.osv_memory): 'invoice_line_tax_id': [(6,0,tax )], 'invoice_id': last_invoice, 'name': factor_name, - 'product_id': data['product'] or product_id, + 'product_id': data.product.id or product_id, 'invoice_line_tax_id': [(6,0,tax)], 'uos_id': product.uom_id.id, 'account_id': account_id, @@ -162,14 +162,14 @@ class hr_timesheet_invoice_create(osv.osv_memory): for line in line_ids: # set invoice_line_note details = [] - if data['date']: + if data.date: details.append(line['date']) - if data['time']: + if data.time: if line['product_uom_id']: details.append("%s %s" % (line['unit_amount'], product_uom_obj.browse(cr, uid, [line['product_uom_id']],context2)[0].name)) else: details.append("%s" % (line['unit_amount'], )) - if data['name']: + if data.name: details.append(line['name']) note.append(u' - '.join(map(lambda x: unicode(x) or '',details))) diff --git a/addons/lunch/wizard/lunch_order_confirm.py b/addons/lunch/wizard/lunch_order_confirm.py index 6014f14f510..3dee0c3fd0d 100644 --- a/addons/lunch/wizard/lunch_order_confirm.py +++ b/addons/lunch/wizard/lunch_order_confirm.py @@ -46,8 +46,8 @@ class lunch_order_confirm(osv.osv_memory): data = context and context.get('active_ids', []) or [] order_ref = self.pool.get('lunch.order') - for confirm_obj in self.read(cr, uid, ids): - order_ref.confirm(cr, uid, data, confirm_obj['confirm_cashbox'], context) + for confirm_obj in self.browse(cr, uid, ids): + order_ref.confirm(cr, uid, data, confirm_obj.confirm_cashbox.id, context) return {'type': 'ir.actions.act_window_close'} lunch_order_confirm() diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py index 8d8a6f8465a..6f9c2126a6d 100644 --- a/addons/point_of_sale/wizard/pos_payment.py +++ b/addons/point_of_sale/wizard/pos_payment.py @@ -148,6 +148,9 @@ class pos_make_payment(osv.osv_memory): order = order_obj.browse(cr, uid, active_id, context=context) amount = order.amount_total - order.amount_paid data = self.read(cr, uid, ids, context=context)[0] + for m2o_field in ['product_id','pricelist_id','partner_id']: + if data[m2o_field] and isinstance(data[m2o_field], (list,tuple)): + data[m2o_field] = data[m2o_field][0] if data['is_acc']: amount = self.pool.get('product.product').browse(cr, uid, data['product_id'], context=context).list_price diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py index 810ef86ec7b..5db14e31358 100644 --- a/addons/point_of_sale/wizard/pos_return.py +++ b/addons/point_of_sale/wizard/pos_return.py @@ -353,8 +353,8 @@ class add_product(osv.osv_memory): data = return_boj.read(cr,uid,return_id,[])[0] wf_service = netsvc.LocalService("workflow") - self_data = self.read(cr, uid, ids)[0] - order_obj.add_product(cr, uid, active_ids[0], self_data['product_id'], self_data['quantity'], context=context) + self_data = self.browse(cr, uid, ids)[0] + order_obj.add_product(cr, uid, active_ids[0], self_data.product_id.id, self_data.quantity, context=context) for order_id in order_obj.browse(cr, uid, active_ids, context=context): prop_ids =property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')]) diff --git a/addons/product/wizard/product_price.py b/addons/product/wizard/product_price.py index 5a5327a3f6d..c797efae937 100644 --- a/addons/product/wizard/product_price.py +++ b/addons/product/wizard/product_price.py @@ -53,6 +53,8 @@ class product_price_list(osv.osv_memory): datas = {'ids': context.get('active_ids', [])} res = self.read(cr, uid, ids, ['price_list','qty1', 'qty2','qty3','qty4','qty5'], context=context) res = res and res[0] or {} + if isinstance(res['price_list'], (tuple,list)): + res['price_list'] = res['price_list'][0] datas['form'] = res return { 'type': 'ir.actions.report.xml', diff --git a/addons/project/wizard/project_task_delegate.py b/addons/project/wizard/project_task_delegate.py index 72b32f7db68..16c3ec85653 100644 --- a/addons/project/wizard/project_task_delegate.py +++ b/addons/project/wizard/project_task_delegate.py @@ -105,6 +105,8 @@ class project_task_delegate(osv.osv_memory): task_id = context.get('active_id', False) task_pool = self.pool.get('project.task') delegate_data = self.read(cr, uid, ids, context=context)[0] + if isinstance(delegate_data['user_id'], tuple): + delegate_data['user_id'] = delegate_data['user_id'][0] delegate_data['name'] = tools.ustr(delegate_data['name']) task_pool.do_delegate(cr, uid, task_id, delegate_data, context=context) return {} diff --git a/addons/project_gtd/wizard/project_gtd_fill.py b/addons/project_gtd/wizard/project_gtd_fill.py index 7a36b3e6ead..8c607cd12f3 100644 --- a/addons/project_gtd/wizard/project_gtd_fill.py +++ b/addons/project_gtd/wizard/project_gtd_fill.py @@ -50,10 +50,10 @@ class project_timebox_fill(osv.osv_memory): def process(self, cr, uid, ids, context=None): if not ids: return {} - data = self.read(cr, uid, ids, [], context=context) - if not data[0]['task_ids']: + data = self.browse(cr, uid, ids, context=context) + if not data[0].task_ids: return {} - self.pool.get('project.task').write(cr, uid, data[0]['task_ids'], {'timebox_id':data[0]['timebox_to_id']}) + self.pool.get('project.task').write(cr, uid, [x.id for x in data[0].task_ids], {'timebox_id':data[0].timebox_to_id.id}) return {'type': 'ir.actions.act_window_close'} project_timebox_fill() diff --git a/addons/project_long_term/wizard/project_compute_phases.py b/addons/project_long_term/wizard/project_compute_phases.py index c07f1ae81be..b074f3c93e9 100644 --- a/addons/project_long_term/wizard/project_compute_phases.py +++ b/addons/project_long_term/wizard/project_compute_phases.py @@ -45,12 +45,12 @@ class project_compute_phases(osv.osv_memory): Compute the phases for scheduling. """ project_pool = self.pool.get('project.project') - data = self.read(cr, uid, ids, [], context=context)[0] - if not data['project_id'] and data['target_project'] == 'one': + data = self.browse(cr, uid, ids, context=context)[0] + if not data.project_id and data.target_project == 'one': raise osv.except_osv(_('Error!'), _('Please Specify Project to be schedule')) - if data['project_id']: # If project mentioned find its phases - project_ids = [data['project_id']] + if data.project_id: # If project mentioned find its phases + project_ids = [data.project_id.id] else: # Else take all the draft,open,pending states phases project_ids = project_pool.search(cr, uid, [], context=context) @@ -69,7 +69,7 @@ class project_compute_phases(osv.osv_memory): id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id'] result = act_obj.read(cr, uid, [id], context=context)[0] result['target'] = 'current' - result['context'] = {"search_default_project_id":data['project_id'], "default_project_id":data['project_id'], "search_default_responsible_id":uid, "search_default_current": 1} + result['context'] = {"search_default_project_id":data.project_id.id or False, "default_project_id":data.project_id.id or False, "search_default_responsible_id":uid, "search_default_current": 1} return result project_compute_phases() diff --git a/addons/project_long_term/wizard/project_compute_tasks.py b/addons/project_long_term/wizard/project_compute_tasks.py index 658350a27d2..d5cc4eb5991 100644 --- a/addons/project_long_term/wizard/project_compute_tasks.py +++ b/addons/project_long_term/wizard/project_compute_tasks.py @@ -37,8 +37,8 @@ class project_compute_tasks(osv.osv_memory): if context is None: context = {} context['compute_by'] = 'project' - data = self.read(cr, uid, ids, [])[0] - project_id = data['project_id'] + data = self.browse(cr, uid, ids)[0] + project_id = data.project_id.id project_pool.schedule_tasks(cr, uid, [project_id], context=context) return self._open_task_list(cr, uid, data, context=context) diff --git a/addons/stock/wizard/stock_move.py b/addons/stock/wizard/stock_move.py index 8cfdc648349..d0bbc73863d 100644 --- a/addons/stock/wizard/stock_move.py +++ b/addons/stock/wizard/stock_move.py @@ -98,9 +98,9 @@ class stock_move_consume(osv.osv_memory): context = {} move_obj = self.pool.get('stock.move') move_ids = context['active_ids'] - for data in self.read(cr, uid, ids): + for data in self.browse(cr, uid, ids): move_obj.action_consume(cr, uid, move_ids, - data['product_qty'], data['location_id'], + data.product_qty, data.location_id.id, context=context) return {'type': 'ir.actions.act_window_close'} @@ -159,9 +159,9 @@ class stock_move_scrap(osv.osv_memory): context = {} move_obj = self.pool.get('stock.move') move_ids = context['active_ids'] - for data in self.read(cr, uid, ids): + for data in self.browse(cr, uid, ids): move_obj.action_scrap(cr, uid, move_ids, - data['product_qty'], data['location_id'], + data.product_qty, data.location_id.id, context=context) return {'type': 'ir.actions.act_window_close'}