[IMP] error messages

fix errors ending with an exclamation point; use a point instead
remove uniques (or almost) error messages titles, like 'Encoding Error' (1 occurrence in addons), 'Integrity Error' (1 occurrence in addons), 'Report Name' (1 occurrence in addons), 'Value Error' (1 occurrence in addons), 'Wrong Period Code' (1 occurrence in addons); replace these with 'Error'
add newline character after some messages titles, when necessary
fix 'UserError': should be 'User Error'
remove spaces before exclamation marks
add capital letters to messages titles words (e.g.: 'Invalid action' becomes 'Invalid Action')

bzr revid: abo@openerp.com-20120807110616-u3nlnybtgaebro18
This commit is contained in:
Antonin Bourguignon 2012-08-07 13:06:16 +02:00
parent fe5956057a
commit b0e8ae4c7d
30 changed files with 231 additions and 231 deletions

View File

@ -404,7 +404,7 @@ class account_account(osv.osv):
journal_obj = self.pool.get('account.journal') journal_obj = self.pool.get('account.journal')
jids = journal_obj.search(cr, uid, [('type','=','situation'),('centralisation','=',1),('company_id','=',account.company_id.id)], context=context) jids = journal_obj.search(cr, uid, [('type','=','situation'),('centralisation','=',1),('company_id','=',account.company_id.id)], context=context)
if not jids: if not jids:
raise osv.except_osv(_('Error!'),_("You need an Opening journal with centralisation checked to set the initial balance!")) raise osv.except_osv(_('Error!'),_("You need an Opening journal with centralisation checked to set the initial balance."))
period_obj = self.pool.get('account.period') period_obj = self.pool.get('account.period')
pids = period_obj.search(cr, uid, [('special','=',True),('company_id','=',account.company_id.id)], context=context) pids = period_obj.search(cr, uid, [('special','=',True),('company_id','=',account.company_id.id)], context=context)
@ -426,7 +426,7 @@ class account_account(osv.osv):
}, context=context) }, context=context)
else: else:
if diff<0.0: if diff<0.0:
raise osv.except_osv(_('Error!'),_("Unable to adapt the initial balance (negative value)!")) raise osv.except_osv(_('Error!'),_("Unable to adapt the initial balance (negative value)."))
nameinv = (name=='credit' and 'debit') or 'credit' nameinv = (name=='credit' and 'debit') or 'credit'
move_id = move_obj.create(cr, uid, { move_id = move_obj.create(cr, uid, {
'name': _('Opening Balance'), 'name': _('Opening Balance'),
@ -541,9 +541,9 @@ class account_account(osv.osv):
return True return True
_constraints = [ _constraints = [
(_check_recursion, 'Error ! You cannot create recursive accounts.', ['parent_id']), (_check_recursion, 'Error!\nYou cannot create recursive accounts.', ['parent_id']),
(_check_type, 'Configuration Error! \nYou cannot define children to an account with internal type different of "View"! ', ['type']), (_check_type, 'Configuration Error!\nYou cannot define children to an account with internal type different of "View".', ['type']),
(_check_account_type, 'Configuration Error! \nYou cannot select an account type with a deferral method different of "Unreconciled" for accounts with internal type "Payable/Receivable"! ', ['user_type','type']), (_check_account_type, 'Configuration Error!\nYou cannot select an account type with a deferral method different of "Unreconciled" for accounts with internal type "Payable/Receivable".', ['user_type','type']),
] ]
_sql_constraints = [ _sql_constraints = [
('code_company_uniq', 'unique (code,company_id)', 'The code of the account must be unique per company !') ('code_company_uniq', 'unique (code,company_id)', 'The code of the account must be unique per company !')
@ -619,9 +619,9 @@ class account_account(osv.osv):
if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]): if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]):
if method == 'write': if method == 'write':
raise osv.except_osv(_('Error !'), _('You cannot deactivate an account that contains journal items.')) raise osv.except_osv(_('Error!'), _('You cannot deactivate an account that contains journal items.'))
elif method == 'unlink': elif method == 'unlink':
raise osv.except_osv(_('Error !'), _('You cannot remove an account that contains journal items.')) raise osv.except_osv(_('Error!'), _('You cannot remove an account that contains journal items.'))
#Checking whether the account is set as a property to any Partner or not #Checking whether the account is set as a property to any Partner or not
value = 'account.account,' + str(ids[0]) value = 'account.account,' + str(ids[0])
partner_prop_acc = self.pool.get('ir.property').search(cr, uid, [('value_reference','=',value)], context=context) partner_prop_acc = self.pool.get('ir.property').search(cr, uid, [('value_reference','=',value)], context=context)
@ -768,7 +768,7 @@ class account_journal(osv.osv):
return True return True
_constraints = [ _constraints = [
(_check_currency, 'Configuration error! The currency chosen should be shared by the default accounts too.', ['currency','default_debit_account_id','default_credit_account_id']), (_check_currency, 'Configuration error!\nThe currency chosen should be shared by the default accounts too.', ['currency','default_debit_account_id','default_credit_account_id']),
] ]
def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False): def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False):
@ -915,7 +915,7 @@ class account_fiscalyear(osv.osv):
return True return True
_constraints = [ _constraints = [
(_check_duration, 'Error! The start date of a fiscal year must precede its end date.', ['date_start','date_stop']) (_check_duration, 'Error!\nThe start date of a fiscal year must precede its end date.', ['date_start','date_stop'])
] ]
def create_period3(self, cr, uid, ids, context=None): def create_period3(self, cr, uid, ids, context=None):
@ -966,7 +966,7 @@ class account_fiscalyear(osv.osv):
ids = self.search(cr, uid, args, context=context) ids = self.search(cr, uid, args, context=context)
if not ids: if not ids:
if exception: if exception:
raise osv.except_osv(_('Error !'), _('There is no fiscal year defined for this date.\nPlease create one from the configuration of the accounting menu.')) raise osv.except_osv(_('Error!'), _('There is no fiscal year defined for this date.\nPlease create one from the configuration of the accounting menu.'))
else: else:
return [] return []
return ids return ids
@ -1032,8 +1032,8 @@ class account_period(osv.osv):
return True return True
_constraints = [ _constraints = [
(_check_duration, 'Error ! The duration of the Period(s) is/are invalid. ', ['date_stop']), (_check_duration, 'Error!\nThe duration of the Period(s) is/are invalid.', ['date_stop']),
(_check_year_limit, 'Error ! The period is invalid. Either some periods are overlapping or the period\'s dates are not matching the scope of the fiscal year.', ['date_stop']) (_check_year_limit, 'Error!\nThe period is invalid. Either some periods are overlapping or the period\'s dates are not matching the scope of the fiscal year.', ['date_stop'])
] ]
def next(self, cr, uid, period, step, context=None): def next(self, cr, uid, period, step, context=None):
@ -1055,7 +1055,7 @@ class account_period(osv.osv):
args.append(('company_id', '=', company_id)) args.append(('company_id', '=', company_id))
ids = self.search(cr, uid, args, context=context) ids = self.search(cr, uid, args, context=context)
if not ids: if not ids:
raise osv.except_osv(_('Error !'), _('There is no period defined for this date: %s.\nPlease create one.')%dt) raise osv.except_osv(_('Error!'), _('There is no period defined for this date: %s.\nPlease create one.')%dt)
return ids return ids
def action_draft(self, cr, uid, ids, *args): def action_draft(self, cr, uid, ids, *args):
@ -1134,7 +1134,7 @@ class account_journal_period(osv.osv):
cr.execute('select * from account_move_line where journal_id=%s and period_id=%s limit 1', (obj.journal_id.id, obj.period_id.id)) cr.execute('select * from account_move_line where journal_id=%s and period_id=%s limit 1', (obj.journal_id.id, obj.period_id.id))
res = cr.fetchall() res = cr.fetchall()
if res: if res:
raise osv.except_osv(_('Error !'), _('You cannot modify/delete a journal with entries for this period.')) raise osv.except_osv(_('Error!'), _('You cannot modify/delete a journal with entries for this period.'))
return True return True
def write(self, cr, uid, ids, vals, context=None): def write(self, cr, uid, ids, vals, context=None):
@ -1314,7 +1314,7 @@ class account_move(osv.osv):
valid_moves = self.validate(cr, uid, ids, context) valid_moves = self.validate(cr, uid, ids, context)
if not valid_moves: if not valid_moves:
raise osv.except_osv(_('Integrity Error !'), _('You cannot validate a non-balanced entry.\nMake sure you have configured payment terms properly.\nThe latest payment term line should be of the "Balance" type.')) raise osv.except_osv(_('Error!'), _('You cannot validate a non-balanced entry.\nMake sure you have configured payment terms properly.\nThe latest payment term line should be of the "Balance" type.'))
obj_sequence = self.pool.get('ir.sequence') obj_sequence = self.pool.get('ir.sequence')
for move in self.browse(cr, uid, valid_moves, context=context): for move in self.browse(cr, uid, valid_moves, context=context):
if move.name =='/': if move.name =='/':
@ -1328,7 +1328,7 @@ class account_move(osv.osv):
c = {'fiscalyear_id': move.period_id.fiscalyear_id.id} c = {'fiscalyear_id': move.period_id.fiscalyear_id.id}
new_name = obj_sequence.next_by_id(cr, uid, journal.sequence_id.id, c) new_name = obj_sequence.next_by_id(cr, uid, journal.sequence_id.id, c)
else: else:
raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal.')) raise osv.except_osv(_('Error!'), _('Please define a sequence on the journal.'))
if new_name: if new_name:
self.write(cr, uid, [move.id], {'name':new_name}) self.write(cr, uid, [move.id], {'name':new_name})
@ -1351,14 +1351,14 @@ class account_move(osv.osv):
if not top_common: if not top_common:
top_common = top_account top_common = top_account
elif top_account.id != top_common.id: elif top_account.id != top_common.id:
raise osv.except_osv(_('Error !'), raise osv.except_osv(_('Error!'),
_('You cannot validate this journal entry because account "%s" does not belong to chart of accounts "%s"!') % (account.name, top_common.name)) _('You cannot validate this journal entry because account "%s" does not belong to chart of accounts "%s".') % (account.name, top_common.name))
return self.post(cursor, user, ids, context=context) return self.post(cursor, user, ids, context=context)
def button_cancel(self, cr, uid, ids, context=None): def button_cancel(self, cr, uid, ids, context=None):
for line in self.browse(cr, uid, ids, context=context): for line in self.browse(cr, uid, ids, context=context):
if not line.journal_id.update_posted: if not line.journal_id.update_posted:
raise osv.except_osv(_('Error !'), _('You cannot modify a posted entry of this journal.\nFirst you should set the journal to allow cancelling entries.')) raise osv.except_osv(_('Error!'), _('You cannot modify a posted entry of this journal.\nFirst you should set the journal to allow cancelling entries.'))
if ids: if ids:
cr.execute('UPDATE account_move '\ cr.execute('UPDATE account_move '\
'SET state=%s '\ 'SET state=%s '\
@ -1445,7 +1445,7 @@ class account_move(osv.osv):
obj_move_line = self.pool.get('account.move.line') obj_move_line = self.pool.get('account.move.line')
for move in self.browse(cr, uid, ids, context=context): for move in self.browse(cr, uid, ids, context=context):
if move['state'] != 'draft': if move['state'] != 'draft':
raise osv.except_osv(_('UserError!'), raise osv.except_osv(_('User Error!'),
_('You cannot delete a posted journal entry "%s".') % \ _('You cannot delete a posted journal entry "%s".') % \
move['name']) move['name'])
line_ids = map(lambda x: x.id, move.line_id) line_ids = map(lambda x: x.id, move.line_id)
@ -1474,14 +1474,14 @@ class account_move(osv.osv):
account_id = move.journal_id.default_debit_account_id.id account_id = move.journal_id.default_debit_account_id.id
mode2 = 'debit' mode2 = 'debit'
if not account_id: if not account_id:
raise osv.except_osv(_('UserError'), raise osv.except_osv(_('User Error!'),
_('There is no default debit account defined \n' \ _('There is no default debit account defined \n' \
'on journal "%s".') % move.journal_id.name) 'on journal "%s".') % move.journal_id.name)
else: else:
account_id = move.journal_id.default_credit_account_id.id account_id = move.journal_id.default_credit_account_id.id
mode2 = 'credit' mode2 = 'credit'
if not account_id: if not account_id:
raise osv.except_osv(_('UserError'), raise osv.except_osv(_('User Error!'),
_('There is no default credit account defined \n' \ _('There is no default credit account defined \n' \
'on journal "%s".') % move.journal_id.name) 'on journal "%s".') % move.journal_id.name)
@ -1833,7 +1833,7 @@ class account_tax_code(osv.osv):
_check_recursion = check_cycle _check_recursion = check_cycle
_constraints = [ _constraints = [
(_check_recursion, 'Error ! You cannot create recursive accounts.', ['parent_id']) (_check_recursion, 'Error!\nYou cannot create recursive accounts.', ['parent_id'])
] ]
_order = 'code' _order = 'code'
@ -2307,7 +2307,7 @@ class account_model(osv.osv):
date_maturity = context.get('date',time.strftime('%Y-%m-%d')) date_maturity = context.get('date',time.strftime('%Y-%m-%d'))
if line.date_maturity == 'partner': if line.date_maturity == 'partner':
if not line.partner_id: if not line.partner_id:
raise osv.except_osv(_('Error !'), _("Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!" \ raise osv.except_osv(_('Error!'), _("Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!" \
"\nPlease define partner on it!")%(line.name, model.name)) "\nPlease define partner on it!")%(line.name, model.name))
if line.partner_id.property_payment_term: if line.partner_id.property_payment_term:
payment_term_id = line.partner_id.property_payment_term.id payment_term_id = line.partner_id.property_payment_term.id
@ -2521,8 +2521,8 @@ class account_account_template(osv.osv):
_check_recursion = check_cycle _check_recursion = check_cycle
_constraints = [ _constraints = [
(_check_recursion, 'Error ! You cannot create recursive account templates.', ['parent_id']), (_check_recursion, 'Error!\nYou cannot create recursive account templates.', ['parent_id']),
(_check_type, 'Configuration Error!\nYou cannot define children to an account that has internal type other than "View"!', ['type']), (_check_type, 'Configuration Error!\nYou cannot define children to an account that has internal type other than "View".', ['type']),
] ]
@ -2623,7 +2623,7 @@ class account_add_tmpl_wizard(osv.osv_memory):
ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]], ['code']) ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]], ['code'])
res = None res = None
if not ptids or not ptids[0]['code']: if not ptids or not ptids[0]['code']:
raise osv.except_osv(_('Error !'), _('There is no parent code for the template account.')) raise osv.except_osv(_('Error!'), _('There is no parent code for the template account.'))
res = acc_obj.search(cr, uid, [('code','=',ptids[0]['code'])]) res = acc_obj.search(cr, uid, [('code','=',ptids[0]['code'])])
return res and res[0] or False return res and res[0] or False
@ -2729,7 +2729,7 @@ class account_tax_code_template(osv.osv):
_check_recursion = check_cycle _check_recursion = check_cycle
_constraints = [ _constraints = [
(_check_recursion, 'Error ! You cannot create recursive Tax Codes.', ['parent_id']) (_check_recursion, 'Error!\nYou cannot create recursive Tax Codes.', ['parent_id'])
] ]
_order = 'code,name' _order = 'code,name'
account_tax_code_template() account_tax_code_template()
@ -3464,7 +3464,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
journal_data.append(vals) journal_data.append(vals)
ref_acc_bank = obj_wizard.chart_template_id.bank_account_view_id ref_acc_bank = obj_wizard.chart_template_id.bank_account_view_id
if journal_data and not ref_acc_bank.code: if journal_data and not ref_acc_bank.code:
raise osv.except_osv(_('Configuration Error !'), _('You have to set a code for the bank account defined on the selected chart of accounts.')) raise osv.except_osv(_('Configuration Error!'), _('You have to set a code for the bank account defined on the selected chart of accounts.'))
current_num = 1 current_num = 1
for line in journal_data: for line in journal_data:

