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 = """