From 1f43329f0e4828e6afd91ec25317177bb335ecf7 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 8 Jul 2008 08:13:12 +0000 Subject: [PATCH] * translation of nearly all exceptions * the export of translations per module take only the files of these modules bzr revid: chs@tinyerp.com-77721e34d87043c4008239f004c7c616f6d4dc82 --- addons/account/account.py | 35 +++++++++--------- addons/account/account_analytic_line.py | 7 ++-- addons/account/account_bank_statement.py | 21 +++++------ addons/account/account_move_line.py | 36 +++++++++---------- addons/account/invoice.py | 19 +++++----- .../wizard/wizard_aged_trial_balance.py | 3 +- .../account/wizard/wizard_bank_reconcile.py | 3 +- .../account/wizard/wizard_fiscalyear_close.py | 15 ++++---- addons/account/wizard/wizard_journal.py | 3 +- .../wizard/wizard_open_closed_fiscalyear.py | 5 +-- addons/account/wizard/wizard_pay_invoice.py | 5 +-- .../wizard/wizard_validate_account_move.py | 5 +-- .../account_analytic_analysis.py | 9 ++--- .../wizard/wizard_followup_print.py | 5 +-- .../wizard/base_module_publish.py | 11 +++--- .../base_module_publish/wizard/module_zip.py | 6 ++-- addons/crm/crm.py | 7 ++-- addons/delivery/delivery.py | 3 +- addons/delivery/stock.py | 5 +-- addons/delivery/wizard/delivery_sale_order.py | 5 +-- addons/hr/hr.py | 7 ++-- addons/hr/wizard/sign_in_out.py | 9 ++--- addons/hr_expense/hr_expense.py | 3 +- addons/hr_timesheet/wizard/sign_in_out.py | 5 +-- .../hr_timesheet_invoice.py | 5 +-- .../hr_timesheet_final_invoice_create.py | 9 ++--- .../wizard/hr_timesheet_invoice_create.py | 9 ++--- .../hr_timesheet_sheet/hr_timesheet_sheet.py | 23 ++++++------ .../wizard/wizard_timesheet_current.py | 3 +- addons/product/pricelist.py | 13 +++---- addons/project/wizard/billing.py | 4 +-- addons/project/wizard/close_task.py | 4 +-- addons/purchase/purchase.py | 7 ++-- addons/sale/sale.py | 29 +++++++-------- addons/stock/stock.py | 25 ++++++------- addons/stock/wizard/wizard_track_line.py | 3 +- addons/subscription/subscription.py | 3 +- 37 files changed, 201 insertions(+), 168 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 8c38566f79d..75605c1ab14 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -32,6 +32,7 @@ import netsvc from osv import fields, osv from tools.misc import currency +from tools.translate import _ import mx.DateTime from mx.DateTime import RelativeDateTime, now, DateTime, localtime @@ -484,7 +485,7 @@ class account_fiscalyear(osv.osv): ids = self.search(cr, uid, [('date_start', '<=', dt), ('date_stop', '>=', dt)]) if not ids: if exception: - raise osv.except_osv('Error !', 'No fiscal year defined for this date !\nPlease create one.') + raise osv.except_osv(_('Error !'), _('No fiscal year defined for this date !\nPlease create one.')) else: return False return ids[0] @@ -517,7 +518,7 @@ class account_period(osv.osv): #CHECKME: shouldn't we check the state of the period? ids = self.search(cr, uid, [('date_start','<=',dt),('date_stop','>=',dt)]) if not ids: - raise osv.except_osv('Error !', 'No period defined for this date !\nPlease create a fiscal year.') + raise osv.except_osv(_('Error !'), _('No period defined for this date !\nPlease create a fiscal year.')) return ids account_period() @@ -549,7 +550,7 @@ class account_journal_period(osv.osv): cr.execute('select * from account_move_line where journal_id=%d and period_id=%d limit 1', (obj.journal_id.id, obj.period_id.id)) res = cr.fetchall() if res: - raise osv.except_osv('Error !', 'You can not modify/delete a journal with entries for this period !') + raise osv.except_osv(_('Error !'), _('You can not modify/delete a journal with entries for this period !')) return True def write(self, cr, uid, ids, vals, context={}): @@ -656,7 +657,7 @@ class account_move(osv.osv): if self.validate(cr, uid, ids, context) and len(ids): cr.execute('update account_move set state=%s where id in ('+','.join(map(str,ids))+')', ('posted',)) else: - raise osv.except_osv('Integrity Error !', 'You can not validate a non balanced entry !') + raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non balanced entry !')) return True def button_validate(self, cursor, user, ids, context=None): @@ -665,7 +666,7 @@ class account_move(osv.osv): def button_cancel(self, cr, uid, ids, context={}): for line in self.browse(cr, uid, ids, context): if not line.journal_id.update_posted: - raise osv.except_osv('Error !', 'You can not modify a posted entry of this journal !') + raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !')) if len(ids): cr.execute('update account_move set state=%s where id in ('+','.join(map(str,ids))+')', ('draft',)) return True @@ -704,7 +705,7 @@ class account_move(osv.osv): if journal.sequence_id: vals['name'] = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id) else: - raise osv.except_osv('Error', 'No sequence defined in the journal !') + raise osv.except_osv(_('Error'), _('No sequence defined in the journal !')) if 'line_id' in vals: c = context.copy() c['novalidate'] = True @@ -718,8 +719,8 @@ class account_move(osv.osv): toremove = [] for move in self.browse(cr, uid, ids, context): if move['state'] <> 'draft': - raise osv.except_osv('UserError', - 'You can not delete posted movement: "%s"!' % \ + raise osv.except_osv(_('UserError'), + _('You can not delete posted movement: "%s"!') % \ move['name']) line_ids = map(lambda x: x.id, move.line_id) context['journal_id'] = move.journal_id.id @@ -741,16 +742,16 @@ class account_move(osv.osv): account_id = move.journal_id.default_debit_account_id.id mode2 = 'debit' if not account_id: - raise osv.except_osv('UserError', - 'There is no default default debit account defined \n' \ - 'on journal "%s"' % move.journal_id.name) + raise osv.except_osv(_('UserError'), + _('There is no default default debit account defined \n' \ + 'on journal "%s"') % move.journal_id.name) else: account_id = move.journal_id.default_credit_account_id.id mode2 = 'credit' if not account_id: - raise osv.except_osv('UserError', - 'There is no default default credit account defined \n' \ - 'on journal "%s"' % move.journal_id.name) + raise osv.except_osv(_('UserError'), + _('There is no default default credit account defined \n' \ + 'on journal "%s"') % move.journal_id.name) # find the first line of this move with the current mode # or create it if it doesn't exist @@ -805,11 +806,11 @@ class account_move(osv.osv): if not company_id: company_id = line.account_id.company_id.id if not company_id == line.account_id.company_id.id: - raise osv.except_osv('Error', 'Couldn\'t create move between different companies') + raise osv.except_osv(_('Error'), _('Couldn\'t create move between different companies')) if line.account_id.currency_id: if line.account_id.currency_id.id != line.currency_id.id and (line.account_id.currency_id.id != line.account_id.company_id.currency_id.id or line.currency_id): - raise osv.except_osv('Error', 'Couldn\'t create move with currency different than the secondary currency of the account') + raise osv.except_osv(_('Error'), _('Couldn\'t create move with currency different than the secondary currency of the account')) if abs(amount) < 0.0001: if not len(line_draft_ids): @@ -1372,7 +1373,7 @@ class account_model(osv.osv): for model in self.browse(cr, uid, ids, context): period_id = self.pool.get('account.period').find(cr,uid, context=context) if not period_id: - raise osv.except_osv('No period found !', 'Unable to find a valid period !') + raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) period_id = period_id[0] name = model.name if model.journal_id.sequence_id: diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index f3682cd5fb7..3dd06187bf2 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -32,6 +32,7 @@ import time from osv import fields from osv import osv +from tools.translate import _ class account_analytic_line(osv.osv): _name = 'account.analytic.line' @@ -75,9 +76,9 @@ class account_analytic_line(osv.osv): if not a: a = prod.categ_id.property_account_expense_categ.id if not a: - raise osv.except_osv('Error !', - 'There is no expense account define ' \ - 'for this product: "%s" (id:%d)' % \ + raise osv.except_osv(_('Error !'), + _('There is no expense account define ' \ + 'for this product: "%s" (id:%d)') % \ (prod.name, prod.id,)) amount = unit_amount * uom_obj._compute_price(cr, uid, prod.uom_id.id, prod.standard_price, unit) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 8ebddcb0fb0..3f50255c416 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -32,6 +32,7 @@ import netsvc from osv import fields, osv from tools.misc import currency +from tools.translate import _ import mx.DateTime from mx.DateTime import RelativeDateTime, now, DateTime, localtime @@ -165,18 +166,18 @@ class account_bank_statement(osv.osv): continue if not (abs(st.balance_end - st.balance_end_real) < 0.0001): - raise osv.except_osv('Error !', - 'The statement balance is incorrect !\n' - 'Check that the ending balance equals the computed one.') + raise osv.except_osv(_('Error !'), + _('The statement balance is incorrect !\n' + 'Check that the ending balance equals the computed one.')) if (not st.journal_id.default_credit_account_id) \ or (not st.journal_id.default_debit_account_id): - raise osv.except_osv('Configration Error !', - 'Please verify that an account is defined in the journal.') + raise osv.except_osv(_('Configration Error !'), + _('Please verify that an account is defined in the journal.')) for line in st.move_line_ids: if line.state <> 'valid': - raise osv.except_osv('Error !', - 'The account entries lines are not valid.') + raise osv.except_osv(_('Error !'), + _('The account entries lines are not valid.')) for move in st.line_ids: move_id = account_move_obj.create(cr, uid, { @@ -275,8 +276,8 @@ class account_bank_statement(osv.osv): context=context).line_id], context=context): if line.state <> 'valid': - raise osv.except_osv('Error !', - 'Account move line "%s" is not valid' % line.name) + raise osv.except_osv(_('Error !'), + _('Account move line "%s" is not valid') % line.name) if move.reconcile_id and move.reconcile_id.line_ids: torec += map(lambda x: x.id, move.reconcile_id.line_ids) @@ -286,7 +287,7 @@ class account_bank_statement(osv.osv): else: account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context) except: - raise osv.except_osv('Error !', 'Unable to reconcile entry "%s": %.2f'%(move.name, move.amount)) + raise osv.except_osv(_('Error !'), _('Unable to reconcile entry "%s": %.2f') % (move.name, move.amount)) done.append(st.id) self.write(cr, uid, done, {'state':'confirm'}, context=context) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index a742c7ef84a..418ff1f56a9 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -31,7 +31,7 @@ import time import netsvc from osv import fields, osv - +from tools.translate import _ class account_move_line(osv.osv): _name = "account.move.line" @@ -431,7 +431,7 @@ class account_move_line(osv.osv): merges_rec = [] for line in self.browse(cr, uid, ids, context): if line.reconcile_id: - raise 'Already Reconciled' + raise _('Already Reconciled') if line.reconcile_partial_id: for line2 in line.reconcile_partial_id.line_partial_ids: if not line2.reconcile_id: @@ -460,8 +460,8 @@ class account_move_line(osv.osv): partner_id = False for line in unrec_lines: if line.state <> 'valid': - raise osv.except_osv('Error', - 'Entry "%s" is not valid !' % line.name) + raise osv.except_osv(_('Error'), + _('Entry "%s" is not valid !') % line.name) credit += line['credit'] debit += line['debit'] currency += line['amount_currency'] or 0.0 @@ -477,17 +477,17 @@ class account_move_line(osv.osv): r = cr.fetchall() #TODO: move this check to a constraint in the account_move_reconcile object if len(r) != 1: - raise osv.except_osv('Error', 'Entries are not of the same account or already reconciled ! ') + raise osv.except_osv(_('Error'), _('Entries are not of the same account or already reconciled ! ')) account = self.pool.get('account.account').browse(cr, uid, account_id, context=context) if not account.reconcile: - raise osv.except_osv('Error', 'The account is not defined to be reconcile !') + raise osv.except_osv(_('Error'), _('The account is not defined to be reconcile !')) if r[0][1] != None: - raise osv.except_osv('Error', 'Some entries are already reconciled !') + raise osv.except_osv(_('Error'), _('Some entries are already reconciled !')) if (not self.pool.get('res.currency').is_zero(cr, uid, account.company_id.currency_id, writeoff)) or \ (account.currency_id and (not self.pool.get('res.currency').is_zero(cr, uid, account.currency_id, currency))): if not writeoff_acc_id: - raise osv.except_osv('Warning', 'You have to provide an account for the write off entry !') + raise osv.except_osv(_('Warning'), _('You have to provide an account for the write off entry !')) if writeoff > 0: debit = writeoff credit = 0.0 @@ -629,7 +629,7 @@ class account_move_line(osv.osv): account_obj = self.pool.get('account.account') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: - raise osv.except_osv('Bad account!', 'You can not use an inactive account!') + raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if update_check: if ('account_id' in vals) or ('journal_id' in vals) or ('period_id' in vals) or ('move_id' in vals) or ('debit' in vals) or ('credit' in vals) or ('date' in vals): self._update_check(cr, uid, ids, context) @@ -647,7 +647,7 @@ class account_move_line(osv.osv): result = cr.fetchall() for (state,) in result: if state=='done': - raise osv.except_osv('Error !', 'You can not add/modify entries in a closed journal.') + raise osv.except_osv(_('Error !'), _('You can not add/modify entries in a closed journal.')) if not result: journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context) period = self.pool.get('account.period').browse(cr, uid, period_id, context) @@ -662,9 +662,9 @@ class account_move_line(osv.osv): done = {} for line in self.browse(cr, uid, ids, context): if line.move_id.state<>'draft': - raise osv.except_osv('Error !', 'You can not do this modification on a confirmed entry ! Please note that you can just change some non important fields !') + raise osv.except_osv(_('Error !'), _('You can not do this modification on a confirmed entry ! Please note that you can just change some non important fields !')) if line.reconcile_id: - raise osv.except_osv('Error !', 'You can not do this modification on a reconciled entry ! Please note that you can just change some non important fields !') + raise osv.except_osv(_('Error !'), _('You can not do this modification on a reconciled entry ! Please note that you can just change some non important fields !')) t = (line.journal_id.id, line.period_id.id) if t not in done: self._update_journal_check(cr, uid, line.journal_id.id, line.period_id.id, context) @@ -677,7 +677,7 @@ class account_move_line(osv.osv): account_obj = self.pool.get('account.account') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: - raise osv.except_osv('Bad account!', 'You can not use an inactive account!') + raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals and 'journal_id' not in context: context['journal_id'] = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: @@ -696,9 +696,9 @@ class account_move_line(osv.osv): res = cr.fetchone() if res: if res[1] != 'draft': - raise osv.except_osv('UserError', - 'The account move (%s) for centralisation ' \ - 'has been confirmed!' % res[2]) + raise osv.except_osv(_('UserError'), + _('The account move (%s) for centralisation ' \ + 'has been confirmed!') % res[2]) vals['move_id'] = res[0] if not vals.get('move_id', False): @@ -712,7 +712,7 @@ class account_move_line(osv.osv): move_id = self.pool.get('account.move').create(cr, uid, v, context) vals['move_id'] = move_id else: - raise osv.except_osv('No piece number !', 'Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.') + raise osv.except_osv(_('No piece number !'), _('Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.')) ok = not (journal.type_control_ids or journal.account_control_ids) if ('account_id' in vals): @@ -736,7 +736,7 @@ class account_move_line(osv.osv): ctx['date'] = vals['date'] vals['amount_currency'] = cur_obj.compute(cr, uid, account.company_id.currency_id.id, account.currency_id.id, vals.get('debit', 0.0)-vals.get('credit', 0.0), context=ctx) if not ok: - raise osv.except_osv('Bad account !', 'You can not use this general account in this journal !') + raise osv.except_osv(_('Bad account !'), _('You can not use this general account in this journal !')) result = super(osv.osv, self).create(cr, uid, vals, context) if check: self.pool.get('account.move').validate(cr, uid, [vals['move_id']], context) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 1e0b2738ed2..3ec87e737d3 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -37,6 +37,7 @@ import mx.DateTime from mx.DateTime import RelativeDateTime from tools import config +from tools.translate import _ class account_invoice(osv.osv): def _amount_untaxed(self, cr, uid, ids, name, args, context={}): @@ -82,7 +83,7 @@ class account_invoice(osv.osv): cr.execute("select id from account_analytic_journal where type=%s limit 1", (tt,)) result = cr.fetchone() if not result: - raise osv.except_osv('No Analytic Journal !', "You have to define an analytic journal of type '%s' !" % (tt,)) + raise osv.except_osv(_('No Analytic Journal !'),("You have to define an analytic journal of type '%s' !") % (tt,)) return result[0] def _get_type(self, cr, uid, context={}): @@ -171,7 +172,7 @@ class account_invoice(osv.osv): if t['state'] in ('draft', 'cancel'): unlink_ids.append(t['id']) else: - raise osv.except_osv('Invalid action !', 'Cannot delete invoice(s) which are already opened or paid !') + raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) which are already opened or paid !')) osv.osv.unlink(self, cr, uid, unlink_ids) return True @@ -378,7 +379,7 @@ class account_invoice(osv.osv): if inv.move_id: continue if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0): - raise osv.except_osv('Bad total !', 'Please verify the price of the invoice !\nThe real total does not match the computed total.') + raise osv.except_osv(_('Bad total !'), _('Please verify the price of the invoice !\nThe real total does not match the computed total.')) company_currency = inv.company_id.currency_id.id # create the analytical lines line_ids = self.read(cr, uid, [inv.id], ['invoice_line'])[0]['invoice_line'] @@ -398,13 +399,13 @@ class account_invoice(osv.osv): key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id) tax_key.append(key) if not key in compute_taxes: - raise osv.except_osv('Warning !', 'Global taxes defined, but not in invoice lines !') + raise osv.except_osv(_('Warning !'), _('Global taxes defined, but not in invoice lines !')) base = compute_taxes[key]['base'] if abs(base - tax.base) > inv.company_id.currency_id.rounding: - raise osv.except_osv('Warning !', 'Tax base different !\nClick on compute to update tax base') + raise osv.except_osv(_('Warning !'), _('Tax base different !\nClick on compute to update tax base')) for key in compute_taxes: if not key in tax_key: - raise osv.except_osv('Warning !', 'Taxes missing !') + raise osv.except_osv(_('Warning !'), _('Taxes missing !')) # one move line per tax line iml += ait_obj.move_line_get(cr, uid, inv.id) @@ -494,8 +495,8 @@ class account_invoice(osv.osv): if journal.sequence_id: name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id) if journal.centralisation: - raise osv.except_osv('UserError', - 'Can not create invoice move on centralized journal') + raise osv.except_osv(_('UserError'), + _('Can not create invoice move on centralized journal')) move = {'name': name, 'line_id': line, 'journal_id': journal_id} if inv.period_id: @@ -684,7 +685,7 @@ class account_invoice(osv.osv): if journal.sequence_id: name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id) else: - raise osv.except_osv('No piece number !', 'Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.') + raise osv.except_osv(_('No piece number !'), _('Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.')) types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} direction = types[invoice.type] l1 = { diff --git a/addons/account/wizard/wizard_aged_trial_balance.py b/addons/account/wizard/wizard_aged_trial_balance.py index c381a229fa5..cf9af968671 100644 --- a/addons/account/wizard/wizard_aged_trial_balance.py +++ b/addons/account/wizard/wizard_aged_trial_balance.py @@ -33,6 +33,7 @@ import datetime import pooler from mx.DateTime import * +from tools.translate import _ _aged_trial_form = """
@@ -60,7 +61,7 @@ def _calc_dates(self, cr, uid, data, context): res = {} period_length = data['form']['period_length'] if period_length<=0: - raise wizard.except_wizard('UserError', 'You must enter a period length that cannot be 0 or below !') + raise wizard.except_wizard(_('UserError'), _('You must enter a period length that cannot be 0 or below !')) start = now() for i in range(5)[::-1]: stop = start-RelativeDateTime(days=period_length) diff --git a/addons/account/wizard/wizard_bank_reconcile.py b/addons/account/wizard/wizard_bank_reconcile.py index 0a1f742aeba..30bcea5510b 100644 --- a/addons/account/wizard/wizard_bank_reconcile.py +++ b/addons/account/wizard/wizard_bank_reconcile.py @@ -28,6 +28,7 @@ ############################################################################## import wizard +from tools.translate import _ _journal_form = ''' @@ -43,7 +44,7 @@ def _action_open_window(self, cr, uid, data, context): cr.execute('select default_credit_account_id from account_journal where id=%d', (form['journal_id'],)) account_id = cr.fetchone()[0] if not account_id: - raise Exception, 'You have to define the bank account\nin the journal definition for reconciliation.' + raise Exception, _('You have to define the bank account\nin the journal definition for reconciliation.') return { 'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (form['journal_id'],account_id), 'name': 'Saisie Standard', diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index f1d28321ea5..490473af2b5 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -30,6 +30,7 @@ import wizard import osv import pooler +from tools.translate import _ _transaction_form = ''' @@ -57,7 +58,7 @@ def _data_load(self, cr, uid, data, context): def _data_save(self, cr, uid, data, context): if not data['form']['sure']: - raise wizard.except_wizard('UserError', 'Closing of fiscal year canceled, please check the box !') + raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year canceled, please check the box !')) pool = pooler.get_pool(cr.dbname) fy_id = data['form']['fy_id'] @@ -66,17 +67,17 @@ def _data_save(self, cr, uid, data, context): new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']) start_jp = new_fyear.start_journal_period_id if not start_jp: - raise wizard.except_wizard('UserError', - 'The new fiscal year should have a journal for new entries define on it') + raise wizard.except_wizard(_('UserError'), + _('The new fiscal year should have a journal for new entries define on it')) new_journal = start_jp.journal_id if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id: - raise wizard.except_wizard('UserError', - 'The journal must have default credit and debit account') + raise wizard.except_wizard(_('UserError'), + _('The journal must have default credit and debit account')) if not new_journal.centralisation: - raise wizard.except_wizard('UserError', - 'The journal must have centralised counterpart') + raise wizard.except_wizard(_('UserError'), + _('The journal must have centralised counterpart')) query_line = pool.get('account.move.line')._query_get(cr, uid, obj='account_move_line', context={'fiscalyear': fy_id}) diff --git a/addons/account/wizard/wizard_journal.py b/addons/account/wizard/wizard_journal.py index 315d23fb1fc..5f7693c134a 100644 --- a/addons/account/wizard/wizard_journal.py +++ b/addons/account/wizard/wizard_journal.py @@ -30,6 +30,7 @@ import wizard from osv import osv import pooler +from tools.translate import _ _journal_form = ''' @@ -66,7 +67,7 @@ def _action_open_window(self, cr, uid, data, context): name = pooler.get_pool(cr.dbname).get('account.journal').read(cr, uid, [form['journal_id']])[0]['name'] state = pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [form['period_id']])[0]['state'] if state == 'done': - raise wizard.except_wizard('UserError', 'This period is already closed !') + raise wizard.except_wizard(_('UserError'), _('This period is already closed !')) jp.create(cr, uid, {'name':name, 'period_id': form['period_id'], 'journal_id':form['journal_id']}) ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])]) jp = jp.browse(cr, uid, ids, context=context)[0] diff --git a/addons/account/wizard/wizard_open_closed_fiscalyear.py b/addons/account/wizard/wizard_open_closed_fiscalyear.py index a6f3b26e170..0e2549e3e93 100644 --- a/addons/account/wizard/wizard_open_closed_fiscalyear.py +++ b/addons/account/wizard/wizard_open_closed_fiscalyear.py @@ -29,6 +29,7 @@ import wizard import netsvc import pooler from osv import fields, osv +from tools.translate import _ form = """ @@ -44,10 +45,10 @@ def _remove_entries(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) data_fyear = pool.get('account.fiscalyear').browse(cr,uid,data['form']['fyear_id']) if not data_fyear.end_journal_period_id: - raise wizard.except_wizard('Error', 'No journal for ending writings have been defined for the fiscal year') + raise wizard.except_wizard(_('Error'), _('No journal for ending writings have been defined for the fiscal year')) period_journal = data_fyear.end_journal_period_id if not period_journal.journal_id.centralisation: - raise wizard.except_wizard('UserError', 'The journal must have centralised counterpart') + raise wizard.except_wizard(_('UserError'), _('The journal must have centralised counterpart')) ids_move = pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)]) pool.get('account.move').unlink(cr,uid,ids_move) cr.execute('UPDATE account_journal_period ' \ diff --git a/addons/account/wizard/wizard_pay_invoice.py b/addons/account/wizard/wizard_pay_invoice.py index ed7f23013ec..adfc7211b0a 100644 --- a/addons/account/wizard/wizard_pay_invoice.py +++ b/addons/account/wizard/wizard_pay_invoice.py @@ -31,6 +31,7 @@ import wizard import netsvc import pooler import time +from tools.translate import _ pay_form = ''' @@ -68,7 +69,7 @@ def _pay_and_reconcile(self, cr, uid, data, context): acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id if not acc_id: - raise wizard.except_wizard('Error !', 'Your journal must have a default credit and debit account.') + raise wizard.except_wizard(_('Error !'), _('Your journal must have a default credit and debit account.')) pool.get('account.invoice').pay_and_reconcile(cr, uid, [data['id']], amount, acc_id, period_id, journal_id, writeoff_account_id, period_id, writeoff_journal_id, context, data['form']['name']) @@ -108,7 +109,7 @@ def _get_period(self, cr, uid, data, context={}): period_id = ids[0] invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context) if invoice.state == 'draft': - raise wizard.except_wizard('Error !', _('Can not pay draft invoice.')) + raise wizard.except_wizard(_('Error !'), _('Can not pay draft invoice.')) return { 'period_id': period_id, 'amount': invoice.amount_total, diff --git a/addons/account/wizard/wizard_validate_account_move.py b/addons/account/wizard/wizard_validate_account_move.py index 12e3a0f820c..d5cec6a5ca9 100644 --- a/addons/account/wizard/wizard_validate_account_move.py +++ b/addons/account/wizard/wizard_validate_account_move.py @@ -30,6 +30,7 @@ import wizard from osv import osv import pooler +from tools.translate import _ _journal_form = ''' @@ -48,7 +49,7 @@ def _validate_move(self, cr, uid, data, context={}): move_obj = pool.get('account.move') ids_move = move_obj.search(cr,uid,[('state','=','draft'),('journal_id','=',data['form']['journal_id']),('period_id','=',data['form']['period_id'])]) if not ids_move: - raise wizard.except_wizard('Warning', 'Specified Journal does not have any account move entries in draft state for this period') + raise wizard.except_wizard(_('Warning'), _('Specified Journal does not have any account move entries in draft state for this period')) res = move_obj.button_validate(cr, uid, ids_move, context) return {} @@ -76,7 +77,7 @@ def _validate_move_lines(self, cr, uid, data, context={}): move_ids.append(line.move_id.id) move_ids = list(set(move_ids)) if not move_ids: - raise wizard.except_wizard('Warning', 'Selected Move lines does not have any account move enties in draft state') + raise wizard.except_wizard(_('Warning'), _('Selected Move lines does not have any account move enties in draft state')) res = move_obj.button_validate(cr, uid, move_ids, context) return {} diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index c19934cda2a..f204ea3ceaf 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -30,6 +30,7 @@ import operator from osv import osv, fields from osv.orm import ID_MAX +from tools.translate import _ class account_analytic_account(osv.osv): @@ -535,8 +536,8 @@ class account_analytic_account_summary_user(osv.osv): ','.join([str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user)) for x in sub_ids]), d1, self._order),d2) if not cr.rowcount == len({}.fromkeys(sub_ids)): - raise except_orm('AccessError', - 'You try to bypass an access rule (Document type: %s).' % self._description) + raise except_orm(_('AccessError'), + _('You try to bypass an access rule (Document type: %s).') % self._description) else: cr.execute('select %s from \"%s\" where id in (%s) ' \ 'and account_id in (%s) ' \ @@ -712,8 +713,8 @@ class account_analytic_account_summary_month(osv.osv): ','.join([str(x)[-6:] for x in sub_ids]), d1, self._order),d2) if not cr.rowcount == len({}.fromkeys(sub_ids)): - raise except_orm('AccessError', - 'You try to bypass an access rule (Document type: %s).' % self._description) + raise except_orm(_('AccessError'), + _('You try to bypass an access rule (Document type: %s).') % self._description) else: cr.execute('select %s from \"%s\" where id in (%s) ' \ 'and account_id in (%s) ' \ diff --git a/addons/account_followup/wizard/wizard_followup_print.py b/addons/account_followup/wizard/wizard_followup_print.py index f8cbd4a58ba..b758f4eb9ac 100644 --- a/addons/account_followup/wizard/wizard_followup_print.py +++ b/addons/account_followup/wizard/wizard_followup_print.py @@ -34,6 +34,7 @@ import time import tools from osv import fields, osv +from tools.translate import _ _followup_wizard_date_form = """ @@ -227,8 +228,8 @@ class followup_all_print(wizard.interface): fups = {} fup_ids = pool.get('account_followup.followup').search(cr, uid, []) if not fup_ids: - raise wizard.except_wizard('No Follow up Defined', - 'You must define at least one follow up for your company !') + raise wizard.except_wizard(_('No Follow up Defined'), + _('You must define at least one follow up for your company !')) fup_id = fup_ids[0] current_date = datetime.date(*time.strptime(data['form']['date'], diff --git a/addons/base_module_publish/wizard/base_module_publish.py b/addons/base_module_publish/wizard/base_module_publish.py index 8fba0d11642..fd774f79d47 100644 --- a/addons/base_module_publish/wizard/base_module_publish.py +++ b/addons/base_module_publish/wizard/base_module_publish.py @@ -35,6 +35,7 @@ import urllib import base64 import module_zip +import tools intro_form = ''' @@ -240,12 +241,12 @@ def _upload(self, cr, uid, datas, context): ('module', res['module_filename'], res['module_file']) ]) if result[0] == "1": - raise wizard.except_wizard('Error', 'Login failed!') + raise wizard.except_wizard(_('Error'), _('Login failed!')) elif result[0] == "2": - raise wizard.except_wizard('Error', - 'This version of the module is already exist on the server') + raise wizard.except_wizard(_('Error'), + _('This version of the module is already exist on the server')) elif result[0] != "0": - raise wizard.except_wizard('Error', 'Failed to upload the file') + raise wizard.except_wizard(_('Error'), _('Failed to upload the file')) updata = { 'link_name': mod.shortdesc or '', @@ -287,7 +288,7 @@ def module_check(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) module = pool.get('ir.module.module').browse(cr, uid, data['id'], context) if module.state != 'installed': - raise wizard.except_wizard('Error', 'You could not publish a module that is not installed!') + raise wizard.except_wizard(_('Error'), _('You could not publish a module that is not installed!')) return { 'name': module.name, 'shortdesc': module.shortdesc, diff --git a/addons/base_module_publish/wizard/module_zip.py b/addons/base_module_publish/wizard/module_zip.py index 376fd4c535f..6aca0381ccc 100644 --- a/addons/base_module_publish/wizard/module_zip.py +++ b/addons/base_module_publish/wizard/module_zip.py @@ -58,8 +58,8 @@ def createzip(cr, uid, moduleid, context, b64enc=True, src=True): module = module_obj.browse(cr, uid, moduleid) if module.state != 'installed': - raise wizard.except_wizard('Error', - 'Can not export module that is not installed!') + raise wizard.except_wizard(_('Error'), + _('Can not export module that is not installed!')) ad = tools.config['addons_path'] if os.path.isdir(os.path.join(ad, module.name)): @@ -73,7 +73,7 @@ def createzip(cr, uid, moduleid, context, b64enc=True, src=True): elif os.path.isfile(os.path.join(ad, module.name + '.zip')): val = file(os.path.join(ad, module.name + '.zip'), 'rb').read() else: - raise wizard.except_wizard('Error', 'Could not find the module to export!') + raise wizard.except_wizard(_('Error'), _('Could not find the module to export!')) if b64enc: val =base64.encodestring(val) return {'module_file':val, 'module_filename': module.name + '-' + \ diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 10c05009ca9..0e26cefea94 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -33,6 +33,7 @@ from osv import fields,osv,orm import mx.DateTime import base64 +from tools.translate import _ MAX_LEVEL = 15 AVAILABLE_STATES = [ @@ -619,8 +620,8 @@ class crm_case(osv.osv): cases = self.browse(cr, uid, ids) for case in cases: if not case.email_from: - raise osv.except_osv('Error!', - 'You must put a Partner eMail to use this action!') + raise osv.except_osv(_('Error!'), + _('You must put a Partner eMail to use this action!')) self.__history(cr, uid, cases, 'Send', history=True, email=False) for case in cases: self.write(cr, uid, [case.id], { @@ -683,7 +684,7 @@ class crm_case(osv.osv): if case.section_id.parent_id.user_id: data['user_id'] = case.section_id.parent_id.user_id.id else: - raise osv.except_osv('Error !', 'You can not escalate this case.\nYou are already at the top level.') + raise osv.except_osv(_('Error !'), _('You can not escalate this case.\nYou are already at the top level.')) self.write(cr, uid, ids, data) self.__history(cr, uid, cases, 'escalate') self._action(cr, uid, cases, 'escalate') diff --git a/addons/delivery/delivery.py b/addons/delivery/delivery.py index 9ac350b5e5e..61d94874a91 100644 --- a/addons/delivery/delivery.py +++ b/addons/delivery/delivery.py @@ -29,6 +29,7 @@ import netsvc from osv import fields,osv,orm +from tools.translate import _ class delivery_carrier(osv.osv): _name = "delivery.carrier" @@ -116,7 +117,7 @@ class delivery_grid(osv.osv): ok = True break if not ok: - raise except_osv('No price avaible !', 'No line matched this order in the choosed delivery grids !') + raise except_osv(_('No price avaible !'), _('No line matched this order in the choosed delivery grids !')) return price diff --git a/addons/delivery/stock.py b/addons/delivery/stock.py index fc150d79669..e83c1f0480c 100644 --- a/addons/delivery/stock.py +++ b/addons/delivery/stock.py @@ -27,6 +27,7 @@ ############################################################################### import netsvc from osv import fields,osv +from tools.translate import _ # Overloaded stock_picking to manage carriers : @@ -67,8 +68,8 @@ class stock_picking(osv.osv): grid_id = carrier_obj.grid_get(cursor, user, [picking.carrier_id.id], picking.address_id.id, context=context) if not grid_id: - raise osv.except_osv('Warning', - 'The carrier %s (id: %d) has no delivery grid!' \ + raise osv.except_osv(_('Warning'), + _('The carrier %s (id: %d) has no delivery grid!') \ % (picking.carrier_id.name, picking.carrier_id.id)) invoice = invoices[result[picking.id]] diff --git a/addons/delivery/wizard/delivery_sale_order.py b/addons/delivery/wizard/delivery_sale_order.py index 74216ac7847..256e7a60a5e 100644 --- a/addons/delivery/wizard/delivery_sale_order.py +++ b/addons/delivery/wizard/delivery_sale_order.py @@ -31,6 +31,7 @@ import time import wizard import ir import pooler +from tools.translate import _ delivery_form = """ @@ -47,7 +48,7 @@ def _delivery_default(self, cr, uid, data, context): order_obj = pooler.get_pool(cr.dbname).get('sale.order') order = order_obj.browse(cr, uid, data['ids'])[0] if not order.state in ('draft'): - raise wizard.except_wizard('Order not in draft state !', 'The order state have to be draft to add delivery lines.') + raise wizard.except_wizard(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.')) carrier_id = order.partner_id.property_delivery_carrier.id return {'carrier_id': carrier_id} @@ -60,7 +61,7 @@ def _delivery_set(self, cr, uid, data, context): for order in order_objs: grid_id = pooler.get_pool(cr.dbname).get('delivery.carrier').grid_get(cr, uid, [data['form']['carrier_id']],order.partner_shipping_id.id) if not grid_id: - raise wizard.except_wizard('No grid avaible !', 'No grid matching for this carrier !') + raise wizard.except_wizard(_('No grid avaible !'), _('No grid matching for this carrier !')) grid = pooler.get_pool(cr.dbname).get('delivery.grid').browse(cr, uid, [grid_id])[0] line_obj.create(cr, uid, { diff --git a/addons/hr/hr.py b/addons/hr/hr.py index b1e20537804..e1c5edaf2d1 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -31,6 +31,7 @@ from mx import DateTime import time from osv import fields, osv +from tools.translate import _ class hr_timesheet_group(osv.osv): _name = "hr.timesheet.group" @@ -140,7 +141,7 @@ class hr_employee(osv.osv): def sign_change(self, cr, uid, ids, context={}, dt=False): for emp in self.browse(cr, uid, ids): if not self._action_check(cr, uid, emp.id, dt, context): - raise osv.except_osv('Warning', 'You tried to sign with a date anterior to another event !\nTry to contact the administrator to correct attendances.') + raise osv.except_osv(_('Warning'), _('You tried to sign with a date anterior to another event !\nTry to contact the administrator to correct attendances.')) res = {'action':'action', 'employee_id':emp.id} if dt: res['name'] = dt @@ -151,7 +152,7 @@ class hr_employee(osv.osv): id = False for emp in self.browse(cr, uid, ids): if not self._action_check(cr, uid, emp.id, dt, context): - raise osv.except_osv('Warning', 'You tried to sign out with a date anterior to another event !\nTry to contact the administrator to correct attendances.') + raise osv.except_osv(_('Warning'), _('You tried to sign out with a date anterior to another event !\nTry to contact the administrator to correct attendances.')) res = {'action':'sign_out', 'employee_id':emp.id} if dt: res['name'] = dt @@ -168,7 +169,7 @@ class hr_employee(osv.osv): id = False for emp in self.browse(cr, uid, ids): if not self._action_check(cr, uid, emp.id, dt, context): - raise osv.except_osv('Warning', 'You tried to sign in with a date anterior to another event !\nTry to contact the administrator to correct attendances.') + raise osv.except_osv(_('Warning'), _('You tried to sign in with a date anterior to another event !\nTry to contact the administrator to correct attendances.')) res = {'action':'sign_in', 'employee_id':emp.id} if dt: res['name'] = dt diff --git a/addons/hr/wizard/sign_in_out.py b/addons/hr/wizard/sign_in_out.py index a430473dccf..70b909262a8 100644 --- a/addons/hr/wizard/sign_in_out.py +++ b/addons/hr/wizard/sign_in_out.py @@ -30,6 +30,7 @@ import wizard import netsvc import time +from tools.translate import _ si_so_form =''' @@ -76,7 +77,7 @@ def _sign_in(self, cr, uid, data, context): emp_id = data['form']['emp_id'] if 'last_time' in data['form'] : if data['form']['last_time'] > time.strftime('%Y-%m-%d'): - raise wizard.except_wizard('UserError', 'The sign-out date must be in the past') + raise wizard.except_wizard(_('UserError'), _('The sign-out date must be in the past')) return {'success': False} service.execute(cr.dbname, uid, 'hr.attendance', 'create', { 'name': data['form']['last_time'], @@ -87,7 +88,7 @@ def _sign_in(self, cr, uid, data, context): success = service.execute(cr.dbname, uid, 'hr.employee', 'sign_in', [emp_id]) print success except: - raise wizard.except_wizard('UserError', 'A sign-in must be right after a sign-out !') + raise wizard.except_wizard(_('UserError'), _('A sign-in must be right after a sign-out !')) return {'success': success} def _sign_out(self, cr, uid, data, context): @@ -95,13 +96,13 @@ def _sign_out(self, cr, uid, data, context): emp_id = data['form']['emp_id'] if 'last_time' in data['form'] : if data['form']['last_time'] > time.strftime('%Y-%m-%d'): - raise wizard.except_wizard('UserError', 'The Sign-in date must be in the past') + raise wizard.except_wizard(_('UserError'), _('The Sign-in date must be in the past')) return {'success': False} service.execute(cr.dbname, uid, 'hr.attendance', 'create', {'name':data['form']['last_time'], 'action':'sign_in', 'employee_id':emp_id}) try: success = service.execute(cr.dbname, uid, 'hr.employee', 'sign_out', [emp_id]) except: - raise wizard.except_wizard('UserError', 'A sign-out must be right after a sign-in !') + raise wizard.except_wizard(_('UserError'), _('A sign-out must be right after a sign-in !')) return {'success' : success} diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 87cca1d38f0..adbb12e0bee 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -31,6 +31,7 @@ from mx import DateTime import time from osv import fields, osv +from tools.translate import _ def _employee_get(obj,cr,uid,context={}): ids = obj.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)]) @@ -142,7 +143,7 @@ class hr_expense_expense(osv.osv): 'account_analytic_id': l.analytic_account.id, })) if not exp.employee_id.address_id: - raise osv.except_osv('Error !', 'The employee must have a contact address') + raise osv.except_osv(_('Error !'), _('The employee must have a contact address')) acc = exp.employee_id.address_id.partner_id.property_account_payable.id payment_term_id = exp.employee_id.address_id.partner_id.property_payment_term.id inv = { diff --git a/addons/hr_timesheet/wizard/sign_in_out.py b/addons/hr_timesheet/wizard/sign_in_out.py index 5eba0b3cc34..acda5153f24 100644 --- a/addons/hr_timesheet/wizard/sign_in_out.py +++ b/addons/hr_timesheet/wizard/sign_in_out.py @@ -31,6 +31,7 @@ import wizard import time import pooler +from tools.translate import _ si_form =''' @@ -82,7 +83,7 @@ def _get_empid(self, cr, uid, data, context): if emp_id: employee = emp_obj.read(cr, uid, emp_id)[0] return {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0], 'date':False, 'server_date':time.strftime('%Y-%m-%d %H:%M:%S')} - raise wizard.except_wizard('UserError', 'No employee defined for your user !') + raise wizard.except_wizard(_('UserError'), _('No employee defined for your user !')) def _get_empid2(self, cr, uid, data, context): res = _get_empid(self,cr, uid, data, context) @@ -112,7 +113,7 @@ def _write(self, cr, uid, data, emp_id, context): hour = round(round((hour + minimum / 2) / minimum) * minimum, 2) res = timesheet_obj.default_get(cr, uid, ['product_id','product_uom_id']) if not res['product_uom_id']: - raise wizard.except_wizard('UserError', 'No cost unit defined for this employee !') + raise wizard.except_wizard(_('UserError'), _('No cost unit defined for this employee !')) up = timesheet_obj.on_change_unit_amount(cr, uid, False, res['product_id'], hour, res['product_uom_id'])['value'] res['name'] = data['form']['info'] res['account_id'] = data['form']['account_id'] diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 66baf17ce7a..8629f587e32 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -30,6 +30,7 @@ from osv import fields, osv +from tools.translate import _ class hr_timesheet_invoice_factor(osv.osv): _name = "hr_timesheet_invoice.factor" @@ -93,8 +94,8 @@ class account_analytic_line(osv.osv): select = [ids] for line in self.browse(cr, uid, select): if line.invoice_id: - raise osv.except_osv('Error !', - 'You can not modify an invoiced analytic line!') + raise osv.except_osv(_('Error !'), + _('You can not modify an invoiced analytic line!')) return True def copy(self, cursor, user, obj_id, default=None, context=None): diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py index fc7ecad9c1f..5bd6f541d30 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py @@ -30,6 +30,7 @@ import wizard import pooler import time +from tools.translate import _ # # Create an final invoice based on selected timesheet lines @@ -57,9 +58,9 @@ class final_invoice_create(wizard.interface): partner = account.partner_id amount_total=0.0 if (not partner) or not (account.pricelist_id): - raise wizard.except_wizard('Analytic account incomplete', - 'Please fill in the partner and pricelist field ' - 'in the analytic account:\n%s' % (account.name,)) + raise wizard.except_wizard(_('Analytic account incomplete'), + _('Please fill in the partner and pricelist field ' + 'in the analytic account:\n%s') % (account.name,)) date_due = False if partner.property_payment_term: @@ -188,7 +189,7 @@ class final_invoice_create(wizard.interface): if data['form']['use_amount_max']: if abs(account.amount_max - amount_total) > data['form']['balance_amount'] : if not data['form']['balance_product']: - raise wizard.except_wizard('Balance product needed', 'Please fill a Balance product in the wizard') + raise wizard.except_wizard(_('Balance product needed'), _('Please fill a Balance product in the wizard')) product = pool.get('product.product').browse(cr, uid, data['form']['balance_product'], context2) taxes = product.taxes_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 a92e82256a0..3130bd53f5f 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -30,6 +30,7 @@ import wizard import pooler import time +from tools.translate import _ # # Create an invoice based on selected timesheet lines @@ -57,9 +58,9 @@ class invoice_create(wizard.interface): for account in analytic_account_obj.browse(cr, uid, account_ids, context): partner = account.partner_id if (not partner) or not (account.pricelist_id): - raise wizard.except_wizard('Analytic account incomplete', - 'Please fill in the partner and pricelist field ' - 'in the analytic account:\n%s' % (account.name,)) + raise wizard.except_wizard(_('Analytic account incomplete'), + _('Please fill in the partner and pricelist field ' + 'in the analytic account:\n%s') % (account.name,)) date_due = False if partner.property_payment_term: @@ -97,7 +98,7 @@ class invoice_create(wizard.interface): for product_id,factor_id,qty in cr.fetchall(): product = pool.get('product.product').browse(cr, uid, product_id, context2) if not product: - raise wizard.except_wizard('Error', 'At least on line have no product !') + raise wizard.except_wizard(_('Error'), _('At least on line have no product !')) factor_name = '' factor = pool.get('hr_timesheet_invoice.factor').browse(cr, uid, factor_id, context2) if factor.customer_name: diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 4587dff4608..d4a0fccd949 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -33,6 +33,7 @@ from osv import osv import netsvc from mx import DateTime +from tools.translate import _ class one2many_mod2(fields.one2many): @@ -148,7 +149,7 @@ class hr_timesheet_sheet(osv.osv): wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'hr_timesheet_sheet.sheet', sheet.id, 'confirm', cr) else: - raise osv.except_osv('Warning !', 'Please verify that the total difference of the sheet is lower than %.2f !' %(di,)) + raise osv.except_osv(_('Warning !'), _('Please verify that the total difference of the sheet is lower than %.2f !') %(di,)) return True def date_today(self, cr, uid, ids, context): @@ -191,7 +192,7 @@ class hr_timesheet_sheet(osv.osv): def sign_in(self, cr, uid, ids, context): if not self.browse(cr, uid, ids, context)[0].date_current == time.strftime('%Y-%m-%d'): - raise osv.except_osv('Error !', 'You can not sign in from an other date than today') + raise osv.except_osv(_('Error !'), _('You can not sign in from an other date than today')) emp_obj = self.pool.get('hr.employee') emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)]) context['sheet_id']=ids[0] @@ -200,7 +201,7 @@ class hr_timesheet_sheet(osv.osv): def sign_out(self, cr, uid, ids, context): if not self.browse(cr, uid, ids, context)[0].date_current == time.strftime('%Y-%m-%d'): - raise osv.except_osv('Error !', 'You can not sign out from an other date than today') + raise osv.except_osv(_('Error !'), _('You can not sign out from an other date than today')) emp_obj = self.pool.get('hr.employee') emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)]) context['sheet_id']=ids[0] @@ -395,7 +396,7 @@ class hr_timesheet_line(osv.osv): if 'sheet_id' in vals: ts = self.pool.get('hr_timesheet_sheet.sheet').browse(cr, uid, vals['sheet_id']) if not ts.state in ('draft', 'new'): - raise osv.except_osv('Error !', 'You can not modify an entry in a confirmed timesheet !') + raise osv.except_osv(_('Error !'), _('You can not modify an entry in a confirmed timesheet !')) return super(hr_timesheet_line,self).create(cr, uid, vals, *args, **kwargs) def unlink(self, cr, uid, ids, *args, **kwargs): @@ -409,7 +410,7 @@ class hr_timesheet_line(osv.osv): def _check(self, cr, uid, ids): for att in self.browse(cr, uid, ids): if att.sheet_id and att.sheet_id.state not in ('draft', 'new'): - raise osv.except_osv('Error !', 'You can not modify an entry in a confirmed timesheet !') + raise osv.except_osv(_('Error !'), _('You can not modify an entry in a confirmed timesheet !')) return True hr_timesheet_line() @@ -514,12 +515,12 @@ class hr_attendance(osv.osv): if 'sheet_id' in context: ts = self.pool.get('hr_timesheet_sheet.sheet').browse(cr, uid, context['sheet_id']) if ts.state not in ('draft', 'new'): - raise osv.except_osv('Error !', 'You can not modify an entry in a confirmed timesheet !') + raise osv.except_osv(_('Error !'), _('You can not modify an entry in a confirmed timesheet !')) res = super(hr_attendance,self).create(cr, uid, vals, context=context) if 'sheet_id' in context: if context['sheet_id'] != self.browse(cr, uid, res, context=context).sheet_id.id: - raise osv.except_osv('UserError', 'You can not enter an attendance ' \ - 'date outside the current timesheet dates!') + raise osv.except_osv(_('UserError'), _('You can not enter an attendance ' \ + 'date outside the current timesheet dates!')) return res def unlink(self, cr, uid, ids, *args, **kwargs): @@ -532,14 +533,14 @@ class hr_attendance(osv.osv): if 'sheet_id' in context: for attendance in self.browse(cr, uid, ids, context=context): if context['sheet_id'] != attendance.sheet_id.id: - raise osv.except_osv('UserError', 'You can not enter an attendance ' \ - 'date outside the current timesheet dates!') + raise osv.except_osv(_('UserError'), _('You can not enter an attendance ' \ + 'date outside the current timesheet dates!')) return res def _check(self, cr, uid, ids): for att in self.browse(cr, uid, ids): if att.sheet_id and att.sheet_id.state not in ('draft', 'new'): - raise osv.except_osv('Error !', 'You can not modify an entry in a confirmed timesheet !') + raise osv.except_osv(_('Error !'), _('You can not modify an entry in a confirmed timesheet !')) return True hr_attendance() diff --git a/addons/hr_timesheet_sheet/wizard/wizard_timesheet_current.py b/addons/hr_timesheet_sheet/wizard/wizard_timesheet_current.py index 8fca05e263a..f6685d7d96a 100644 --- a/addons/hr_timesheet_sheet/wizard/wizard_timesheet_current.py +++ b/addons/hr_timesheet_sheet/wizard/wizard_timesheet_current.py @@ -33,13 +33,14 @@ import netsvc import time import pooler from osv import osv +from tools.translate import _ class wiz_timesheet_open(wizard.interface): def _open_timesheet(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) user_ids = pool.get('hr.employee').search(cr, uid, [('user_id','=',uid)]) if not len(user_ids): - raise wizard.except_wizard('Error !', 'No employee defined for your user !') + raise wizard.except_wizard(_('Error !'), _('No employee defined for your user !')) ts = pool.get('hr_timesheet_sheet.sheet') ids = ts.search(cr, uid, [('user_id','=',uid),('state','=','draft'),('date_from','<=',time.strftime('%Y-%m-%d')), ('date_to','>=',time.strftime('%Y-%m-%d'))]) view_type = 'form,tree' diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 5b28b29bacc..78b9fcf6cbf 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -34,6 +34,7 @@ from osv import fields, osv from _common import rounding import time from tools import config +from tools.translate import _ class price_type(osv.osv): """ @@ -136,9 +137,9 @@ class product_pricelist(osv.osv): plversion = cr.dictfetchone() if not plversion: - raise osv.except_osv('Warning !', - 'No active version for the selected pricelist !\n' \ - 'Please create or activate one.') + raise osv.except_osv(_('Warning !'), + _('No active version for the selected pricelist !\n' \ + 'Please create or activate one.')) cr.execute('SELECT id, categ_id ' \ 'FROM product_template ' \ @@ -154,10 +155,10 @@ class product_pricelist(osv.osv): 'WHERE id = %d', (categ,)) categ = cr.fetchone()[0] if str(categ) in categ_ids: - raise osv.except_osv('Warning !', - 'Could not resolve product category, ' \ + raise osv.except_osv(_('Warning !'), + _('Could not resolve product category, ' \ 'you have defined cyclic categories ' \ - 'of products!') + 'of products!')) if categ_ids: categ_where = '(categ_id IN (' + ','.join(categ_ids) + '))' else: diff --git a/addons/project/wizard/billing.py b/addons/project/wizard/billing.py index 5e551ecc542..348de0f3563 100644 --- a/addons/project/wizard/billing.py +++ b/addons/project/wizard/billing.py @@ -89,9 +89,9 @@ def _do_orders(self, cr, uid, data, context): if not task.project_id.id in customers: partner = task.partner_id or task.project_id.partner_id if not partner.id: - raise wizard.except_wizard('Error !', 'No partner defined for the task or project.') + raise wizard.except_wizard(_('Error !'), _('No partner defined for the task or project.')) if not task.project_id.pricelist_id.id: - raise wizard.except_wizard('Error !', 'No pricelist defined in the project definition.') + raise wizard.except_wizard(_('Error !'), _('No pricelist defined in the project definition.')) adr = pooler.get_pool(cr.dbname).get('res.partner').address_get(cr, uid, [partner.id], ['default','invoice','shipping']) a = partner.property_account_receivable.id diff --git a/addons/project/wizard/close_task.py b/addons/project/wizard/close_task.py index 994e1a50bba..264048ee489 100644 --- a/addons/project/wizard/close_task.py +++ b/addons/project/wizard/close_task.py @@ -50,7 +50,7 @@ def email_send(cr, uid, ids, to_adr, description, context={}): from_adr = task.user_id.address_id.email signature = task.user_id.signature else: - raise osv.except_osv('Error', "Couldn't send mail because your email address is not configured!") + raise osv.except_osv(_('Error'), _("Couldn't send mail because your email address is not configured!")) if to_adr: val = { @@ -66,7 +66,7 @@ def email_send(cr, uid, ids, to_adr, description, context={}): body = u'%s\n%s\n%s\n\n-- \n%s' % (header, description, footer, signature) email(from_adr, [to_adr], subject, body.encode('utf-8'), email_bcc=[from_adr]) else: - raise osv.except_osv('Error', "Couldn't send mail because the contact for this task (%s) has no email address!"% contact.name) + raise osv.except_osv(_('Error'), _("Couldn't send mail because the contact for this task (%s) has no email address!") % contact.name) class wizard_close(wizard.interface): def _check_complete(self, cr, uid, data, context): diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index d3847499d1d..7c7297b6516 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -36,6 +36,7 @@ import ir from mx import DateTime import pooler from tools import config +from tools.translate import _ # # Model definition @@ -204,7 +205,7 @@ class purchase_order(osv.osv): if not a: a = ol.product_id.categ_id.property_account_expense_categ.id if not a: - raise osv.except_osv('Error !', 'There is no expense account defined for this product: "%s" (id:%d)' % (ol.product_id.name, ol.product_id.id,)) + raise osv.except_osv(_('Error !'), _('There is no expense account defined for this product: "%s" (id:%d)') % (ol.product_id.name, ol.product_id.id,)) else: a = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category') il.append(self.inv_line_create(a,ol)) @@ -339,7 +340,7 @@ class purchase_order_line(osv.osv): def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom, partner_id, date_order=False): if not pricelist: - raise osv.except_osv('No Pricelist !', 'You have to select a pricelist in the purchase form !\n Please set one before choosing a product.') + raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist in the purchase form !\nPlease set one before choosing a product.')) if not product: return {'value': {'price_unit': 0.0, 'name':'','notes':''}, 'domain':{'product_uom':[]}} lang=False @@ -368,7 +369,7 @@ class purchase_order_line(osv.osv): res3 = self.pool.get('product.uom').read(cr, uid, [prod_uom_po], ['category_id']) domain = {'product_uom':[('category_id','=',res2[0]['category_id'][0])]} if res2[0]['category_id'] != res3[0]['category_id']: - raise osv.except_osv('Wrong Product UOM !', 'You have to select a product UOM in the same category than the purchase UOM of the product') + raise osv.except_osv(_('Wrong Product UOM !'), _('You have to select a product UOM in the same category than the purchase UOM of the product')) res['domain'] = domain return res diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 7aed9be9058..433c16e0a38 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -33,6 +33,7 @@ from osv import fields, osv import ir from mx import DateTime from tools import config +from tools.translate import _ class sale_shop(osv.osv): _name = "sale.shop" @@ -336,8 +337,8 @@ class sale_order(osv.osv): for pick in sale.picking_ids: if pick.state not in ('draft','cancel'): raise osv.except_osv( - 'Could not cancel sale order !', - 'You must first cancel all packings attached to this sale order.') + _('Could not cancel sale order !'), + _('You must first cancel all packings attached to this sale order.')) for r in self.read(cr,uid,ids,['picking_ids']): for pick in r['picking_ids']: wf_service = netsvc.LocalService("workflow") @@ -345,8 +346,8 @@ class sale_order(osv.osv): for inv in sale.invoice_ids: if inv.state not in ('draft','cancel'): raise osv.except_osv( - 'Could not cancel this sale order !', - 'You must first cancel all invoices attached to this sale order.') + _('Could not cancel this sale order !'), + _('You must first cancel all invoices attached to this sale order.')) for r in self.read(cr,uid,ids,['invoice_ids']): for inv in r['invoice_ids']: wf_service = netsvc.LocalService("workflow") @@ -386,7 +387,7 @@ class sale_order(osv.osv): # if mode == 'canceled': # returns True if there is at least one canceled line, False otherwise def test_state(self, cr, uid, ids, mode, *args): - assert mode in ('finished', 'canceled'), "invalid mode for test_state" + assert mode in ('finished', 'canceled'), _("invalid mode for test_state") finished = True canceled = False write_done_ids = [] @@ -648,9 +649,9 @@ class sale_order_line(osv.osv): if not a: a = line.product_id.categ_id.property_account_income_categ.id if not a: - raise osv.except_osv('Error !', - 'There is no income account defined ' \ - 'for this product: "%s" (id:%d)' % \ + raise osv.except_osv(_('Error !'), + _('There is no income account defined ' \ + 'for this product: "%s" (id:%d)') % \ (line.product_id.name, line.product_id.id,)) else: a = self.pool.get('ir.property').get(cr, uid, @@ -733,9 +734,9 @@ class sale_order_line(osv.osv): 'product_uos': []}} if not pricelist: - raise osv.except_osv('No Pricelist !', - 'You have to select a pricelist in the sale form !\n' - 'Please set one before choosing a product.') + raise osv.except_osv(_('No Pricelist !'), + _('You have to select a pricelist in the sale form !\n' + 'Please set one before choosing a product.')) if not date_order: date_order = time.strftime('%Y-%m-%d') @@ -745,9 +746,9 @@ class sale_order_line(osv.osv): 'date': date_order, })[pricelist] if price is False: - raise osv.except_osv('No valid pricelist line found !', - "Couldn't find a pricelist line matching this product and quantity.\n" - "You have to change either the product, the quantity or the pricelist.") + raise osv.except_osv(_('No valid pricelist line found !'), + _("Couldn't find a pricelist line matching this product and quantity.\n" + "You have to change either the product, the quantity or the pricelist.")) product = product_obj.browse(cr, uid, product, context=context) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index a6b1d706e0c..2cef57f04de 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -33,6 +33,7 @@ import netsvc from osv import fields,osv import ir from tools import config +from tools.translate import _ #---------------------------------------------------------- @@ -363,7 +364,7 @@ class stock_tracking(osv.osv): return res def unlink(self, cr ,uid, ids): - raise Exception, 'You can not remove a lot line !' + raise Exception, _('You can not remove a lot line !') stock_tracking() #---------------------------------------------------------- @@ -951,9 +952,9 @@ class stock_move(osv.osv): acc_src = move.product_id.categ_id.\ property_stock_account_input_categ.id if not acc_src: - raise osv.except_osv('Error!', - 'There is no stock input account defined ' \ - 'for this product: "%s" (id: %d)' % \ + raise osv.except_osv(_('Error!'), + _('There is no stock input account defined ' \ + 'for this product: "%s" (id: %d)') % \ (move.product_id.name, move.product_id.id,)) if not acc_dest: @@ -963,15 +964,15 @@ class stock_move(osv.osv): acc_dest = move.product_id.categ_id.\ property_stock_account_output_categ.id if not acc_dest: - raise osv.except_osv('Error!', - 'There is no stock output account defined ' \ - 'for this product: "%s" (id: %d)' % \ + raise osv.except_osv(_('Error!'), + _('There is no stock output account defined ' \ + 'for this product: "%s" (id: %d)') % \ (move.product_id.name, move.product_id.id,)) if not move.product_id.categ_id.property_stock_journal.id: - raise osv.except_osv('Error!', - 'There is no journal defined '\ - 'on the product category: "%s" (id: %d)' % \ + raise osv.except_osv(_('Error!'), + _('There is no journal defined '\ + 'on the product category: "%s" (id: %d)') % \ (move.product_id.categ_id.name, move.product_id.categ_id.id,)) journal_id = move.product_id.categ_id.property_stock_journal.id @@ -1018,8 +1019,8 @@ class stock_move(osv.osv): def unlink(self, cr, uid, ids, context=None): for move in self.browse(cr, uid, ids, context=context): if move.state != 'draft': - raise osv.except_osv('UserError', - 'You can only delete draft moves.') + raise osv.except_osv(_('UserError'), + _('You can only delete draft moves.')) return super(stock_move, self).unlink( cr, uid, ids, context=context) diff --git a/addons/stock/wizard/wizard_track_line.py b/addons/stock/wizard/wizard_track_line.py index eaaa538d52c..5b82dd45662 100644 --- a/addons/stock/wizard/wizard_track_line.py +++ b/addons/stock/wizard/wizard_track_line.py @@ -33,6 +33,7 @@ import pooler import time from osv import osv +from tools.translate import _ track_form = ''' @@ -65,7 +66,7 @@ def _track_lines(self, cr, uid, data, context): sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial') if not sequence: - raise wizard.except_wizard('Error!', 'No production sequence defined') + raise wizard.except_wizard(_('Error!'), _('No production sequence defined')) if data['form']['tracking_prefix']: sequence=data['form']['tracking_prefix']+'/'+(sequence or '') diff --git a/addons/subscription/subscription.py b/addons/subscription/subscription.py index c9f4507bded..7fe7c264d28 100644 --- a/addons/subscription/subscription.py +++ b/addons/subscription/subscription.py @@ -33,6 +33,7 @@ from mx import DateTime import time from osv import fields,osv +from tools.translate import _ class subscription_document(osv.osv): _name = "subscription.document" @@ -111,7 +112,7 @@ class subscription_subscription(osv.osv): id = int(id) model = self.pool.get(model_name) except: - raise osv.except_osv('Wrong Source Document !', 'Please provide another source document.\nThis one does not exist !') + raise osv.except_osv(_('Wrong Source Document !'), _('Please provide another source document.\nThis one does not exist !')) default = {'state':'draft'} doc_obj = self.pool.get('subscription.document')