View File

@ -192,11 +192,11 @@ class account_bank_statement(osv.osv):
'ref': st_line.ref, 'ref': st_line.ref,
} }
def _prepare_bank_move_line(self, cr, uid, st_line, move_id, amount, company_currency_id, def _prepare_bank_move_line(self, cr, uid, st_line, move_id, amount, company_currency_id,
context=None): context=None):
"""Compute the args to build the dict of values to create the bank move line from a """Compute the args to build the dict of values to create the bank move line from a
statement line by calling the _prepare_move_line_vals. This method may be statement line by calling the _prepare_move_line_vals. This method may be
overridden to implement custom move generation (making sure to call super() to overridden to implement custom move generation (making sure to call super() to
establish a clean extension chain). establish a clean extension chain).
:param browse_record st_line: account.bank.statement.line record to :param browse_record st_line: account.bank.statement.line record to
@ -219,12 +219,12 @@ class account_bank_statement(osv.osv):
res_currency_obj = self.pool.get('res.currency') res_currency_obj = self.pool.get('res.currency')
amt_cur = -res_currency_obj.compute(cr, uid, company_currency_id, cur_id, amount, context=context) amt_cur = -res_currency_obj.compute(cr, uid, company_currency_id, cur_id, amount, context=context)
res = self._prepare_move_line_vals(cr, uid, st_line, move_id, debit, credit, res = self._prepare_move_line_vals(cr, uid, st_line, move_id, debit, credit,
amount_currency=amt_cur, currency_id=cur_id, analytic_id=anl_id, context=context) amount_currency=amt_cur, currency_id=cur_id, analytic_id=anl_id, context=context)
return res return res
def _get_counter_part_account(sefl, cr, uid, st_line, context=None): def _get_counter_part_account(sefl, cr, uid, st_line, context=None):
"""Retrieve the account to use in the counterpart move. """Retrieve the account to use in the counterpart move.
This method may be overridden to implement custom move generation (making sure to This method may be overridden to implement custom move generation (making sure to
call super() to establish a clean extension chain). call super() to establish a clean extension chain).
@ -237,7 +237,7 @@ class account_bank_statement(osv.osv):
return st_line.statement_id.journal_id.default_debit_account_id.id return st_line.statement_id.journal_id.default_debit_account_id.id
def _get_counter_part_partner(sefl, cr, uid, st_line, context=None): def _get_counter_part_partner(sefl, cr, uid, st_line, context=None):
"""Retrieve the partner to use in the counterpart move. """Retrieve the partner to use in the counterpart move.
This method may be overridden to implement custom move generation (making sure to This method may be overridden to implement custom move generation (making sure to
call super() to establish a clean extension chain). call super() to establish a clean extension chain).
@ -247,11 +247,11 @@ class account_bank_statement(osv.osv):
""" """
return st_line.partner_id and st_line.partner_id.id or False return st_line.partner_id and st_line.partner_id.id or False
def _prepare_counterpart_move_line(self, cr, uid, st_line, move_id, amount, company_currency_id, def _prepare_counterpart_move_line(self, cr, uid, st_line, move_id, amount, company_currency_id,
context=None): context=None):
"""Compute the args to build the dict of values to create the counter part move line from a """Compute the args to build the dict of values to create the counter part move line from a
statement line by calling the _prepare_move_line_vals. This method may be statement line by calling the _prepare_move_line_vals. This method may be
overridden to implement custom move generation (making sure to call super() to overridden to implement custom move generation (making sure to call super() to
establish a clean extension chain). establish a clean extension chain).
:param browse_record st_line: account.bank.statement.line record to :param browse_record st_line: account.bank.statement.line record to
@ -271,12 +271,12 @@ class account_bank_statement(osv.osv):
if st_line.statement_id.currency.id <> company_currency_id: if st_line.statement_id.currency.id <> company_currency_id:
amt_cur = st_line.amount amt_cur = st_line.amount
cur_id = st_line.statement_id.currency.id cur_id = st_line.statement_id.currency.id
return self._prepare_move_line_vals(cr, uid, st_line, move_id, debit, credit, return self._prepare_move_line_vals(cr, uid, st_line, move_id, debit, credit,
amount_currency = amt_cur, currency_id = cur_id, account_id = account_id, amount_currency = amt_cur, currency_id = cur_id, account_id = account_id,
partner_id = partner_id, context=context) partner_id = partner_id, context=context)
def _prepare_move_line_vals(self, cr, uid, st_line, move_id, debit, credit, currency_id = False, def _prepare_move_line_vals(self, cr, uid, st_line, move_id, debit, credit, currency_id = False,
amount_currency= False, account_id = False, analytic_id = False, amount_currency= False, account_id = False, analytic_id = False,
partner_id = False, context=None): partner_id = False, context=None):
"""Prepare the dict of values to create the move line from a """Prepare the dict of values to create the move line from a
statement line. All non-mandatory args will replace the default computed one. statement line. All non-mandatory args will replace the default computed one.
@ -350,12 +350,12 @@ class account_bank_statement(osv.osv):
amount = res_currency_obj.compute(cr, uid, st.currency.id, amount = res_currency_obj.compute(cr, uid, st.currency.id,
company_currency_id, st_line.amount, context=context) company_currency_id, st_line.amount, context=context)
bank_move_vals = self._prepare_bank_move_line(cr, uid, st_line, move_id, amount, bank_move_vals = self._prepare_bank_move_line(cr, uid, st_line, move_id, amount,
company_currency_id, context=context) company_currency_id, context=context)
move_line_id = account_move_line_obj.create(cr, uid, bank_move_vals, context=context) move_line_id = account_move_line_obj.create(cr, uid, bank_move_vals, context=context)
torec.append(move_line_id) torec.append(move_line_id)
counterpart_move_vals = self._prepare_counterpart_move_line(cr, uid, st_line, move_id, counterpart_move_vals = self._prepare_counterpart_move_line(cr, uid, st_line, move_id,
amount, company_currency_id, context=context) amount, company_currency_id, context=context)
account_move_line_obj.create(cr, uid, counterpart_move_vals, context=context) account_move_line_obj.create(cr, uid, counterpart_move_vals, context=context)
@ -401,7 +401,7 @@ class account_bank_statement(osv.osv):
self.balance_check(cr, uid, st.id, journal_type=j_type, context=context) self.balance_check(cr, uid, st.id, journal_type=j_type, context=context)
if (not st.journal_id.default_credit_account_id) \ if (not st.journal_id.default_credit_account_id) \
or (not st.journal_id.default_debit_account_id): or (not st.journal_id.default_debit_account_id):
raise osv.except_osv(_('Configuration Error !'), raise osv.except_osv(_('Configuration Error!'),
_('Please verify that an account is defined in the journal.')) _('Please verify that an account is defined in the journal.'))
if not st.name == '/': if not st.name == '/':
@ -445,7 +445,7 @@ class account_bank_statement(osv.osv):
account_move_obj.unlink(cr, uid, ids, context) account_move_obj.unlink(cr, uid, ids, context)
done.append(st.id) done.append(st.id)
return self.write(cr, uid, done, {'state':'draft'}, context=context) return self.write(cr, uid, done, {'state':'draft'}, context=context)
def _compute_balance_end_real(self, cr, uid, journal_id, context=None): def _compute_balance_end_real(self, cr, uid, journal_id, context=None):
cr.execute('SELECT balance_end_real \ cr.execute('SELECT balance_end_real \
FROM account_bank_statement \ FROM account_bank_statement \
@ -469,7 +469,7 @@ class account_bank_statement(osv.osv):
if t['state'] in ('draft'): if t['state'] in ('draft'):
unlink_ids.append(t['id']) unlink_ids.append(t['id'])
else: else:
raise osv.except_osv(_('Invalid action !'), _('In order to delete a bank statement, you must first cancel it to delete related journal items.')) raise osv.except_osv(_('Invalid Action!'), _('In order to delete a bank statement, you must first cancel it to delete related journal items.'))
osv.osv.unlink(self, cr, uid, unlink_ids, context=context) osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
return True return True

View File

@ -425,7 +425,7 @@ class account_invoice(osv.osv):
if t['state'] in ('draft', 'cancel') and t['internal_number']== False: if t['state'] in ('draft', 'cancel') and t['internal_number']== False:
unlink_ids.append(t['id']) unlink_ids.append(t['id'])
else: else:
raise osv.except_osv(_('Invalid action !'), _('You cannot delete an invoice which is open or paid. You should refund it instead.')) raise osv.except_osv(_('Invalid Action!'), _('You cannot delete an invoice which is open or paid. You should refund it instead.'))
osv.osv.unlink(self, cr, uid, unlink_ids, context=context) osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
return True return True
@ -458,7 +458,7 @@ class account_invoice(osv.osv):
rec_res_id = rec_line_data and rec_line_data[0].get('value_reference',False) and int(rec_line_data[0]['value_reference'].split(',')[1]) or False rec_res_id = rec_line_data and rec_line_data[0].get('value_reference',False) and int(rec_line_data[0]['value_reference'].split(',')[1]) or False
pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False
if not rec_res_id and not pay_res_id: if not rec_res_id and not pay_res_id:
raise osv.except_osv(_('Configuration Error !'), raise osv.except_osv(_('Configuration Error!'),
_('Cannot find a chart of accounts for this company, you should create one.')) _('Cannot find a chart of accounts for this company, you should create one.'))
account_obj = self.pool.get('account.account') account_obj = self.pool.get('account.account')
rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id]) rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id])
@ -553,7 +553,7 @@ class account_invoice(osv.osv):
rec_res_id = rec_line_data and rec_line_data[0].get('value_reference',False) and int(rec_line_data[0]['value_reference'].split(',')[1]) or False rec_res_id = rec_line_data and rec_line_data[0].get('value_reference',False) and int(rec_line_data[0]['value_reference'].split(',')[1]) or False
pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False
if not rec_res_id and not pay_res_id: if not rec_res_id and not pay_res_id:
raise osv.except_osv(_('Configuration Error !'), raise osv.except_osv(_('Configuration Error!'),
_('Cannot find a chart of account, you should create one from Settings\Configuration\Accounting menu.')) _('Cannot find a chart of account, you should create one from Settings\Configuration\Accounting menu.'))
if type in ('out_invoice', 'out_refund'): if type in ('out_invoice', 'out_refund'):
acc_id = rec_res_id acc_id = rec_res_id
@ -568,7 +568,7 @@ class account_invoice(osv.osv):
if line.account_id.company_id.id != company_id: if line.account_id.company_id.id != company_id:
result_id = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) result_id = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)])
if not result_id: if not result_id:
raise osv.except_osv(_('Configuration Error !'), raise osv.except_osv(_('Configuration Error!'),
_('Cannot find a chart of account, you should create one from Settings\Configuration\Accounting menu.')) _('Cannot find a chart of account, you should create one from Settings\Configuration\Accounting menu.'))
inv_line_obj.write(cr, uid, [line.id], {'account_id': result_id[-1]}) inv_line_obj.write(cr, uid, [line.id], {'account_id': result_id[-1]})
else: else:
@ -576,7 +576,7 @@ class account_invoice(osv.osv):
for inv_line in invoice_line: for inv_line in invoice_line:
obj_l = account_obj.browse(cr, uid, inv_line[2]['account_id']) obj_l = account_obj.browse(cr, uid, inv_line[2]['account_id'])
if obj_l.company_id.id != company_id: if obj_l.company_id.id != company_id:
raise osv.except_osv(_('Configuration Error !'), raise osv.except_osv(_('Configuration Error!'),
_('Invoice line account\'s company and invoice\'s compnay does not match.')) _('Invoice line account\'s company and invoice\'s compnay does not match.'))
else: else:
continue continue
@ -598,7 +598,7 @@ class account_invoice(osv.osv):
if r[1] == 'journal_id' and r[2] in journal_ids: if r[1] == 'journal_id' and r[2] in journal_ids:
val['journal_id'] = r[2] val['journal_id'] = r[2]
if not val.get('journal_id', False): if not val.get('journal_id', False):
raise osv.except_osv(_('Configuration Error !'), (_('Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Journals\Journals.') % (journal_type))) raise osv.except_osv(_('Configuration Error!'), (_('Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Journals\Journals.') % (journal_type)))
dom = {'journal_id': [('id', 'in', journal_ids)]} dom = {'journal_id': [('id', 'in', journal_ids)]}
else: else:
journal_ids = obj_journal.search(cr, uid, []) journal_ids = obj_journal.search(cr, uid, [])
@ -947,7 +947,7 @@ class account_invoice(osv.osv):
journal_id = inv.journal_id.id journal_id = inv.journal_id.id
journal = journal_obj.browse(cr, uid, journal_id, context=ctx) journal = journal_obj.browse(cr, uid, journal_id, context=ctx)
if journal.centralisation: if journal.centralisation:
raise osv.except_osv(_('UserError'), raise osv.except_osv(_('User Error!'),
_('You cannot create an invoice on a centralized journal. Uncheck the centralized counterpart box in the related journal from the configuration menu.')) _('You cannot create an invoice on a centralized journal. Uncheck the centralized counterpart box in the related journal from the configuration menu.'))
line = self.finalize_invoice_move_lines(cr, uid, inv, line) line = self.finalize_invoice_move_lines(cr, uid, inv, line)

View File

@ -1090,7 +1090,7 @@ class account_move_line(osv.osv):
res = cr.fetchone() res = cr.fetchone()
if res: if res:
if res[1] != 'draft': if res[1] != 'draft':
raise osv.except_osv(_('UserError!'), raise osv.except_osv(_('User Error!'),
_('The account move (%s) for centralisation ' \ _('The account move (%s) for centralisation ' \
'has been confirmed.') % res[2]) 'has been confirmed.') % res[2])
return res return res
@ -1141,7 +1141,7 @@ class account_move_line(osv.osv):
if vals.get('account_tax_id', False): if vals.get('account_tax_id', False):
raise osv.except_osv(_('Unable to change tax!'), _('You cannot change the tax, you should remove and recreate lines.')) raise osv.except_osv(_('Unable to change tax!'), _('You cannot change the tax, you should remove and recreate lines.'))
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
raise osv.except_osv(_('Bad account!'), _('You cannot use an inactive account.')) raise osv.except_osv(_('Bad Account!'), _('You cannot use an inactive account.'))
if update_check: 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): 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) self._update_check(cr, uid, ids, context)
@ -1224,7 +1224,7 @@ class account_move_line(osv.osv):
if company_id: if company_id:
vals['company_id'] = company_id[0] vals['company_id'] = company_id[0]
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
raise osv.except_osv(_('Bad account!'), _('You cannot use an inactive account.')) raise osv.except_osv(_('Bad Account!'), _('You cannot use an inactive account.'))
if 'journal_id' in vals: if 'journal_id' in vals:
context['journal_id'] = vals['journal_id'] context['journal_id'] = vals['journal_id']
if 'period_id' in vals: if 'period_id' in vals:
@ -1237,7 +1237,7 @@ class account_move_line(osv.osv):
if 'period_id' not in context or not isinstance(context.get('period_id', ''), (int, long)): if 'period_id' not in context or not isinstance(context.get('period_id', ''), (int, long)):
period_candidate_ids = self.pool.get('account.period').name_search(cr, uid, name=context.get('period_id','')) period_candidate_ids = self.pool.get('account.period').name_search(cr, uid, name=context.get('period_id',''))
if len(period_candidate_ids) != 1: if len(period_candidate_ids) != 1:
raise osv.except_osv(_('Encoding error!'), _('No period found or more than one period found for the given date.')) raise osv.except_osv(_('Error!'), _('No period found or more than one period found for the given date.'))
context['period_id'] = period_candidate_ids[0][0] context['period_id'] = period_candidate_ids[0][0]
if not context.get('journal_id', False) and context.get('search_default_journal_id', False): if not context.get('journal_id', False) and context.get('search_default_journal_id', False):
context['journal_id'] = context.get('search_default_journal_id') context['journal_id'] = context.get('search_default_journal_id')
@ -1288,7 +1288,7 @@ class account_move_line(osv.osv):
vals['amount_currency'] = cur_obj.compute(cr, uid, account.company_id.currency_id.id, 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) account.currency_id.id, vals.get('debit', 0.0)-vals.get('credit', 0.0), context=ctx)
if not ok: if not ok:
raise osv.except_osv(_('Bad account !'), _('You cannot use this general account in this journal, check the tab \'Entry Controls\' on the related journal.')) raise osv.except_osv(_('Bad Account!'), _('You cannot use this general account in this journal, check the tab \'Entry Controls\' on the related journal.'))
if vals.get('analytic_account_id',False): if vals.get('analytic_account_id',False):
if journal.analytic_journal_id: if journal.analytic_journal_id:

View File

@ -70,4 +70,4 @@
try: try:
self.button_cancel(cr, uid, [ref("account_bank_statement_0")]) self.button_cancel(cr, uid, [ref("account_bank_statement_0")])
except Exception, e: except Exception, e:
assert e[0]=='UserError', 'Another exception has been raised!' assert e[0]=='User Error!', 'Another exception has been raised!'

View File

@ -145,7 +145,7 @@ class account_automatic_reconcile(osv.osv_memory):
allow_write_off = form.allow_write_off allow_write_off = form.allow_write_off
reconciled = unreconciled = 0 reconciled = unreconciled = 0
if not form.account_ids: if not form.account_ids:
raise osv.except_osv(_('UserError!'), _('You must select accounts to reconcile.')) raise osv.except_osv(_('User Error!'), _('You must select accounts to reconcile.'))
for account_id in form.account_ids: for account_id in form.account_ids:
params = (account_id.id,) params = (account_id.id,)
if not allow_write_off: if not allow_write_off:

View File

@ -85,7 +85,7 @@ class account_fiscalyear_close(osv.osv_memory):
fy2_period_set = ','.join(map(lambda id: str(id[0]), cr.fetchall())) fy2_period_set = ','.join(map(lambda id: str(id[0]), cr.fetchall()))
if not fy_period_set or not fy2_period_set: if not fy_period_set or not fy2_period_set:
raise osv.except_osv(_('UserError!'), _('The periods to generate opening entries cannot be found.')) raise osv.except_osv(_('User Error!'), _('The periods to generate opening entries cannot be found.'))
period = obj_acc_period.browse(cr, uid, data[0].period_id.id, context=context) period = obj_acc_period.browse(cr, uid, data[0].period_id.id, context=context)
new_fyear = obj_acc_fiscalyear.browse(cr, uid, data[0].fy2_id.id, context=context) new_fyear = obj_acc_fiscalyear.browse(cr, uid, data[0].fy2_id.id, context=context)
@ -96,10 +96,10 @@ class account_fiscalyear_close(osv.osv_memory):
company_id = new_journal.company_id.id company_id = new_journal.company_id.id
if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id: if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id:
raise osv.except_osv(_('UserError!'), raise osv.except_osv(_('User Error!'),
_('The journal must have default credit and debit account.')) _('The journal must have default credit and debit account.'))
if (not new_journal.centralisation) or new_journal.entry_posted: if (not new_journal.centralisation) or new_journal.entry_posted:
raise osv.except_osv(_('UserError!'), raise osv.except_osv(_('User Error!'),
_('The journal must have centralized counterpart without the Skipping draft state option checked.')) _('The journal must have centralized counterpart without the Skipping draft state option checked.'))
#delete existing move and move lines if any #delete existing move and move lines if any

View File

@ -60,7 +60,7 @@ class account_move_journal(osv.osv_memory):
if context.get('journal_type', False): if context.get('journal_type', False):
jids = journal_pool.search(cr, uid, [('type','=', context.get('journal_type'))]) jids = journal_pool.search(cr, uid, [('type','=', context.get('journal_type'))])
if not jids: if not jids:
raise osv.except_osv(_('Configuration Error !'), _('Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration/Journals/Journals.') % context.get('journal_type')) raise osv.except_osv(_('Configuration Error!'), _('Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration/Journals/Journals.') % context.get('journal_type'))
journal_id = jids[0] journal_id = jids[0]
return journal_id return journal_id
@ -158,7 +158,7 @@ class account_move_journal(osv.osv_memory):
state = period.state state = period.state
if state == 'done': if state == 'done':
raise osv.except_osv(_('UserError!'), _('This period is already closed.')) raise osv.except_osv(_('User Error!'), _('This period is already closed.'))
company = period.company_id.id company = period.company_id.id
res = { res = {

View File

@ -48,7 +48,7 @@ class account_period_close(osv.osv_memory):
for id in context['active_ids']: for id in context['active_ids']:
account_move_ids = account_move_obj.search(cr, uid, [('period_id', '=', id), ('state', '=', "draft")], context=context) account_move_ids = account_move_obj.search(cr, uid, [('period_id', '=', id), ('state', '=', "draft")], context=context)
if account_move_ids: if account_move_ids:
raise osv.except_osv(_('Invalid action !'), _('In order to close a period, you must first post related journal entries.')) raise osv.except_osv(_('Invalid Action!'), _('In order to close a period, you must first post related journal entries.'))
cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id))
cr.execute('update account_period set state=%s where id=%s', (mode, id)) cr.execute('update account_period set state=%s where id=%s', (mode, id))

View File

@ -53,9 +53,9 @@ class account_aged_trial_balance(osv.osv_memory):
period_length = data['form']['period_length'] period_length = data['form']['period_length']
if period_length<=0: if period_length<=0:
raise osv.except_osv(_('UserError!'), _('You must set a period length greater than 0.')) raise osv.except_osv(_('User Error!'), _('You must set a period length greater than 0.'))
if not data['form']['date_from']: if not data['form']['date_from']:
raise osv.except_osv(_('UserError!'), _('You must set a start date.')) raise osv.except_osv(_('User Error!'), _('You must set a start date.'))
start = datetime.strptime(data['form']['date_from'], "%Y-%m-%d") start = datetime.strptime(data['form']['date_from'], "%Y-%m-%d")

View File

@ -231,7 +231,7 @@ class account_analytic_plan_instance(osv.osv):
if acct_anal_acct.search(cr, uid, [('parent_id', 'child_of', [item.root_analytic_id.id]), ('id', '=', tempo[2]['analytic_account_id'])], context=context): if acct_anal_acct.search(cr, uid, [('parent_id', 'child_of', [item.root_analytic_id.id]), ('id', '=', tempo[2]['analytic_account_id'])], context=context):
total_per_plan += tempo[2]['rate'] total_per_plan += tempo[2]['rate']
if total_per_plan < item.min_required or total_per_plan > item.max_required: if total_per_plan < item.min_required or total_per_plan > item.max_required:
raise osv.except_osv(_('Value Error!'),_('The total should be between %s and %s.') % (str(item.min_required), str(item.max_required))) raise osv.except_osv(_('Error!'),_('The total should be between %s and %s.') % (str(item.min_required), str(item.max_required)))
return super(account_analytic_plan_instance, self).create(cr, uid, vals, context=context) return super(account_analytic_plan_instance, self).create(cr, uid, vals, context=context)

View File

@ -293,10 +293,10 @@ class coda_bank_statement(osv.osv):
# unlink CODA banks statements as well as associated bank statements and CODA files # unlink CODA banks statements as well as associated bank statements and CODA files
for coda_statement in self.browse(cr, uid, new_ids, context=context): for coda_statement in self.browse(cr, uid, new_ids, context=context):
if coda_statement.statement_id.state == 'confirm': if coda_statement.statement_id.state == 'confirm':
raise osv.except_osv(_('Invalid action !'), raise osv.except_osv(_('Invalid Action!'),
_("Cannot delete CODA Bank Statement '%s' of Journal '%s'." \ _("Cannot delete CODA Bank Statement '%s' of journal '%s'." \
"\nThe associated Bank Statement has already been confirmed !" \ "\nThe associated Bank Statement has already been confirmed." \
"\nPlease undo this action first!") \ "\nPlease undo this action first.") \
% (coda_statement.name, coda_statement.journal_id.name)) % (coda_statement.name, coda_statement.journal_id.name))
else: else:
if not context.get('coda_unlink', False): if not context.get('coda_unlink', False):

View File

@ -822,7 +822,7 @@ class account_voucher(osv.osv):
def unlink(self, cr, uid, ids, context=None): def unlink(self, cr, uid, ids, context=None):
for t in self.read(cr, uid, ids, ['state'], context=context): for t in self.read(cr, uid, ids, ['state'], context=context):
if t['state'] not in ('draft', 'cancel'): if t['state'] not in ('draft', 'cancel'):
raise osv.except_osv(_('Invalid Action !'), _('Cannot delete voucher(s) which are already opened or paid.')) raise osv.except_osv(_('Invalid Action!'), _('Cannot delete voucher(s) which are already opened or paid.'))
return super(account_voucher, self).unlink(cr, uid, ids, context=context) return super(account_voucher, self).unlink(cr, uid, ids, context=context)
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'): def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'):

View File

@ -92,7 +92,7 @@ class ModifyExistingReport(unohelper.Base, XJobExecutor):
ids = self.sock.execute(database, uid, self.password, 'ir.module.module', 'search', [('name','=','base_report_designer'),('state', '=', 'installed')]) ids = self.sock.execute(database, uid, self.password, 'ir.module.module', 'search', [('name','=','base_report_designer'),('state', '=', 'installed')])
if not len(ids): if not len(ids):
ErrorDialog("Please install base_report_designer module.", "", "Module Uninstalled Error !") ErrorDialog("Please install base_report_designer module.", "", "Module Uninstalled Error!")
exit(1) exit(1)
ids = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'search', [('report_xsl', '=', False),('report_xml', '=', False)]) ids = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'search', [('report_xsl', '=', False),('report_xml', '=', False)])

View File

@ -91,7 +91,7 @@ class SendtoServer(unohelper.Base, XJobExecutor):
self.ids = self.sock.execute(database, uid, self.password, 'ir.module.module', 'search', [('name','=','base_report_designer'),('state', '=', 'installed')]) self.ids = self.sock.execute(database, uid, self.password, 'ir.module.module', 'search', [('name','=','base_report_designer'),('state', '=', 'installed')])
if not len(self.ids): if not len(self.ids):
ErrorDialog("Please install base_report_designer module.", "", "Module Uninstalled Error !") ErrorDialog("Please install base_report_designer module.", "", "Module Uninstalled Error!")
exit(1) exit(1)
report_name = "" report_name = ""
@ -170,7 +170,7 @@ class SendtoServer(unohelper.Base, XJobExecutor):
} }
res = self.sock.execute(database, uid, self.password, 'ir.values' , 'create',rec ) res = self.sock.execute(database, uid, self.password, 'ir.values' , 'create',rec )
else : else :
ErrorDialog("This name is already used for another report.\nPlease try with another name.", "", "Report Name !") ErrorDialog("This name is already used for another report.\nPlease try with another name.", "", "Error!")
self.logobj.log_write('SendToServer',LOG_WARNING, ': report name already used DB %s' % (database)) self.logobj.log_write('SendToServer',LOG_WARNING, ': report name already used DB %s' % (database))
self.win.endExecute() self.win.endExecute()
except Exception,e: except Exception,e:
@ -203,8 +203,8 @@ class SendtoServer(unohelper.Base, XJobExecutor):
self.logobj.log_write('SendToServer',LOG_INFO, ':Report %s successfully send using %s'%(params['name'],database)) self.logobj.log_write('SendToServer',LOG_INFO, ':Report %s successfully send using %s'%(params['name'],database))
self.win.endExecute() self.win.endExecute()
else: else:
ErrorDialog("Either report name or technical name is blank.\nPlease specify an appropriate name.","","Blank Field Error !") ErrorDialog("Either report name or technical name is empty.\nPlease specify an appropriate name.", "", "Error!")
self.logobj.log_write('SendToServer',LOG_WARNING, ': either report name or technical name is blank.') self.logobj.log_write('SendToServer',LOG_WARNING, ': either report name or technical name is empty.')
self.win.endExecute() self.win.endExecute()
def getID(self): def getID(self):

View File

@ -133,7 +133,7 @@ class ServerParameter( unohelper.Base, XJobExecutor ):
# self.win.endExecute() # self.win.endExecute()
ids_module =self.sock.execute(sDatabase, UID, sPassword, 'ir.module.module', 'search', [('name','=','base_report_designer'),('state', '=', 'installed')]) ids_module =self.sock.execute(sDatabase, UID, sPassword, 'ir.module.module', 'search', [('name','=','base_report_designer'),('state', '=', 'installed')])
if not len(ids_module): if not len(ids_module):
ErrorDialog("Please install base_report_designer module.", "", "Module Uninstalled Error !") ErrorDialog("Please install base_report_designer module.", "", "Module Uninstalled Error!")
self.logobj.log_write('Module not found.',LOG_WARNING, ': base_report_designer not installed in database %s.' % (sDatabase)) self.logobj.log_write('Module not found.',LOG_WARNING, ': base_report_designer not installed in database %s.' % (sDatabase))
#self.win.endExecute() #self.win.endExecute()
else: else:

View File

@ -158,25 +158,25 @@ class hr_sign_in_out(osv.osv_memory):
emp_id = data['emp_id'] emp_id = data['emp_id']
if 'last_time' in data: if 'last_time' in data:
if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'): if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'):
raise osv.except_osv(_('UserError !'), _('The sign-out date must be in the past.')) raise osv.except_osv(_('User Error!'), _('The sign-out date must be in the past.'))
self.pool.get('hr.attendance').create(cr, uid, {'name': data['last_time'], 'action': 'sign_out', self.pool.get('hr.attendance').create(cr, uid, {'name': data['last_time'], 'action': 'sign_out',
'employee_id': emp_id}, context=context) 'employee_id': emp_id}, context=context)
try: try:
self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_in') self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_in')
except: except:
raise osv.except_osv(_('UserError !'), _('A sign-in must be right after a sign-out!')) raise osv.except_osv(_('User Error!'), _('A sign-in must be right after a sign-out!'))
return {'type': 'ir.actions.act_window_close'} # To do: Return Success message return {'type': 'ir.actions.act_window_close'} # To do: Return Success message
def sign_out(self, cr, uid, data, context=None): def sign_out(self, cr, uid, data, context=None):
emp_id = data['emp_id'] emp_id = data['emp_id']
if 'last_time' in data: if 'last_time' in data:
if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'): if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'):
raise osv.except_osv(_('UserError !'), _('The sign-in date must be in the past.')) raise osv.except_osv(_('User Error!'), _('The sign-in date must be in the past.'))
self.pool.get('hr.attendance').create(cr, uid, {'name':data['last_time'], 'action':'sign_in', 'employee_id':emp_id}, context=context) self.pool.get('hr.attendance').create(cr, uid, {'name':data['last_time'], 'action':'sign_in', 'employee_id':emp_id}, context=context)
try: try:
self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_out') self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_out')
except: except:
raise osv.except_osv(_('UserError !'), _('A sign-out must be right after a sign-in!')) raise osv.except_osv(_('User Error!'), _('A sign-out must be right after a sign-in.'))
return {'type': 'ir.actions.act_window_close'} # To do: Return Success message return {'type': 'ir.actions.act_window_close'} # To do: Return Success message
hr_sign_in_out() hr_sign_in_out()

View File

@ -74,7 +74,7 @@ class hr_so_project(osv.osv_memory):
res = timesheet_obj.default_get(cr, uid, ['product_id','product_uom_id'], context=context) res = timesheet_obj.default_get(cr, uid, ['product_id','product_uom_id'], context=context)
if not res['product_uom_id']: if not res['product_uom_id']:
raise osv.except_osv(_('UserError !'), _('Please define cost unit for this employee!')) raise osv.except_osv(_('User Error!'), _('Please define cost unit for this employee.'))
up = timesheet_obj.on_change_unit_amount(cr, uid, False, res['product_id'], hour,False, res['product_uom_id'])['value'] up = timesheet_obj.on_change_unit_amount(cr, uid, False, res['product_id'], hour,False, res['product_uom_id'])['value']
res['name'] = data['info'] res['name'] = data['info']
@ -129,7 +129,7 @@ class hr_si_project(osv.osv_memory):
emp_obj = self.pool.get('hr.employee') emp_obj = self.pool.get('hr.employee')
emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context) emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context)
if not emp_id: if not emp_id:
raise osv.except_osv(_('UserError !'), _('Please define employee for your user!')) raise osv.except_osv(_('User Error!'), _('Please define employee for your user.'))
return False return False
def check_state(self, cr, uid, ids, context=None): def check_state(self, cr, uid, ids, context=None):

View File

@ -103,7 +103,7 @@ class account_analytic_line(osv.osv):
if not product: if not product:
raise osv.except_osv(_('Error'), _('There is no product defined for the line %s. Please select one or force the product through the wizard.') % (line_name)) raise osv.except_osv(_('Error'), _('There is no product defined for the line %s. Please select one or force the product through the wizard.') % (line_name))
factor = invoice_factor_obj.browse(cr, uid, factor_id, context=context2) factor = invoice_factor_obj.browse(cr, uid, factor_id, context=context2)
factor_name = product_obj.name_get(cr, uid, [product_id], context=context2)[0][1] factor_name = product_obj.name_get(cr, uid, [product_id], context=context2)[0][1]
if factor.customer_name: if factor.customer_name:
factor_name += ' - ' + factor.customer_name factor_name += ' - ' + factor.customer_name
@ -119,7 +119,7 @@ class account_analytic_line(osv.osv):
tax = fiscal_pos_obj.map_tax(cr, uid, account.partner_id.property_account_position, taxes) tax = fiscal_pos_obj.map_tax(cr, uid, account.partner_id.property_account_position, taxes)
account_id = product.product_tmpl_id.property_account_income.id or product.categ_id.property_account_income_categ.id account_id = product.product_tmpl_id.property_account_income.id or product.categ_id.property_account_income_categ.id
if not account_id: if not account_id:
raise osv.except_osv(_("Configuration Error !"), _("Please define income account for product '%s'.") % product.name) raise osv.except_osv(_("Configuration Error!"), _("Please define income account for product '%s'.") % product.name)
curr_line = { curr_line = {
'price_unit': price, 'price_unit': price,
'quantity': qty, 'quantity': qty,

View File

@ -234,33 +234,33 @@ class hr_timesheet_sheet(osv.osv):
ids_signout = self.pool.get('hr.attendance').search(cr,uid,[('sheet_id', '=', sheet_id),('action','=','sign_out')]) ids_signout = self.pool.get('hr.attendance').search(cr,uid,[('sheet_id', '=', sheet_id),('action','=','sign_out')])
if len(ids_signin) != len(ids_signout): if len(ids_signin) != len(ids_signout):
raise osv.except_osv(('Warning !'),_('The timesheet cannot be validated as it does not contain an equal number of sign ins and sign outs!')) raise osv.except_osv(('Warning!'),_('The timesheet cannot be validated as it does not contain an equal number of sign ins and sign outs.'))
return True return True
def copy(self, cr, uid, ids, *args, **argv): def copy(self, cr, uid, ids, *args, **argv):
raise osv.except_osv(_('Error !'), _('You cannot duplicate a timesheet!')) raise osv.except_osv(_('Error!'), _('You cannot duplicate a timesheet.'))
def create(self, cr, uid, vals, *args, **argv): def create(self, cr, uid, vals, *args, **argv):
if 'employee_id' in vals: if 'employee_id' in vals:
if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).user_id: if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).user_id:
raise osv.except_osv(_('Error !'), _('In order to create a timesheet for this employee, you must assign it to a user!')) raise osv.except_osv(_('Error!'), _('In order to create a timesheet for this employee, you must assign it to a user.'))
if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).product_id: if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).product_id:
raise osv.except_osv(_('Error !'), _('In order to create a timesheet for this employee, you must link the employee to a product, like \'Consultant\'!')) raise osv.except_osv(_('Error!'), _('In order to create a timesheet for this employee, you must link the employee to a product, like \'Consultant\'.'))
if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).journal_id: if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).journal_id:
raise osv.except_osv(_('Error !'), _('In order to create a timesheet for this employee, you must assign the employee to an analytic journal, like \'Timesheet\'!')) raise osv.except_osv(_('Error!'), _('In order to create a timesheet for this employee, you must assign the employee to an analytic journal, like \'Timesheet\'.'))
return super(hr_timesheet_sheet, self).create(cr, uid, vals, *args, **argv) return super(hr_timesheet_sheet, self).create(cr, uid, vals, *args, **argv)
def write(self, cr, uid, ids, vals, *args, **argv): def write(self, cr, uid, ids, vals, *args, **argv):
if 'employee_id' in vals: if 'employee_id' in vals:
new_user_id = self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).user_id.id or False new_user_id = self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).user_id.id or False
if not new_user_id: if not new_user_id:
raise osv.except_osv(_('Error !'), _('In order to create a timesheet for this employee, you must assign it to a user!')) raise osv.except_osv(_('Error!'), _('In order to create a timesheet for this employee, you must assign it to a user.'))
if not self._sheet_date(cr, uid, ids, forced_user_id=new_user_id): if not self._sheet_date(cr, uid, ids, forced_user_id=new_user_id):
raise osv.except_osv(_('Error !'), _('You cannot have 2 timesheets that overlaps!\nYou should use the menu \'My Timesheet\' to avoid this problem.')) raise osv.except_osv(_('Error!'), _('You cannot have 2 timesheets that overlaps!\nYou should use the menu \'My Timesheet\' to avoid this problem.'))
if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).product_id: if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).product_id:
raise osv.except_osv(_('Error !'), _('In order to create a timesheet for this employee, you must link the employee to a product!')) raise osv.except_osv(_('Error!'), _('In order to create a timesheet for this employee, you must link the employee to a product.'))
if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).journal_id: if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).journal_id:
raise osv.except_osv(_('Error !'), _('In order to create a timesheet for this employee, you must assign the employee to an analytic journal!')) raise osv.except_osv(_('Error!'), _('In order to create a timesheet for this employee, you must assign the employee to an analytic journal.'))
return super(hr_timesheet_sheet, self).write(cr, uid, ids, vals, *args, **argv) return super(hr_timesheet_sheet, self).write(cr, uid, ids, vals, *args, **argv)
def button_confirm(self, cr, uid, ids, context=None): def button_confirm(self, cr, uid, ids, context=None):
@ -271,7 +271,7 @@ class hr_timesheet_sheet(osv.osv):
wf_service = netsvc.LocalService("workflow") wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'hr_timesheet_sheet.sheet', sheet.id, 'confirm', cr) wf_service.trg_validate(uid, 'hr_timesheet_sheet.sheet', sheet.id, 'confirm', cr)
else: 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 return True
def date_today(self, cr, uid, ids, context=None): def date_today(self, cr, uid, ids, context=None):
@ -315,7 +315,7 @@ class hr_timesheet_sheet(osv.osv):
def check_sign(self, cr, uid, ids, typ, context=None): def check_sign(self, cr, uid, ids, typ, context=None):
sheet = self.browse(cr, uid, ids, context=context)[0] sheet = self.browse(cr, uid, ids, context=context)[0]
if not sheet.date_current == time.strftime('%Y-%m-%d'): if not sheet.date_current == time.strftime('%Y-%m-%d'):
raise osv.except_osv(_('Error !'), _('You cannot sign in/sign out from other date than today.')) raise osv.except_osv(_('Error!'), _('You cannot sign in/sign out from other date than today.'))
return True return True
def sign(self, cr, uid, ids, typ, context=None): def sign(self, cr, uid, ids, typ, context=None):
@ -452,9 +452,9 @@ class hr_timesheet_sheet(osv.osv):
sheets = self.read(cr, uid, ids, ['state','total_attendance'], context=context) sheets = self.read(cr, uid, ids, ['state','total_attendance'], context=context)
for sheet in sheets: for sheet in sheets:
if sheet['state'] in ('confirm', 'done'): if sheet['state'] in ('confirm', 'done'):
raise osv.except_osv(_('Invalid action !'), _('You cannot delete a timesheet which is already confirmed!')) raise osv.except_osv(_('Invalid Action!'), _('You cannot delete a timesheet which is already confirmed.'))
elif sheet['total_attendance'] <> 0.00: elif sheet['total_attendance'] <> 0.00:
raise osv.except_osv(_('Invalid action !'), _('You cannot delete a timesheet which have attendance entries!')) raise osv.except_osv(_('Invalid Action!'), _('You cannot delete a timesheet which have attendance entries.'))
return super(hr_timesheet_sheet, self).unlink(cr, uid, ids, context=context) return super(hr_timesheet_sheet, self).unlink(cr, uid, ids, context=context)
def onchange_employee_id(self, cr, uid, ids, employee_id, context=None): def onchange_employee_id(self, cr, uid, ids, employee_id, context=None):
@ -545,7 +545,7 @@ class hr_timesheet_line(osv.osv):
def _check(self, cr, uid, ids): def _check(self, cr, uid, ids):
for att in self.browse(cr, uid, ids): for att in self.browse(cr, uid, ids):
if att.sheet_id and att.sheet_id.state not in ('draft', 'new'): if att.sheet_id and att.sheet_id.state not in ('draft', 'new'):
raise osv.except_osv(_('Error !'), _('You cannot modify an entry in a confirmed timesheet !')) raise osv.except_osv(_('Error!'), _('You cannot modify an entry in a confirmed timesheet.'))
return True return True
hr_timesheet_line() hr_timesheet_line()
@ -612,12 +612,12 @@ class hr_attendance(osv.osv):
if 'sheet_id' in context: if 'sheet_id' in context:
ts = self.pool.get('hr_timesheet_sheet.sheet').browse(cr, uid, context['sheet_id'], context=context) ts = self.pool.get('hr_timesheet_sheet.sheet').browse(cr, uid, context['sheet_id'], context=context)
if ts.state not in ('draft', 'new'): if ts.state not in ('draft', 'new'):
raise osv.except_osv(_('Error !'), _('You cannot modify an entry in a confirmed timesheet!')) raise osv.except_osv(_('Error!'), _('You cannot modify an entry in a confirmed timesheet.'))
res = super(hr_attendance,self).create(cr, uid, vals, context=context) res = super(hr_attendance,self).create(cr, uid, vals, context=context)
if 'sheet_id' in context: if 'sheet_id' in context:
if context['sheet_id'] != self.browse(cr, uid, res, context=context).sheet_id.id: if context['sheet_id'] != self.browse(cr, uid, res, context=context).sheet_id.id:
raise osv.except_osv(_('UserError !'), _('You cannot enter an attendance ' \ raise osv.except_osv(_('User Error!'), _('You cannot enter an attendance ' \
'date outside the current timesheet dates!')) 'date outside the current timesheet dates.'))
return res return res
def unlink(self, cr, uid, ids, *args, **kwargs): def unlink(self, cr, uid, ids, *args, **kwargs):
@ -636,14 +636,14 @@ class hr_attendance(osv.osv):
if 'sheet_id' in context: if 'sheet_id' in context:
for attendance in self.browse(cr, uid, ids, context=context): for attendance in self.browse(cr, uid, ids, context=context):
if context['sheet_id'] != attendance.sheet_id.id: if context['sheet_id'] != attendance.sheet_id.id:
raise osv.except_osv(_('UserError !'), _('You cannot enter an attendance ' \ raise osv.except_osv(_('User Error!'), _('You cannot enter an attendance ' \
'date outside the current timesheet dates!')) 'date outside the current timesheet dates.'))
return res return res
def _check(self, cr, uid, ids): def _check(self, cr, uid, ids):
for att in self.browse(cr, uid, ids): for att in self.browse(cr, uid, ids):
if att.sheet_id and att.sheet_id.state not in ('draft', 'new'): if att.sheet_id and att.sheet_id.state not in ('draft', 'new'):
raise osv.except_osv(_('Error !'), _('You cannot modify an entry in a confirmed timesheet!')) raise osv.except_osv(_('Error!'), _('You cannot modify an entry in a confirmed timesheet'))
return True return True
hr_attendance() hr_attendance()

View File

@ -31,7 +31,7 @@ from mako import exceptions
from report import report_sxw from report import report_sxw
from report_webkit import webkit_report from report_webkit import webkit_report
from report_webkit import report_helper from report_webkit import report_helper
from osv import osv from osv import osv
from osv.osv import except_osv from osv.osv import except_osv
@ -68,24 +68,24 @@ class l10n_ch_report_webkit_html(report_sxw.rml_parse):
_compile_comma_me = re.compile("^(-?\d+)(\d{3})") _compile_comma_me = re.compile("^(-?\d+)(\d{3})")
_compile_check_bvr = re.compile('[0-9][0-9]-[0-9]{3,6}-[0-9]') _compile_check_bvr = re.compile('[0-9][0-9]-[0-9]{3,6}-[0-9]')
_compile_check_bvr_add_num = re.compile('[0-9]*$') _compile_check_bvr_add_num = re.compile('[0-9]*$')
def set_context(self, objects, data, ids, report_type=None): def set_context(self, objects, data, ids, report_type=None):
user = self.pool.get('res.users').browse(self.cr, self.uid, self.uid) user = self.pool.get('res.users').browse(self.cr, self.uid, self.uid)
company = user.company_id company = user.company_id
if not company.invoice_only: if not company.invoice_only:
self._check(ids) self._check(ids)
return super(l10n_ch_report_webkit_html, self).set_context(objects, data, ids, report_type=report_type) return super(l10n_ch_report_webkit_html, self).set_context(objects, data, ids, report_type=report_type)
def police_absolute_path(self, inner_path) : def police_absolute_path(self, inner_path) :
"""Will get the ocrb police absolute path""" """Will get the ocrb police absolute path"""
path = addons.get_module_resource(os.path.join('l10n_ch', 'report', inner_path)) path = addons.get_module_resource(os.path.join('l10n_ch', 'report', inner_path))
return path return path
def bvr_absolute_path(self) : def bvr_absolute_path(self) :
"""Will get the ocrb police absolute path""" """Will get the ocrb police absolute path"""
path = addons.get_module_resource(os.path.join('l10n_ch', 'report', 'bvr1.jpg')) path = addons.get_module_resource(os.path.join('l10n_ch', 'report', 'bvr1.jpg'))
return path return path
def headheight(self): def headheight(self):
report_id = self.pool.get('ir.actions.report.xml').search(self.cr, self.uid, [('name','=', 'BVR invoice')])[0] report_id = self.pool.get('ir.actions.report.xml').search(self.cr, self.uid, [('name','=', 'BVR invoice')])[0]
report = self.pool.get('ir.actions.report.xml').browse(self.cr, self.uid, report_id) report = self.pool.get('ir.actions.report.xml').browse(self.cr, self.uid, report_id)
@ -112,8 +112,8 @@ class l10n_ch_report_webkit_html(report_sxw.rml_parse):
'12 34567 89012 345' '12 34567 89012 345'
""" """
return ''.join([' '[(i - 2) % nbrspc:] + c for i, c in enumerate(nbr)]) return ''.join([' '[(i - 2) % nbrspc:] + c for i, c in enumerate(nbr)])
def _get_ref(self, inv): def _get_ref(self, inv):
"""Retrieve ESR/BVR reference form invoice in order to print it""" """Retrieve ESR/BVR reference form invoice in order to print it"""
res = '' res = ''
@ -123,7 +123,7 @@ class l10n_ch_report_webkit_html(report_sxw.rml_parse):
if inv.number: if inv.number:
invoice_number = self._compile_get_ref.sub('', inv.number) invoice_number = self._compile_get_ref.sub('', inv.number)
return mod10r(res + invoice_number.rjust(26-len(res), '0')) return mod10r(res + invoice_number.rjust(26-len(res), '0'))
def _check(self, invoice_ids): def _check(self, invoice_ids):
"""Check if the invoice is ready to be printed""" """Check if the invoice is ready to be printed"""
if not invoice_ids: if not invoice_ids:
@ -135,24 +135,24 @@ class l10n_ch_report_webkit_html(report_sxw.rml_parse):
for invoice in invoice_obj.browse(cursor, self.uid, ids): for invoice in invoice_obj.browse(cursor, self.uid, ids):
invoice_name = "%s %s" %(invoice.name, invoice.number) invoice_name = "%s %s" %(invoice.name, invoice.number)
if not invoice.partner_bank_id: if not invoice.partner_bank_id:
raise except_osv(_('UserError'), raise except_osv(_('User Error!'),
_('No bank specified on invoice:\n%s' %(invoice_name))) _('No bank specified on invoice:\n%s.' %(invoice_name)))
if not self._compile_check_bvr.match( if not self._compile_check_bvr.match(
invoice.partner_bank_id.post_number or ''): invoice.partner_bank_id.post_number or ''):
raise except_osv(_('UserError'), raise except_osv(_('User Error!'),
_(('Your bank BVR number should be of the form 0X-XXX-X! ' _(('Your bank BVR number should be of the form 0X-XXX-X! '
'Please check your company ' 'Please check your company '
'information for the invoice:\n%s') 'information for the invoice:\n%s.')
%(invoice_name))) %(invoice_name)))
if invoice.partner_bank_id.bvr_adherent_num \ if invoice.partner_bank_id.bvr_adherent_num \
and not self._compile_check_bvr_add_num.match( and not self._compile_check_bvr_add_num.match(
invoice.partner_bank_id.bvr_adherent_num): invoice.partner_bank_id.bvr_adherent_num):
raise except_osv(_('UserError'), raise except_osv(_('User Error!'),
_(('Your bank BVR adherent number must contain only ' _(('Your bank BVR adherent number must contain only '
'digits!\nPlease check your company ' 'digits!\nPlease check your company '
'information for the invoice:\n%s') %(invoice_name))) 'information for the invoice:\n%s.') %(invoice_name)))
return '' return ''
def mako_template(text): def mako_template(text):
"""Build a Mako template. """Build a Mako template.
@ -162,15 +162,15 @@ def mako_template(text):
return Template(text, input_encoding='utf-8', output_encoding='utf-8', lookup=tmp_lookup) return Template(text, input_encoding='utf-8', output_encoding='utf-8', lookup=tmp_lookup)
class BVRWebKitParser(webkit_report.WebKitParser): class BVRWebKitParser(webkit_report.WebKitParser):
def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None):
"""generate the PDF""" """generate the PDF"""
context = context or {} context = context or {}
if report_xml.report_type != 'webkit': if report_xml.report_type != 'webkit':
return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context) return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
self.parser_instance = self.parser(cursor, self.parser_instance = self.parser(cursor,
uid, uid,
self.name2, self.name2,
context=context) context=context)
self.pool = pooler.get_pool(cursor.dbname) self.pool = pooler.get_pool(cursor.dbname)
objs = self.getObjects(cursor, uid, ids, context) objs = self.getObjects(cursor, uid, ids, context)
@ -183,12 +183,12 @@ class BVRWebKitParser(webkit_report.WebKitParser):
if not template and report_xml.report_webkit_data : if not template and report_xml.report_webkit_data :
template = report_xml.report_webkit_data template = report_xml.report_webkit_data
if not template : if not template :
raise except_osv(_('Error'),_('Webkit Report template not found !')) raise except_osv(_('Error!'),_('Webkit Report template not found.'))
header = report_xml.webkit_header.html header = report_xml.webkit_header.html
footer = report_xml.webkit_header.footer_html footer = report_xml.webkit_header.footer_html
if not header and report_xml.header: if not header and report_xml.header:
raise except_osv( raise except_osv(
_('No header defined for this Webkit report!'), _('No header defined for this Webkit report.'),
_('Please set a header in company settings.') _('Please set a header in company settings.')
) )
if not report_xml.header : if not report_xml.header :
@ -212,7 +212,7 @@ class BVRWebKitParser(webkit_report.WebKitParser):
self.parser_instance.localcontext['objects'] = [obj] self.parser_instance.localcontext['objects'] = [obj]
if not company.bvr_only: if not company.bvr_only:
try: try:
html = body_mako_tpl.render(helper=helper, html = body_mako_tpl.render(helper=helper,
css=css, css=css,
_=self.translate_call, _=self.translate_call,
**self.parser_instance.localcontext) **self.parser_instance.localcontext)
@ -221,16 +221,16 @@ class BVRWebKitParser(webkit_report.WebKitParser):
htmls.append(html) htmls.append(html)
if not company.invoice_only: if not company.invoice_only:
try: try:
bvr = body_bvr_tpl.render(helper=helper, bvr = body_bvr_tpl.render(helper=helper,
css=css, css=css,
_=self.translate_call, _=self.translate_call,
**self.parser_instance.localcontext) **self.parser_instance.localcontext)
except Exception, e: except Exception, e:
raise Exception(exceptions.text_error_template().render()) raise Exception(exceptions.text_error_template().render())
htmls.append(bvr) htmls.append(bvr)
head_mako_tpl = Template(header, input_encoding='utf-8', output_encoding='utf-8') head_mako_tpl = Template(header, input_encoding='utf-8', output_encoding='utf-8')
try: try:
head = head_mako_tpl.render(helper=helper, head = head_mako_tpl.render(helper=helper,
css=css, css=css,
_debug=False, _debug=False,
_=self.translate_call, _=self.translate_call,
@ -241,16 +241,16 @@ class BVRWebKitParser(webkit_report.WebKitParser):
if footer and company.invoice_only : if footer and company.invoice_only :
foot_mako_tpl = Template(footer, input_encoding='utf-8', output_encoding='utf-8') foot_mako_tpl = Template(footer, input_encoding='utf-8', output_encoding='utf-8')
try: try:
foot = foot_mako_tpl.render(helper=helper, foot = foot_mako_tpl.render(helper=helper,
css=css, css=css,
_=self.translate_call, _=self.translate_call,
**self.parser_instance.localcontext) **self.parser_instance.localcontext)
except Exception, e: except Exception, e:
raise Exception(exceptions.text_error_template().render()) raise Exception(exceptions.text_error_template().render())
if report_xml.webkit_debug : if report_xml.webkit_debug :
try: try:
deb = head_mako_tpl.render(helper=helper, deb = head_mako_tpl.render(helper=helper,
css=css, css=css,
_debug=html, _debug=html,
_=self.translate_call, _=self.translate_call,
**self.parser_instance.localcontext) **self.parser_instance.localcontext)
@ -260,10 +260,10 @@ class BVRWebKitParser(webkit_report.WebKitParser):
bin = self.get_lib(cursor, uid) bin = self.get_lib(cursor, uid)
pdf = self.generate_pdf(bin, report_xml, head, foot, htmls) pdf = self.generate_pdf(bin, report_xml, head, foot, htmls)
return (pdf, 'pdf') return (pdf, 'pdf')
BVRWebKitParser('report.invoice_web_bvr', BVRWebKitParser('report.invoice_web_bvr',
'account.invoice', 'account.invoice',
'addons/l10n_ch/report/report_webkit_html.mako', 'addons/l10n_ch/report/report_webkit_html.mako',
parser=l10n_ch_report_webkit_html) parser=l10n_ch_report_webkit_html)

View File

@ -71,9 +71,9 @@ def _import(self, cursor, user, data, context=None):
statement_obj = self.pool.get('account.bank.statement') statement_obj = self.pool.get('account.bank.statement')
property_obj = self.pool.get('ir.property') property_obj = self.pool.get('ir.property')
file = data['form']['file'] file = data['form']['file']
if not file: if not file:
raise osv.except_osv(_('UserError'), raise osv.except_osv(_('User Error!'),
_('Please select a file first!')) _('Please select a file first.'))
statement_id = data['id'] statement_id = data['id']
records = [] records = []
total_amount = 0 total_amount = 0
@ -90,12 +90,12 @@ def _import(self, cursor, user, data, context=None):
if line[0:3] in ('999', '995'): if line[0:3] in ('999', '995'):
if find_total: if find_total:
raise osv.except_osv(_('Error'), raise osv.except_osv(_('Error!'),
_('Too much total record found!')) _('Too much total record found.'))
find_total = True find_total = True
if lines: if lines:
raise osv.except_osv(_('Error'), raise osv.except_osv(_('Error!'),
_('Record found after total record!')) _('Record found after total record.'))
amount = float(line[39:49]) + (float(line[49:51]) / 100) amount = float(line[39:49]) + (float(line[49:51]) / 100)
cost = float(line[69:76]) + (float(line[76:78]) / 100) cost = float(line[69:76]) + (float(line[76:78]) / 100)
if line[2] == '5': if line[2] == '5':
@ -104,11 +104,11 @@ def _import(self, cursor, user, data, context=None):
if round(amount - total_amount, 2) >= 0.01 \ if round(amount - total_amount, 2) >= 0.01 \
or round(cost - total_cost, 2) >= 0.01: or round(cost - total_cost, 2) >= 0.01:
raise osv.except_osv(_('Error'), raise osv.except_osv(_('Error!'),
_('Total record different from the computed!')) _('Total record different from the computed.'))
if int(line[51:63]) != len(records): if int(line[51:63]) != len(records):
raise osv.except_osv(_('Error'), raise osv.except_osv(_('Error!'),
_('Number record different from the computed!')) _('Number record different from the computed.'))
else: else:
record = { record = {
'reference': line[12:39], 'reference': line[12:39],
@ -119,8 +119,8 @@ def _import(self, cursor, user, data, context=None):
} }
if record['reference'] != mod10r(record['reference'][:-1]): if record['reference'] != mod10r(record['reference'][:-1]):
raise osv.except_osv(_('Error'), raise osv.except_osv(_('Error!'),
_('Recursive mod10 is invalid for reference: %s') % \ _('Recursive mod10 is invalid for reference: %s.') % \
record['reference']) record['reference'])
if line[2] == '5': if line[2] == '5':
@ -221,10 +221,10 @@ def _import(self, cursor, user, data, context=None):
if value : if value :
account_id = int(value.split(',')[1]) account_id = int(value.split(',')[1])
else : else :
raise osv.except_osv(_('Error'), raise osv.except_osv(_('Error!'),
_('The properties account payable and account receivable are not set.')) _('The properties account payable and account receivable are not set.'))
if not account_id and line_ids: if not account_id and line_ids:
raise osv.except_osv(_('Error'), raise osv.except_osv(_('Error!'),
_('The properties account payable and account receivable are not set.')) _('The properties account payable and account receivable are not set.'))
values['account_id'] = account_id values['account_id'] = account_id
values['partner_id'] = partner_id values['partner_id'] = partner_id

View File

@ -451,10 +451,10 @@ class mrp_production(osv.osv):
def _src_id_default(self, cr, uid, ids, context=None): def _src_id_default(self, cr, uid, ids, context=None):
src_location_id = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context) src_location_id = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context)
return src_location_id.id return src_location_id.id
def _dest_id_default(self, cr, uid, ids, context=None): def _dest_id_default(self, cr, uid, ids, context=None):
dest_location_id = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context) dest_location_id = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context)
return dest_location_id.id return dest_location_id.id
_columns = { _columns = {
'name': fields.char('Reference', size=64, required=True), 'name': fields.char('Reference', size=64, required=True),
@ -530,7 +530,7 @@ class mrp_production(osv.osv):
def unlink(self, cr, uid, ids, context=None): def unlink(self, cr, uid, ids, context=None):
for production in self.browse(cr, uid, ids, context=context): for production in self.browse(cr, uid, ids, context=context):
if production.state not in ('draft', 'cancel'): if production.state not in ('draft', 'cancel'):
raise osv.except_osv(_('Invalid action !'), _('Cannot delete a manufacturing order in state \'%s\'.') % production.state) raise osv.except_osv(_('Invalid Action!'), _('Cannot delete a manufacturing order in state \'%s\'.') % production.state)
return super(mrp_production, self).unlink(cr, uid, ids, context=context) return super(mrp_production, self).unlink(cr, uid, ids, context=context)
def copy(self, cr, uid, id, default=None, context=None): def copy(self, cr, uid, id, default=None, context=None):
@ -1041,7 +1041,7 @@ class mrp_production(osv.osv):
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)]) pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])
return True return True
# --------------------------------------------------- # ---------------------------------------------------
# OpenChatter methods and notifications # OpenChatter methods and notifications
# --------------------------------------------------- # ---------------------------------------------------

View File

@ -135,8 +135,8 @@ class procurement_order(osv.osv):
if s['state'] in ['draft','cancel']: if s['state'] in ['draft','cancel']:
unlink_ids.append(s['id']) unlink_ids.append(s['id'])
else: else:
raise osv.except_osv(_('Invalid action !'), raise osv.except_osv(_('Invalid Action!'),
_('Cannot delete Procurement Order(s) which are in %s state!') % \ _('Cannot delete Procurement Order(s) which are in %s state.') % \
s['state']) s['state'])
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context) return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
@ -328,7 +328,7 @@ class procurement_order(osv.osv):
for procurement in self.browse(cr, uid, ids, context=context): for procurement in self.browse(cr, uid, ids, context=context):
if procurement.product_qty <= 0.00: if procurement.product_qty <= 0.00:
raise osv.except_osv(_('Insufficient Data!'), raise osv.except_osv(_('Insufficient Data!'),
_('Please check the quantity in procurement order(s), it should not be 0 or less.')) _('Quantity in procurement order(s) must be greater than 0.'))
if procurement.product_id.type in ('product', 'consu'): if procurement.product_id.type in ('product', 'consu'):
if not procurement.move_id: if not procurement.move_id:
source = procurement.location_id.id source = procurement.location_id.id

View File

@ -116,7 +116,7 @@ class project_work(osv.osv):
vals_line['product_id'] = result['product_id'] vals_line['product_id'] = result['product_id']
vals_line['date'] = vals['date'][:10] vals_line['date'] = vals['date'][:10]
#calculate quantity based on employee's product's uom #calculate quantity based on employee's product's uom
vals_line['unit_amount'] = vals['hours'] vals_line['unit_amount'] = vals['hours']
default_uom = self.pool.get('res.users').browse(cr, uid, uid).company_id.project_time_mode_id.id default_uom = self.pool.get('res.users').browse(cr, uid, uid).company_id.project_time_mode_id.id
@ -254,7 +254,7 @@ class res_partner(osv.osv):
def unlink(self, cursor, user, ids, context=None): def unlink(self, cursor, user, ids, context=None):
parnter_id=self.pool.get('project.project').search(cursor, user, [('partner_id', 'in', ids)]) parnter_id=self.pool.get('project.project').search(cursor, user, [('partner_id', 'in', ids)])
if parnter_id: if parnter_id:
raise osv.except_osv(_('Invalid action !'), _('You cannot delete a partner which is assigned to project, we suggest you to uncheck the active box!')) raise osv.except_osv(_('Invalid Action!'), _('You cannot delete a partner which is assigned to project, but you can uncheck the active box.'))
return super(res_partner,self).unlink(cursor, user, ids, return super(res_partner,self).unlink(cursor, user, ids,
context=context) context=context)
res_partner() res_partner()
@ -271,6 +271,6 @@ class account_analytic_line(osv.osv):
res['value']['to_invoice'] = st or False res['value']['to_invoice'] = st or False
if acc.state == 'close' or acc.state == 'cancelled': if acc.state == 'close' or acc.state == 'cancelled':
raise osv.except_osv(_('Invalid Analytic Account !'), _('You cannot select a Analytic Account which is in Close or Cancelled state.')) raise osv.except_osv(_('Invalid Analytic Account !'), _('You cannot select a Analytic Account which is in Close or Cancelled state.'))
return res return res
account_analytic_line() account_analytic_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -224,13 +224,13 @@ class purchase_order(osv.osv):
_inherit = ['ir.needaction_mixin', 'mail.thread'] _inherit = ['ir.needaction_mixin', 'mail.thread']
_description = "Purchase Order" _description = "Purchase Order"
_order = "name desc" _order = "name desc"
def create(self, cr, uid, vals, context=None): def create(self, cr, uid, vals, context=None):
order = super(purchase_order, self).create(cr, uid, vals, context=context) order = super(purchase_order, self).create(cr, uid, vals, context=context)
if order: if order:
self.create_send_note(cr, uid, [order], context=context) self.create_send_note(cr, uid, [order], context=context)
return order return order
def unlink(self, cr, uid, ids, context=None): def unlink(self, cr, uid, ids, context=None):
purchase_orders = self.read(cr, uid, ids, ['state'], context=context) purchase_orders = self.read(cr, uid, ids, ['state'], context=context)
unlink_ids = [] unlink_ids = []
@ -238,7 +238,7 @@ class purchase_order(osv.osv):
if s['state'] in ['draft','cancel']: if s['state'] in ['draft','cancel']:
unlink_ids.append(s['id']) unlink_ids.append(s['id'])
else: else:
raise osv.except_osv(_('Invalid action !'), _('In order to delete a purchase order, You must cancel it first.')) raise osv.except_osv(_('Invalid Action!'), _('In order to delete a purchase order, you must cancel it first.'))
# TODO: temporary fix in 5.0, to remove in 5.2 when subflows support # TODO: temporary fix in 5.0, to remove in 5.2 when subflows support
# automatically sending subflow.delete upon deletion # automatically sending subflow.delete upon deletion
@ -291,7 +291,7 @@ class purchase_order(osv.osv):
if not po.invoice_ids: if not po.invoice_ids:
context.update({'active_ids' : [line.id for line in po.order_line]}) context.update({'active_ids' : [line.id for line in po.order_line]})
wizard_obj.makeInvoices(cr, uid, [], context=context) wizard_obj.makeInvoices(cr, uid, [], context=context)
for po in self.browse(cr, uid, ids, context=context): for po in self.browse(cr, uid, ids, context=context):
inv_ids+= [invoice.id for invoice in po.invoice_ids] inv_ids+= [invoice.id for invoice in po.invoice_ids]
res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_supplier_form') res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_supplier_form')
@ -476,12 +476,12 @@ class purchase_order(osv.osv):
if res: if res:
self.invoice_send_note(cr, uid, ids, res, context) self.invoice_send_note(cr, uid, ids, res, context)
return res return res
def invoice_done(self, cr, uid, ids, context=None): def invoice_done(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state':'approved'}, context=context) self.write(cr, uid, ids, {'state':'approved'}, context=context)
self.invoice_done_send_note(cr, uid, ids, context=context) self.invoice_done_send_note(cr, uid, ids, context=context)
return True return True
def has_stockable_product(self,cr, uid, ids, *args): def has_stockable_product(self,cr, uid, ids, *args):
for order in self.browse(cr, uid, ids): for order in self.browse(cr, uid, ids):
for order_line in order.order_line: for order_line in order.order_line:
@ -727,18 +727,18 @@ class purchase_order(osv.osv):
wf_service.trg_redirect(uid, 'purchase.order', old_id, neworder_id, cr) wf_service.trg_redirect(uid, 'purchase.order', old_id, neworder_id, cr)
wf_service.trg_validate(uid, 'purchase.order', old_id, 'purchase_cancel', cr) wf_service.trg_validate(uid, 'purchase.order', old_id, 'purchase_cancel', cr)
return orders_info return orders_info
# -------------------------------------- # --------------------------------------
# OpenChatter methods and notifications # OpenChatter methods and notifications
# -------------------------------------- # --------------------------------------
def get_needaction_user_ids(self, cr, uid, ids, context=None): def get_needaction_user_ids(self, cr, uid, ids, context=None):
result = super(purchase_order, self).get_needaction_user_ids(cr, uid, ids, context=context) result = super(purchase_order, self).get_needaction_user_ids(cr, uid, ids, context=context)
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
if obj.state == 'approved': if obj.state == 'approved':
result[obj.id].append(obj.validator.id) result[obj.id].append(obj.validator.id)
return result return result
def create_send_note(self, cr, uid, ids, context=None): def create_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Request for quotation <b>created</b>."), context=context) return self.message_append_note(cr, uid, ids, body=_("Request for quotation <b>created</b>."), context=context)
@ -746,7 +746,7 @@ class purchase_order(osv.osv):
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
self.message_subscribe(cr, uid, [obj.id], [obj.validator.id], context=context) self.message_subscribe(cr, uid, [obj.id], [obj.validator.id], context=context)
self.message_append_note(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> <b>converted</b> to a Purchase Order of %s %s.") % (obj.partner_id.name, obj.amount_total, obj.pricelist_id.currency_id.symbol), context=context) self.message_append_note(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> <b>converted</b> to a Purchase Order of %s %s.") % (obj.partner_id.name, obj.amount_total, obj.pricelist_id.currency_id.symbol), context=context)
def shipment_send_note(self, cr, uid, ids, picking_id, context=None): def shipment_send_note(self, cr, uid, ids, picking_id, context=None):
for order in self.browse(cr, uid, ids, context=context): for order in self.browse(cr, uid, ids, context=context):
for picking in (pck for pck in order.picking_ids if pck.id == picking_id): for picking in (pck for pck in order.picking_ids if pck.id == picking_id):
@ -755,21 +755,21 @@ class purchase_order(osv.osv):
picking_datetime = fields.DT.datetime.strptime(picking.min_date, DEFAULT_SERVER_DATETIME_FORMAT) picking_datetime = fields.DT.datetime.strptime(picking.min_date, DEFAULT_SERVER_DATETIME_FORMAT)
picking_date_str = fields.datetime.context_timestamp(cr, uid, picking_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)") picking_date_str = fields.datetime.context_timestamp(cr, uid, picking_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
self.message_append_note(cr, uid, [order.id], body=_("Shipment <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context) self.message_append_note(cr, uid, [order.id], body=_("Shipment <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context)
def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None):
for order in self.browse(cr, uid, ids, context=context): for order in self.browse(cr, uid, ids, context=context):
for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id):
self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s is <b>waiting for validation</b>.") % (invoice.amount_total, invoice.currency_id.symbol), context=context) self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s is <b>waiting for validation</b>.") % (invoice.amount_total, invoice.currency_id.symbol), context=context)
def shipment_done_send_note(self, cr, uid, ids, context=None): def shipment_done_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("""Shipment <b>received</b>."""), context=context) self.message_append_note(cr, uid, ids, body=_("""Shipment <b>received</b>."""), context=context)
def invoice_done_send_note(self, cr, uid, ids, context=None): def invoice_done_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Invoice <b>paid</b>."), context=context) self.message_append_note(cr, uid, ids, body=_("Invoice <b>paid</b>."), context=context)
def draft_send_note(self, cr, uid, ids, context=None): def draft_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Purchase Order has been set to <b>draft</b>."), context=context) return self.message_append_note(cr, uid, ids, body=_("Purchase Order has been set to <b>draft</b>."), context=context)
def cancel_send_note(self, cr, uid, ids, context=None): def cancel_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Purchase Order for <em>%s</em> <b>cancelled</b>.") % (obj.partner_id.name), context=context) self.message_append_note(cr, uid, [obj.id], body=_("Purchase Order for <em>%s</em> <b>cancelled</b>.") % (obj.partner_id.name), context=context)
@ -1086,7 +1086,7 @@ procurement_order()
class mail_message(osv.osv): class mail_message(osv.osv):
_name = 'mail.message' _name = 'mail.message'
_inherit = 'mail.message' _inherit = 'mail.message'
def _postprocess_sent_message(self, cr, uid, message, context=None): def _postprocess_sent_message(self, cr, uid, message, context=None):
if message.model == 'purchase.order': if message.model == 'purchase.order':
wf_service = netsvc.LocalService("workflow") wf_service = netsvc.LocalService("workflow")

View File

@ -50,7 +50,7 @@ class sale_order(osv.osv):
_name = "sale.order" _name = "sale.order"
_inherit = ['ir.needaction_mixin', 'mail.thread'] _inherit = ['ir.needaction_mixin', 'mail.thread']
_description = "Sales Order" _description = "Sales Order"
def copy(self, cr, uid, id, default=None, context=None): def copy(self, cr, uid, id, default=None, context=None):
if not default: if not default:
@ -295,7 +295,7 @@ class sale_order(osv.osv):
if s['state'] in ['draft', 'cancel']: if s['state'] in ['draft', 'cancel']:
unlink_ids.append(s['id']) unlink_ids.append(s['id'])
else: else:
raise osv.except_osv(_('Invalid action !'), _('In order to delete a confirmed sales order, you must cancel it! To cancel a sale order, you must first cancel related picking for delivery orders.')) raise osv.except_osv(_('Invalid Action!'), _('In order to delete a confirmed sales order, you must cancel it.\nTo do so, you must first cancel related picking for delivery orders.'))
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context) return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
@ -481,7 +481,7 @@ class sale_order(osv.osv):
'form': self.read(cr, uid, ids[0], context=context), 'form': self.read(cr, uid, ids[0], context=context),
} }
return {'type': 'ir.actions.report.xml', 'report_name': 'sale.order', 'datas': datas, 'nodestroy': True} return {'type': 'ir.actions.report.xml', 'report_name': 'sale.order', 'datas': datas, 'nodestroy': True}
def manual_invoice(self, cr, uid, ids, context=None): def manual_invoice(self, cr, uid, ids, context=None):
""" create invoices for the given sale orders (ids), and open the form """ create invoices for the given sale orders (ids), and open the form
view of one of the newly created invoices view of one of the newly created invoices
@ -547,7 +547,7 @@ class sale_order(osv.osv):
result.update(view_id = res and res[1] or False) result.update(view_id = res and res[1] or False)
return result return result
def action_view_delivery(self, cr, uid, ids, context=None): def action_view_delivery(self, cr, uid, ids, context=None):
''' '''
This function returns an action that display existing delivery orders of given sale order ids. It can either be a in a list or in a form view, if there is only one delivery order to show. This function returns an action that display existing delivery orders of given sale order ids. It can either be a in a list or in a form view, if there is only one delivery order to show.
@ -1021,27 +1021,27 @@ class sale_order(osv.osv):
# ------------------------------------------------ # ------------------------------------------------
# OpenChatter methods and notifications # OpenChatter methods and notifications
# ------------------------------------------------ # ------------------------------------------------
def get_needaction_user_ids(self, cr, uid, ids, context=None): def get_needaction_user_ids(self, cr, uid, ids, context=None):
result = super(sale_order, self).get_needaction_user_ids(cr, uid, ids, context=context) result = super(sale_order, self).get_needaction_user_ids(cr, uid, ids, context=context)
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
if (obj.state == 'manual' or obj.state == 'progress'): if (obj.state == 'manual' or obj.state == 'progress'):
result[obj.id].append(obj.user_id.id) result[obj.id].append(obj.user_id.id)
return result return result
def create_send_note(self, cr, uid, ids, context=None): def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
self.message_subscribe(cr, uid, [obj.id], [obj.user_id.id], context=context) self.message_subscribe(cr, uid, [obj.id], [obj.user_id.id], context=context)
self.message_append_note(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> has been <b>created</b>.") % (obj.partner_id.name), context=context) self.message_append_note(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> has been <b>created</b>.") % (obj.partner_id.name), context=context)
def confirm_send_note(self, cr, uid, ids, context=None): def confirm_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> <b>converted</b> to Sale Order of %s %s.") % (obj.partner_id.name, obj.amount_total, obj.pricelist_id.currency_id.symbol), context=context) self.message_append_note(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> <b>converted</b> to Sale Order of %s %s.") % (obj.partner_id.name, obj.amount_total, obj.pricelist_id.currency_id.symbol), context=context)
def cancel_send_note(self, cr, uid, ids, context=None): def cancel_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Sale Order for <em>%s</em> <b>cancelled</b>.") % (obj.partner_id.name), context=context) self.message_append_note(cr, uid, [obj.id], body=_("Sale Order for <em>%s</em> <b>cancelled</b>.") % (obj.partner_id.name), context=context)
def delivery_send_note(self, cr, uid, ids, picking_id, context=None): def delivery_send_note(self, cr, uid, ids, picking_id, context=None):
for order in self.browse(cr, uid, ids, context=context): for order in self.browse(cr, uid, ids, context=context):
for picking in (pck for pck in order.picking_ids if pck.id == picking_id): for picking in (pck for pck in order.picking_ids if pck.id == picking_id):
@ -1050,22 +1050,22 @@ class sale_order(osv.osv):
picking_datetime = fields.DT.datetime.strptime(picking.min_date, DEFAULT_SERVER_DATETIME_FORMAT) picking_datetime = fields.DT.datetime.strptime(picking.min_date, DEFAULT_SERVER_DATETIME_FORMAT)
picking_date_str = fields.datetime.context_timestamp(cr, uid, picking_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)") picking_date_str = fields.datetime.context_timestamp(cr, uid, picking_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
self.message_append_note(cr, uid, [order.id], body=_("Delivery Order <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context) self.message_append_note(cr, uid, [order.id], body=_("Delivery Order <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context)
def delivery_end_send_note(self, cr, uid, ids, context=None): def delivery_end_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Order <b>delivered</b>."), context=context) self.message_append_note(cr, uid, ids, body=_("Order <b>delivered</b>."), context=context)
def invoice_paid_send_note(self, cr, uid, ids, context=None): def invoice_paid_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Invoice <b>paid</b>."), context=context) self.message_append_note(cr, uid, ids, body=_("Invoice <b>paid</b>."), context=context)
def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None):
for order in self.browse(cr, uid, ids, context=context): for order in self.browse(cr, uid, ids, context=context):
for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id):
self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s <b>waiting for validation</b>.") % (invoice.amount_total, invoice.currency_id.symbol), context=context) self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s <b>waiting for validation</b>.") % (invoice.amount_total, invoice.currency_id.symbol), context=context)
def action_cancel_draft_send_note(self, cr, uid, ids, context=None): def action_cancel_draft_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body='Sale order has been set in draft.', context=context) return self.message_append_note(cr, uid, ids, body='Sale order has been set in draft.', context=context)
sale_order() sale_order()
# TODO add a field price_unit_uos # TODO add a field price_unit_uos
@ -1249,7 +1249,7 @@ class sale_order_line(osv.osv):
def button_cancel(self, cr, uid, ids, context=None): def button_cancel(self, cr, uid, ids, context=None):
for line in self.browse(cr, uid, ids, context=context): for line in self.browse(cr, uid, ids, context=context):
if line.invoiced: if line.invoiced:
raise osv.except_osv(_('Invalid action !'), _('You cannot cancel a sale order line that has already been invoiced!')) raise osv.except_osv(_('Invalid Action!'), _('You cannot cancel a sale order line that has already been invoiced.'))
for move_line in line.move_ids: for move_line in line.move_ids:
if move_line.state != 'cancel': if move_line.state != 'cancel':
raise osv.except_osv( raise osv.except_osv(
@ -1333,7 +1333,7 @@ class sale_order_line(osv.osv):
(qty, ean, qty_pack, type_ul.name) (qty, ean, qty_pack, type_ul.name)
warning_msgs += _("Picking Information ! : ") + warn_msg + "\n\n" warning_msgs += _("Picking Information ! : ") + warn_msg + "\n\n"
warning = { warning = {
'title': _('Configuration Error !'), 'title': _('Configuration Error!'),
'message': warning_msgs 'message': warning_msgs
} }
result['product_uom_qty'] = qty result['product_uom_qty'] = qty
@ -1453,7 +1453,7 @@ class sale_order_line(osv.osv):
result.update({'price_unit': price}) result.update({'price_unit': price})
if warning_msgs: if warning_msgs:
warning = { warning = {
'title': _('Configuration Error !'), 'title': _('Configuration Error!'),
'message' : warning_msgs 'message' : warning_msgs
} }
return {'value': result, 'domain': domain, 'warning': warning} return {'value': result, 'domain': domain, 'warning': warning}
@ -1479,18 +1479,18 @@ class sale_order_line(osv.osv):
"""Allows to delete sales order lines in draft,cancel states""" """Allows to delete sales order lines in draft,cancel states"""
for rec in self.browse(cr, uid, ids, context=context): for rec in self.browse(cr, uid, ids, context=context):
if rec.state not in ['draft', 'cancel']: if rec.state not in ['draft', 'cancel']:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete a sales order line which is in state \'%s\'!') %(rec.state,)) raise osv.except_osv(_('Invalid Action!'), _('Cannot delete a sales order line which is in state \'%s\'.') %(rec.state,))
return super(sale_order_line, self).unlink(cr, uid, ids, context=context) return super(sale_order_line, self).unlink(cr, uid, ids, context=context)
sale_order_line() sale_order_line()
class mail_message(osv.osv): class mail_message(osv.osv):
_inherit = 'mail.message' _inherit = 'mail.message'
def _postprocess_sent_message(self, cr, uid, message, context=None): def _postprocess_sent_message(self, cr, uid, message, context=None):
if message.model == 'sale.order': if message.model == 'sale.order':
wf_service = netsvc.LocalService("workflow") wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'sale.order', message.res_id, 'quotation_sent', cr) wf_service.trg_validate(uid, 'sale.order', message.res_id, 'quotation_sent', cr)
return super(mail_message, self)._postprocess_sent_message(cr, uid, message=message, context=context) return super(mail_message, self)._postprocess_sent_message(cr, uid, message=message, context=context)
mail_message() mail_message()

View File

@ -114,12 +114,12 @@ class sale_advance_payment_inv(osv.osv_memory):
prop_id = prop and prop.id or False prop_id = prop and prop.id or False
account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, sale.fiscal_position.id or False, prop_id) account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, sale.fiscal_position.id or False, prop_id)
if not account_id: if not account_id:
raise osv.except_osv(_('Configuration Error !'), raise osv.except_osv(_('Configuration Error!'),
_('There is no income account defined as global property.')) _('There is no income account defined as global property.'))
res['account_id'] = account_id res['account_id'] = account_id
if not res.get('account_id'): if not res.get('account_id'):
raise osv.except_osv(_('Configuration Error !'), raise osv.except_osv(_('Configuration Error!'),
_('There is no income account defined for this product: "%s" (id:%d)') % \ _('There is no income account defined for this product: "%s" (id:%d).') % \
(wizard.product_id.name, wizard.product_id.id,)) (wizard.product_id.name, wizard.product_id.id,))
# determine invoice amount # determine invoice amount

View File

@ -605,7 +605,7 @@ class stock_picking(osv.osv):
res[pick]['min_date'] = dt1 res[pick]['min_date'] = dt1
res[pick]['max_date'] = dt2 res[pick]['max_date'] = dt2
return res return res
def create(self, cr, user, vals, context=None): def create(self, cr, user, vals, context=None):
if ('name' not in vals) or (vals.get('name')=='/'): if ('name' not in vals) or (vals.get('name')=='/'):
seq_obj_name = 'stock.picking.' + vals['type'] seq_obj_name = 'stock.picking.' + vals['type']
@ -1322,7 +1322,7 @@ class stock_picking(osv.osv):
delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context) delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context)
res[pick.id] = {'delivered_picking': delivered_pack.id or False} res[pick.id] = {'delivered_picking': delivered_pack.id or False}
return res return res
def log_picking(self, cr, uid, ids, context=None): def log_picking(self, cr, uid, ids, context=None):
@ -1364,11 +1364,11 @@ class stock_picking(osv.osv):
context.update({'view_id': res and res[1] or False}) context.update({'view_id': res and res[1] or False})
message += state_list[pick.state] message += state_list[pick.state]
return True return True
# ----------------------------------------- # -----------------------------------------
# OpenChatter methods and notifications # OpenChatter methods and notifications
# ----------------------------------------- # -----------------------------------------
def _get_document_type(self, type): def _get_document_type(self, type):
type_dict = { type_dict = {
'out': 'Delivery order', 'out': 'Delivery order',
@ -1376,17 +1376,17 @@ class stock_picking(osv.osv):
'internal': 'Internal picking', 'internal': 'Internal picking',
} }
return type_dict.get(type, 'Stock picking') return type_dict.get(type, 'Stock picking')
def create_send_note(self, cr, uid, ids, context=None): def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("%s has been <b>created</b>.") % (self._get_document_type(obj.type)), context=context) self.message_append_note(cr, uid, [obj.id], body=_("%s has been <b>created</b>.") % (self._get_document_type(obj.type)), context=context)
def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None): def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None):
return self.message_append_note(cr, uid, ids, body= _("%s %s %s has been <b>moved to</b> scrap.") % (quantity, uom, name), context=context) return self.message_append_note(cr, uid, ids, body= _("%s %s %s has been <b>moved to</b> scrap.") % (quantity, uom, name), context=context)
def back_order_send_note(self, cr, uid, ids, back_name, context=None): def back_order_send_note(self, cr, uid, ids, back_name, context=None):
return self.message_append_note(cr, uid, ids, body=_("Back order <em>%s</em> has been <b>created</b>.") % (back_name), context=context) return self.message_append_note(cr, uid, ids, body=_("Back order <em>%s</em> has been <b>created</b>.") % (back_name), context=context)
def ship_done_send_note(self, cr, uid, ids, context=None): def ship_done_send_note(self, cr, uid, ids, context=None):
type_dict = { type_dict = {
'out': 'delivered', 'out': 'delivered',
@ -1395,11 +1395,11 @@ class stock_picking(osv.osv):
} }
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Products have been <b>%s</b>.") % (type_dict.get(obj.type, 'move done')), context=context) self.message_append_note(cr, uid, [obj.id], body=_("Products have been <b>%s</b>.") % (type_dict.get(obj.type, 'move done')), context=context)
def ship_cancel_send_note(self, cr, uid, ids, context=None): def ship_cancel_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("%s has been <b>cancelled</b>.") % (self._get_document_type(obj.type)), context=context) self.message_append_note(cr, uid, [obj.id], body=_("%s has been <b>cancelled</b>.") % (self._get_document_type(obj.type)), context=context)
stock_picking() stock_picking()
@ -1727,7 +1727,7 @@ class stock_move(osv.osv):
if location_xml_id: if location_xml_id:
location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', location_xml_id) location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', location_xml_id)
return location_id return location_id
def _default_destination_address(self, cr, uid, context=None): def _default_destination_address(self, cr, uid, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return user.company_id.partner_id.id return user.company_id.partner_id.id
@ -2367,7 +2367,7 @@ class stock_move(osv.osv):
ctx = context.copy() ctx = context.copy()
for move in self.browse(cr, uid, ids, context=context): for move in self.browse(cr, uid, ids, context=context):
if move.state != 'draft' and not ctx.get('call_unlink',False): if move.state != 'draft' and not ctx.get('call_unlink',False):
raise osv.except_osv(_('UserError!'), raise osv.except_osv(_('User Error!'),
_('You can only delete draft moves.')) _('You can only delete draft moves.'))
return super(stock_move, self).unlink( return super(stock_move, self).unlink(
cr, uid, ids, context=ctx) cr, uid, ids, context=ctx)
@ -2537,7 +2537,7 @@ class stock_move(osv.osv):
'location_id': location_id or move.location_id.id, 'location_id': location_id or move.location_id.id,
} }
self.write(cr, uid, [move.id], update_val) self.write(cr, uid, [move.id], update_val)
product_obj = self.pool.get('product.product') product_obj = self.pool.get('product.product')
for new_move in self.browse(cr, uid, res, context=context): for new_move in self.browse(cr, uid, res, context=context):
message = _("Product has been consumed with '%s' quantity.") % (new_move.product_qty) message = _("Product has been consumed with '%s' quantity.") % (new_move.product_qty)
@ -2779,7 +2779,7 @@ class stock_inventory(osv.osv):
account_move_data_l = account_move_obj.read(cr, uid, account_move_ids, ['state'], context=context) account_move_data_l = account_move_obj.read(cr, uid, account_move_ids, ['state'], context=context)
for account_move in account_move_data_l: for account_move in account_move_data_l:
if account_move['state'] == 'posted': if account_move['state'] == 'posted':
raise osv.except_osv(_('UserError!'), raise osv.except_osv(_('User Error!'),
_('In order to cancel this inventory, you must first unpost related journal entries.')) _('In order to cancel this inventory, you must first unpost related journal entries.'))
account_move_obj.unlink(cr, uid, [account_move['id']], context=context) account_move_obj.unlink(cr, uid, [account_move['id']], context=context)
self.write(cr, uid, [inv.id], {'state': 'cancel'}, context=context) self.write(cr, uid, [inv.id], {'state': 'cancel'}, context=context)
@ -2869,8 +2869,8 @@ class stock_picking_in(osv.osv):
('confirmed', 'Waiting Availability'), ('confirmed', 'Waiting Availability'),
('assigned', 'Ready to Receive'), ('assigned', 'Ready to Receive'),
('done', 'Received'), ('done', 'Received'),
('cancel', 'Cancelled'),], ('cancel', 'Cancelled'),],
'State', readonly=True, select=True, 'State', readonly=True, select=True,
help="""* Draft: not confirmed yet and will not be scheduled until confirmed\n help="""* Draft: not confirmed yet and will not be scheduled until confirmed\n
* Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n * Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n
* Waiting Availability: still waiting for the availability of products\n * Waiting Availability: still waiting for the availability of products\n
@ -2908,8 +2908,8 @@ class stock_picking_out(osv.osv):
('confirmed', 'Waiting Availability'), ('confirmed', 'Waiting Availability'),
('assigned', 'Ready to Deliver'), ('assigned', 'Ready to Deliver'),
('done', 'Delivered'), ('done', 'Delivered'),
('cancel', 'Cancelled'),], ('cancel', 'Cancelled'),],
'State', readonly=True, select=True, 'State', readonly=True, select=True,
help="""* Draft: not confirmed yet and will not be scheduled until confirmed\n help="""* Draft: not confirmed yet and will not be scheduled until confirmed\n
* Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n * Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n
* Waiting Availability: still waiting for the availability of products\n * Waiting Availability: still waiting for the availability of products\n

View File

@ -29,7 +29,7 @@ from tools.translate import _
import logging import logging
import decimal_precision as dp import decimal_precision as dp
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
def rounding(fl, round_value): def rounding(fl, round_value):
@ -52,11 +52,11 @@ class stock_period(osv.osv):
_defaults = { _defaults = {
'state': 'draft' 'state': 'draft'
} }
def button_open(self, cr, uid, ids, context=None): def button_open(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'open'}) self.write(cr, uid, ids, {'state': 'open'})
return True return True
def button_close(self, cr, uid, ids, context=None): def button_close(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'close'}) self.write(cr, uid, ids, {'state': 'close'})
return True return True
@ -143,7 +143,7 @@ class stock_sale_forecast(osv.osv):
if t['state'] in ('draft'): if t['state'] in ('draft'):
unlink_ids.append(t['id']) unlink_ids.append(t['id'])
else: else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete a validated sales forecast!')) raise osv.except_osv(_('Invalid Action!'), _('Cannot delete a validated sales forecast.'))
osv.osv.unlink(self, cr, uid, unlink_ids, context=context) osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
return True return True
@ -172,7 +172,7 @@ class stock_sale_forecast(osv.osv):
res = {'value': ret} res = {'value': ret}
return res return res
def onchange_uom(self, cr, uid, ids, product_uom=False, product_qty=0.0, def onchange_uom(self, cr, uid, ids, product_uom=False, product_qty=0.0,
active_uom=False, product_id=False): active_uom=False, product_id=False):
ret = {} ret = {}
if product_uom and product_id: if product_uom and product_id:
@ -430,7 +430,7 @@ class stock_planning(osv.osv):
result['warehouse_id'] = False result['warehouse_id'] = False
return {'value': result} return {'value': result}
def onchange_uom(self, cr, uid, ids, product_uom=False, product_id=False, active_uom=False, def onchange_uom(self, cr, uid, ids, product_uom=False, product_id=False, active_uom=False,
planned_outgoing=0.0, to_procure=0.0): planned_outgoing=0.0, to_procure=0.0):
ret = {} ret = {}
if not product_uom: if not product_uom:
@ -623,7 +623,7 @@ class stock_planning(osv.osv):
def procure_incomming_left(self, cr, uid, ids, context, *args): def procure_incomming_left(self, cr, uid, ids, context, *args):
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
if obj.incoming_left <= 0: if obj.incoming_left <= 0:
raise osv.except_osv(_('Error !'), _('Incoming Left must be greater than 0 !')) raise osv.except_osv(_('Error!'), _('Incoming Left must be greater than 0.'))
uom_qty, uom, uos_qty, uos = self._qty_to_standard(cr, uid, obj, context) uom_qty, uom, uos_qty, uos = self._qty_to_standard(cr, uid, obj, context)
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
proc_id = self.pool.get('procurement.order').create(cr, uid, { proc_id = self.pool.get('procurement.order').create(cr, uid, {
@ -667,11 +667,11 @@ class stock_planning(osv.osv):
def internal_supply(self, cr, uid, ids, context, *args): def internal_supply(self, cr, uid, ids, context, *args):
for obj in self.browse(cr, uid, ids, context=context): for obj in self.browse(cr, uid, ids, context=context):
if obj.incoming_left <= 0: if obj.incoming_left <= 0:
raise osv.except_osv(_('Error !'), _('Incoming Left must be greater than 0 !')) raise osv.except_osv(_('Error!'), _('Incoming Left must be greater than 0.'))
if not obj.supply_warehouse_id: if not obj.supply_warehouse_id:
raise osv.except_osv(_('Error !'), _('You must specify a Source Warehouse !')) raise osv.except_osv(_('Error!'), _('You must specify a Source Warehouse.'))
if obj.supply_warehouse_id.id == obj.warehouse_id.id: if obj.supply_warehouse_id.id == obj.warehouse_id.id:
raise osv.except_osv(_('Error !'), _('You must specify a Source Warehouse different than calculated (destination) Warehouse !')) raise osv.except_osv(_('Error!'), _('You must specify a Source Warehouse different than calculated (destination) Warehouse.'))
uom_qty, uom, uos_qty, uos = self._qty_to_standard(cr, uid, obj, context) uom_qty, uom, uos_qty, uos = self._qty_to_standard(cr, uid, obj, context)
user = self.pool.get('res.users').browse(cr, uid, uid, context) user = self.pool.get('res.users').browse(cr, uid, uid, context)
picking_id = self.pool.get('stock.picking').create(cr, uid, { picking_id = self.pool.get('stock.picking').create(cr, uid, {