[IMP] rephrase some error and warning messages in account

remove exclamation marks at the end of messages
remove first person usage ('I' and 'We')
remove unjustified capital letters
rephrase the clumsy form 'No <some attribute> is defined'

bzr revid: abo@openerp.com-20120806154410-kbf9aai2uzq2b0c4
This commit is contained in:
Antonin Bourguignon 2012-08-06 17:44:10 +02:00
parent 3bbe3ddbd5
commit 48e0915804
22 changed files with 160 additions and 160 deletions

View File

@ -125,7 +125,7 @@ class account_payment_term_line(osv.osv):
return True return True
_constraints = [ _constraints = [
(_check_percent, 'Percentages for Payment Term Line must be between 0 and 1, Example: 0.02 for 2% .', ['value_amount']), (_check_percent, 'Percentages for Payment Term Line must be between 0 and 1, Example: 0.02 for 2%.', ['value_amount']),
] ]
account_payment_term_line() account_payment_term_line()
@ -409,7 +409,7 @@ class account_account(osv.osv):
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)
if not pids: if not pids:
raise osv.except_osv(_('Error!'),_("No opening/closing period is defined, please create one to set the initial balance!")) raise osv.except_osv(_('Error!'),_("There is no opening/closing period defined, please create one to set the initial balance."))
move_obj = self.pool.get('account.move.line') move_obj = self.pool.get('account.move.line')
move_id = move_obj.search(cr, uid, [ move_id = move_obj.search(cr, uid, [
@ -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 some 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 containing 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)
@ -790,7 +790,7 @@ class account_journal(osv.osv):
if 'company_id' in vals and journal.company_id.id != vals['company_id']: if 'company_id' in vals and journal.company_id.id != vals['company_id']:
move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)]) move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)])
if move_lines: if move_lines:
raise osv.except_osv(_('Warning !'), _('You cannot modify the company of this journal as its related record exist in journal items.')) raise osv.except_osv(_('Warning !'), _('This journal already contains items, therefore you cannot modify its company field.'))
return super(account_journal, self).write(cr, uid, ids, vals, context=context) return super(account_journal, self).write(cr, uid, ids, vals, context=context)
def create_sequence(self, cr, uid, vals, context=None): def create_sequence(self, cr, uid, vals, context=None):
@ -915,7 +915,7 @@ class account_fiscalyear(osv.osv):
return True return True
_constraints = [ _constraints = [
(_check_duration, 'Error! The start date of the fiscal year must be less than the end date.', ['date_start','date_stop']) (_check_duration, 'Error! The 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 !'), _('No fiscal year is 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
@ -1033,7 +1033,7 @@ class account_period(osv.osv):
_constraints = [ _constraints = [
(_check_duration, 'Error ! The duration of the Period(s) is/are invalid. ', ['date_stop']), (_check_duration, 'Error ! The duration of the Period(s) is/are invalid. ', ['date_stop']),
(_check_year_limit, 'Invalid period ! Some periods overlap or the date period which is not in the scope of the fiscal year. ', ['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'])
] ]
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 !'), _('No period is 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):
@ -1080,7 +1080,7 @@ class account_period(osv.osv):
if 'company_id' in vals: if 'company_id' in vals:
move_lines = self.pool.get('account.move.line').search(cr, uid, [('period_id', 'in', ids)]) move_lines = self.pool.get('account.move.line').search(cr, uid, [('period_id', 'in', ids)])
if move_lines: if move_lines:
raise osv.except_osv(_('Warning !'), _('You cannot modify company of this period as some journal items exist.')) raise osv.except_osv(_('Warning !'), _('This journal already contains items for this period, therefore you cannot modify its company field.'))
return super(account_period, self).write(cr, uid, ids, vals, context=context) return super(account_period, self).write(cr, uid, ids, vals, context=context)
def build_ctx_periods(self, cr, uid, period_from_id, period_to_id): def build_ctx_periods(self, cr, uid, period_from_id, period_to_id):
@ -1095,7 +1095,7 @@ class account_period(osv.osv):
if company1_id != company2_id: if company1_id != company2_id:
raise osv.except_osv(_('Error!'), _('You should choose the periods that belong to the same company.')) raise osv.except_osv(_('Error!'), _('You should choose the periods that belong to the same company.'))
if period_date_start > period_date_stop: if period_date_start > period_date_stop:
raise osv.except_osv(_('Error!'), _('Start period should be smaller than End period.')) raise osv.except_osv(_('Error!'), _('Start period should precede then end period.'))
#for period from = january, we want to exclude the opening period (but it has same date_from, so we have to check if period_from is special or not to include that clause or not in the search). #for period from = january, we want to exclude the opening period (but it has same date_from, so we have to check if period_from is special or not to include that clause or not in the search).
if period_from.special: if period_from.special:
return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id)]) return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id)])
@ -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):
@ -1303,7 +1303,7 @@ class account_move(osv.osv):
_constraints = [ _constraints = [
(_check_centralisation, (_check_centralisation,
'You cannot create more than one move per period on centralized journal.', 'You cannot create more than one move per period on a centralized journal.',
['journal_id']), ['journal_id']),
] ]
@ -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 type "Balance" !')) 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.'))
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 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})
@ -1358,7 +1358,7 @@ class account_move(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 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 !\nYou should set the journal to allow cancelling entries if you want to do that.')) 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 '\
@ -1446,7 +1446,7 @@ class account_move(osv.osv):
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(_('UserError!'),
_('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)
context['journal_id'] = move.journal_id.id context['journal_id'] = move.journal_id.id
@ -1475,14 +1475,14 @@ class account_move(osv.osv):
mode2 = 'debit' mode2 = 'debit'
if not account_id: if not account_id:
raise osv.except_osv(_('UserError'), raise osv.except_osv(_('UserError'),
_('No default debit account is 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(_('UserError'),
_('No default credit account is defined \n' \ _('There is no default credit account defined \n' \
'on journal "%s".') % move.journal_id.name) 'on journal "%s".') % move.journal_id.name)
# find the first line of this move with the current mode # find the first line of this move with the current mode
@ -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 !'), _('I cannot locate a 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

View File

@ -88,7 +88,7 @@ class account_analytic_line(osv.osv):
a = prod.categ_id.property_account_expense_categ.id a = prod.categ_id.property_account_expense_categ.id
if not a: if not a:
raise osv.except_osv(_('Error !'), raise osv.except_osv(_('Error !'),
_('No expense account is defined ' \ _('There is no expense account defined ' \
'for this product: "%s" (id:%d).') % \ 'for this product: "%s" (id:%d).') % \
(prod.name, prod.id,)) (prod.name, prod.id,))
else: else:
@ -97,7 +97,7 @@ class account_analytic_line(osv.osv):
a = prod.categ_id.property_account_income_categ.id a = prod.categ_id.property_account_income_categ.id
if not a: if not a:
raise osv.except_osv(_('Error !'), raise osv.except_osv(_('Error !'),
_('No income account is defined ' \ _('There is no income account defined ' \
'for this product: "%s" (id:%d).') % \ 'for this product: "%s" (id:%d).') % \
(prod.name, prod_id,)) (prod.name, prod_id,))

View File

@ -260,7 +260,7 @@ class account_cash_statement(osv.osv):
if journal_type == 'bank': if journal_type == 'bank':
return super(account_cash_statement, self).balance_check(cr, uid, cash_id, journal_type, context) return super(account_cash_statement, self).balance_check(cr, uid, cash_id, journal_type, context)
if not self._equal_balance(cr, uid, cash_id, context): if not self._equal_balance(cr, uid, cash_id, context):
raise osv.except_osv(_('Error !'), _('The closing balance should be equal to compute balance on the cash register !')) raise osv.except_osv(_('Error !'), _('The closing balance should be equal to compute balance on the cash register.'))
return True return True
def statement_close(self, cr, uid, ids, journal_type='bank', context=None): def statement_close(self, cr, uid, ids, journal_type='bank', context=None):
@ -289,8 +289,8 @@ class account_cash_statement(osv.osv):
for item_label, item_account in TALBES: for item_label, item_account in TALBES:
if getattr(obj.journal_id, item_account): if getattr(obj.journal_id, item_account):
raise osv.except_osv(_('Error !'), raise osv.except_osv(_('Error !'),
_('No %s Account on the Journal %s.') % (item_label, obj.journal_id.name,)) _('There is no %s Account on the journal %s.') % (item_label, obj.journal_id.name,))
is_profit = obj.difference < 0.0 is_profit = obj.difference < 0.0

View File

@ -319,7 +319,7 @@ class account_invoice(osv.osv):
res['fields'][field]['selection'] = journal_select res['fields'][field]['selection'] = journal_select
doc = etree.XML(res['arch']) doc = etree.XML(res['arch'])
if context.get('type', False): if context.get('type', False):
for node in doc.xpath("//field[@name='partner_bank_id']"): for node in doc.xpath("//field[@name='partner_bank_id']"):
if context['type'] == 'in_refund': if context['type'] == 'in_refund':
@ -327,7 +327,7 @@ class account_invoice(osv.osv):
elif context['type'] == 'out_refund': elif context['type'] == 'out_refund':
node.set('domain', "[('partner_id', '=', partner_id)]") node.set('domain', "[('partner_id', '=', partner_id)]")
res['arch'] = etree.tostring(doc) res['arch'] = etree.tostring(doc)
if view_type == 'search': if view_type == 'search':
if context.get('type', 'in_invoice') in ('out_invoice', 'out_refund'): if context.get('type', 'in_invoice') in ('out_invoice', 'out_refund'):
for node in doc.xpath("//group[@name='extended filter']"): for node in doc.xpath("//group[@name='extended filter']"):
@ -364,7 +364,7 @@ class account_invoice(osv.osv):
except Exception, e: except Exception, e:
if '"journal_id" viol' in e.args[0]: if '"journal_id" viol' in e.args[0]:
raise orm.except_orm(_('Configuration Error!'), raise orm.except_orm(_('Configuration Error!'),
_('No Sale/Purchase Journal(s) is defined!')) _('There is no Sale/Purchase Journal(s) defined.'))
else: else:
raise orm.except_orm(_('Unknown Error!'), str(e)) raise orm.except_orm(_('Unknown Error!'), str(e))
@ -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. We suggest you to 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
@ -577,7 +577,7 @@ class account_invoice(osv.osv):
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 !'),
_('Company of invoice line account and the company of invoice does not match.')) _('Invoice line account\'s company and invoice\'s compnay does not match.'))
else: else:
continue continue
if company_id and type: if company_id and type:
@ -840,7 +840,7 @@ class account_invoice(osv.osv):
raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.')) raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.'))
if inv.move_id: if inv.move_id:
continue continue
ctx = context.copy() ctx = context.copy()
ctx.update({'lang': inv.partner_id.lang}) ctx.update({'lang': inv.partner_id.lang})
if not inv.date_invoice: if not inv.date_invoice:
@ -866,7 +866,7 @@ class account_invoice(osv.osv):
total_percent += line.value_amount total_percent += line.value_amount
total_fixed = (total_fixed * 100) / (inv.amount_total or 1.0) total_fixed = (total_fixed * 100) / (inv.amount_total or 1.0)
if (total_fixed + total_percent) > 100: if (total_fixed + total_percent) > 100:
raise osv.except_osv(_('Error !'), _("Cannot create the invoice !\nThe related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount. The latest line of your payment term must be of type 'balance' to avoid rounding issues.")) raise osv.except_osv(_('Error !'), _("Cannot create the invoice.\nThe related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount. In order to avoid rounding issues, the latest line of your payment term must be of type 'balance'."))
# one move line per tax line # one move line per tax line
iml += ait_obj.move_line_get(cr, uid, inv.id) iml += ait_obj.move_line_get(cr, uid, inv.id)
@ -979,7 +979,7 @@ class account_invoice(osv.osv):
move_obj.post(cr, uid, [move_id], context=ctx) move_obj.post(cr, uid, [move_id], context=ctx)
self._log_event(cr, uid, ids) self._log_event(cr, uid, ids)
return True return True
def invoice_validate(self, cr, uid, ids, context=None): def invoice_validate(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state':'open'}, context=context) self.write(cr, uid, ids, {'state':'open'}, context=context)
return True return True
@ -1061,7 +1061,7 @@ class account_invoice(osv.osv):
pay_ids = account_move_line_obj.browse(cr, uid, i['payment_ids']) pay_ids = account_move_line_obj.browse(cr, uid, i['payment_ids'])
for move_line in pay_ids: for move_line in pay_ids:
if move_line.reconcile_partial_id and move_line.reconcile_partial_id.line_partial_ids: if move_line.reconcile_partial_id and move_line.reconcile_partial_id.line_partial_ids:
raise osv.except_osv(_('Error !'), _('You cannot cancel an invoice which is partially paid! You need to unreconcile related payment entries first!')) raise osv.except_osv(_('Error !'), _('You cannot cancel an invoice which is partially paid. You need to unreconcile related payment entries first.'))
# First, set the invoices as cancelled and detach the move ids # First, set the invoices as cancelled and detach the move ids
self.write(cr, uid, ids, {'state':'cancel', 'move_id':False}) self.write(cr, uid, ids, {'state':'cancel', 'move_id':False})
@ -1281,11 +1281,11 @@ class account_invoice(osv.osv):
# Update the stored value (fields.function), so we write to trigger recompute # Update the stored value (fields.function), so we write to trigger recompute
self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context) self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context)
return True return True
# ----------------------------------------- # -----------------------------------------
# OpenChatter notifications and need_action # OpenChatter notifications and need_action
# ----------------------------------------- # -----------------------------------------
def _get_document_type(self, type): def _get_document_type(self, type):
type_dict = { type_dict = {
'out_invoice': 'Customer invoice', 'out_invoice': 'Customer invoice',
@ -1294,19 +1294,19 @@ class account_invoice(osv.osv):
'in_refund': 'Supplier Refund', 'in_refund': 'Supplier Refund',
} }
return type_dict.get(type, 'Invoice') return type_dict.get(type, 'Invoice')
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 <b>created</b>.") % (self._get_document_type(obj.type)), context=context) self.message_append_note(cr, uid, [obj.id],body=_("%s <b>created</b>.") % (self._get_document_type(obj.type)), context=context)
def confirm_paid_send_note(self, cr, uid, ids, context=None): def confirm_paid_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 <b>paid</b>.") % (self._get_document_type(obj.type)), context=context) self.message_append_note(cr, uid, [obj.id], body=_("%s <b>paid</b>.") % (self._get_document_type(obj.type)), context=context)
def invoice_cancel_send_note(self, cr, uid, ids, context=None): def invoice_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 <b>cancelled</b>.") % (self._get_document_type(obj.type)), context=context) self.message_append_note(cr, uid, [obj.id], body=_("%s <b>cancelled</b>.") % (self._get_document_type(obj.type)), context=context)
account_invoice() account_invoice()
class account_invoice_line(osv.osv): class account_invoice_line(osv.osv):
@ -1475,7 +1475,7 @@ class account_invoice_line(osv.osv):
if prod.uom_id.category_id.id != prod_uom.category_id.id: if prod.uom_id.category_id.id != prod_uom.category_id.id:
warning = { warning = {
'title': _('Warning!'), 'title': _('Warning!'),
'message': _('Selected Unit of Measure is not compatible with the Unit of Measure of the product.') 'message': _('The selected unit of measure is not compatible with the unit of measure of the product.')
} }
return {'value': res['value'], 'warning': warning} return {'value': res['value'], 'warning': warning}
return res return res

View File

@ -95,7 +95,7 @@ class account_move_line(osv.osv):
if initial_bal and not context.get('periods', False) and not where_move_lines_by_date: if initial_bal and not context.get('periods', False) and not where_move_lines_by_date:
#we didn't pass any filter in the context, and the initial balance can't be computed using only the fiscalyear otherwise entries will be summed twice #we didn't pass any filter in the context, and the initial balance can't be computed using only the fiscalyear otherwise entries will be summed twice
#so we have to invalidate this query #so we have to invalidate this query
raise osv.except_osv(_('Warning !'),_("You havenot supplied enough argument to compute the initial balance, please select a period and journal in the context.")) raise osv.except_osv(_('Warning !'),_("You have not supplied enough arguments to compute the initial balance, please select a period and a journal in the context."))
if context.get('journal_ids', False): if context.get('journal_ids', False):
@ -752,7 +752,7 @@ class account_move_line(osv.osv):
else: else:
currency_id = line.company_id.currency_id currency_id = line.company_id.currency_id
if line.reconcile_id: if line.reconcile_id:
raise osv.except_osv(_('Warning !'), _('Already Reconciled!')) raise osv.except_osv(_('Warning !'), _('Already reconciled.'))
if line.reconcile_partial_id: if line.reconcile_partial_id:
for line2 in line.reconcile_partial_id.line_partial_ids: for line2 in line.reconcile_partial_id.line_partial_ids:
if not line2.reconcile_id: if not line2.reconcile_id:
@ -823,15 +823,15 @@ class account_move_line(osv.osv):
r = cr.fetchall() r = cr.fetchall()
#TODO: move this check to a constraint in the account_move_reconcile object #TODO: move this check to a constraint in the account_move_reconcile object
if not unrec_lines: if not unrec_lines:
raise osv.except_osv(_('Error !'), _('Entry is already reconciled!')) raise osv.except_osv(_('Error !'), _('Entry is already reconciled.'))
account = account_obj.browse(cr, uid, account_id, context=context) account = account_obj.browse(cr, uid, account_id, context=context)
if r[0][1] != None: if r[0][1] != None:
raise osv.except_osv(_('Error !'), _('Some entries are already reconciled !')) raise osv.except_osv(_('Error !'), _('Some entries are already reconciled.'))
if (not currency_obj.is_zero(cr, uid, account.company_id.currency_id, writeoff)) or \ if (not currency_obj.is_zero(cr, uid, account.company_id.currency_id, writeoff)) or \
(account.currency_id and (not currency_obj.is_zero(cr, uid, account.currency_id, currency))): (account.currency_id and (not currency_obj.is_zero(cr, uid, account.currency_id, currency))):
if not writeoff_acc_id: if not writeoff_acc_id:
raise osv.except_osv(_('Warning !'), _('You have to provide an account for the write off/exchange difference entry !')) raise osv.except_osv(_('Warning !'), _('You have to provide an account for the write off/exchange difference entry.'))
if writeoff > 0: if writeoff > 0:
debit = writeoff debit = writeoff
credit = 0.0 credit = 0.0
@ -1092,7 +1092,7 @@ class account_move_line(osv.osv):
if res[1] != 'draft': if res[1] != 'draft':
raise osv.except_osv(_('UserError!'), raise osv.except_osv(_('UserError!'),
_('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
def _remove_move_reconcile(self, cr, uid, move_ids=[], context=None): def _remove_move_reconcile(self, cr, uid, move_ids=[], context=None):
@ -1139,9 +1139,9 @@ class account_move_line(osv.osv):
if isinstance(ids, (int, long)): if isinstance(ids, (int, long)):
ids = [ids] ids = [ids]
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)
@ -1202,9 +1202,9 @@ class account_move_line(osv.osv):
for line in self.browse(cr, uid, ids, context=context): for line in self.browse(cr, uid, ids, context=context):
err_msg = _('Move name (id): %s (%s)') % (line.move_id.name, str(line.move_id.id)) err_msg = _('Move name (id): %s (%s)') % (line.move_id.name, str(line.move_id.id))
if line.move_id.state <> 'draft' and (not line.journal_id.entry_posted): if line.move_id.state <> 'draft' and (not line.journal_id.entry_posted):
raise osv.except_osv(_('Error !'), _('You cannot do this modification on a confirmed entry! You can just change some non legal fields or you must unconfirm the journal entry first! \n%s.') % err_msg) raise osv.except_osv(_('Error !'), _('You cannot do this modification on a confirmed entry. You can just change some non legal fields or you must unconfirm the journal entry first.\n%s.') % err_msg)
if line.reconcile_id: if line.reconcile_id:
raise osv.except_osv(_('Error !'), _('You cannot do this modification on a reconciled entry! You can just change some non legal fields or you must unreconcile first!\n%s.') % err_msg) raise osv.except_osv(_('Error !'), _('You cannot do this modification on a reconciled entry. You can just change some non legal fields or you must unreconcile first.\n%s.') % err_msg)
t = (line.journal_id.id, line.period_id.id) t = (line.journal_id.id, line.period_id.id)
if t not in done: if t not in done:
self._update_journal_check(cr, uid, line.journal_id.id, line.period_id.id, context) self._update_journal_check(cr, uid, line.journal_id.id, line.period_id.id, 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,10 +1237,10 @@ 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 is found or more than one period found for the given date.')) raise osv.except_osv(_('Encoding 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')
self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context) self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context)
move_id = vals.get('move_id', False) move_id = vals.get('move_id', False)
journal = journal_obj.browse(cr, uid, context['journal_id'], context=context) journal = journal_obj.browse(cr, uid, context['journal_id'], context=context)
@ -1263,7 +1263,7 @@ class account_move_line(osv.osv):
move_id = move_obj.create(cr, uid, v, context) move_id = move_obj.create(cr, uid, v, context)
vals['move_id'] = move_id vals['move_id'] = move_id
else: else:
raise osv.except_osv(_('No piece number !'), _('Cannot create an automatic sequence for this piece!\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.')) raise osv.except_osv(_('No piece number !'), _('Cannot create an automatic sequence for this piece.\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.'))
ok = not (journal.type_control_ids or journal.account_control_ids) ok = not (journal.type_control_ids or journal.account_control_ids)
if ('account_id' in vals): if ('account_id' in vals):
account = account_obj.browse(cr, uid, vals['account_id'], context=context) account = account_obj.browse(cr, uid, vals['account_id'], context=context)
@ -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

@ -89,7 +89,7 @@ class common_report_header(object):
return '' return ''
def _get_sortby(self, data): def _get_sortby(self, data):
raise (_('Error!'), _('Not implemented!')) raise (_('Error!'), _('Not implemented.'))
def _get_filter(self, data): def _get_filter(self, data):
if data.get('form', False) and data['form'].get('filter', False): if data.get('form', False) and data['form'].get('filter', False):

View File

@ -35,7 +35,7 @@ class account_change_currency(osv.osv_memory):
context = {} context = {}
if context.get('active_id',False): if context.get('active_id',False):
if obj_inv.browse(cr, uid, context['active_id']).state != 'draft': if obj_inv.browse(cr, uid, context['active_id']).state != 'draft':
raise osv.except_osv(_('Error!'), _('You can only change currency for Draft Invoice !')) raise osv.except_osv(_('Error!'), _('You can only change currency for Draft Invoice.'))
pass pass
def change_currency(self, cr, uid, ids, context=None): def change_currency(self, cr, uid, ids, context=None):
@ -56,18 +56,18 @@ class account_change_currency(osv.osv_memory):
if invoice.company_id.currency_id.id == invoice.currency_id.id: if invoice.company_id.currency_id.id == invoice.currency_id.id:
new_price = line.price_unit * rate new_price = line.price_unit * rate
if new_price <= 0: if new_price <= 0:
raise osv.except_osv(_('Error!'), _('New currency is not configured properly !')) raise osv.except_osv(_('Error!'), _('New currency is not configured properly.'))
if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id == new_currency: if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id == new_currency:
old_rate = invoice.currency_id.rate old_rate = invoice.currency_id.rate
if old_rate <= 0: if old_rate <= 0:
raise osv.except_osv(_('Error!'), _('Current currency is not configured properly !')) raise osv.except_osv(_('Error!'), _('Current currency is not configured properly.'))
new_price = line.price_unit / old_rate new_price = line.price_unit / old_rate
if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id != new_currency: if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id != new_currency:
old_rate = invoice.currency_id.rate old_rate = invoice.currency_id.rate
if old_rate <= 0: if old_rate <= 0:
raise osv.except_osv(_('Error!'), _('Current currency is not configured properly !')) raise osv.except_osv(_('Error!'), _('Current currency is not configured properly.'))
new_price = (line.price_unit / old_rate ) * rate new_price = (line.price_unit / old_rate ) * rate
obj_inv_line.write(cr, uid, [line.id], {'price_unit': new_price}) obj_inv_line.write(cr, uid, [line.id], {'price_unit': new_price})
obj_inv.write(cr, uid, [invoice.id], {'currency_id': new_currency}, context=context) obj_inv.write(cr, uid, [invoice.id], {'currency_id': new_currency}, context=context)

View File

@ -51,9 +51,9 @@ class account_fiscalyear_close(osv.osv_memory):
""" """
def _reconcile_fy_closing(cr, uid, ids, context=None): def _reconcile_fy_closing(cr, uid, ids, context=None):
""" """
This private function manually do the reconciliation on the account_move_line given as `ids´, and directly This private function manually do the reconciliation on the account_move_line given as `ids´, and directly
through psql. It's necessary to do it this way because the usual `reconcile()´ function on account.move.line through psql. It's necessary to do it this way because the usual `reconcile()´ function on account.move.line
object is really resource greedy (not supposed to work on reconciliation between thousands of records) and object is really resource greedy (not supposed to work on reconciliation between thousands of records) and
it does a lot of different computation that are useless in this particular case. it does a lot of different computation that are useless in this particular case.
""" """
#check that the reconcilation concern journal entries from only one company #check that the reconcilation concern journal entries from only one company
@ -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 were not found.')) raise osv.except_osv(_('UserError!'), _('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)
@ -100,7 +100,7 @@ class account_fiscalyear_close(osv.osv_memory):
_('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(_('UserError!'),
_('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
move_ids = obj_acc_move.search(cr, uid, [ move_ids = obj_acc_move.search(cr, uid, [

View File

@ -108,7 +108,7 @@ class account_invoice_refund(osv.osv_memory):
if inv.state in ['draft', 'proforma2', 'cancel']: if inv.state in ['draft', 'proforma2', 'cancel']:
raise osv.except_osv(_('Error !'), _('Cannot %s draft/proforma/cancel invoice.') % (mode)) raise osv.except_osv(_('Error !'), _('Cannot %s draft/proforma/cancel invoice.') % (mode))
if inv.reconciled and mode in ('cancel', 'modify'): if inv.reconciled and mode in ('cancel', 'modify'):
raise osv.except_osv(_('Error !'), _('Cannot %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice.') % (mode)) raise osv.except_osv(_('Error !'), _('Cannot %s invoice which is already reconciled, invoice should be unreconciled first. You can only refund this invoice.') % (mode))
if form.period.id: if form.period.id:
period = form.period.id period = form.period.id
else: else:
@ -144,7 +144,7 @@ class account_invoice_refund(osv.osv_memory):
if not period: if not period:
raise osv.except_osv(_('Data Insufficient !'), \ raise osv.except_osv(_('Data Insufficient !'), \
_('No Period is found on Invoice!')) _('No period found on the invoice.'))
refund_id = inv_obj.refund(cr, uid, [inv.id], date, period, description, journal_id) refund_id = inv_obj.refund(cr, uid, [inv.id], date, period, description, journal_id)
refund = inv_obj.browse(cr, uid, refund_id[0], context=context) refund = inv_obj.browse(cr, uid, refund_id[0], context=context)

View File

@ -41,7 +41,7 @@ class account_invoice_confirm(osv.osv_memory):
for record in data_inv: for record in data_inv:
if record['state'] not in ('draft','proforma','proforma2'): if record['state'] not in ('draft','proforma','proforma2'):
raise osv.except_osv(_('Warning!'), _("Selected Invoice(s) cannot be confirmed as they are not in 'Draft' or 'Pro-Forma' state!")) raise osv.except_osv(_('Warning!'), _("Selected invoice(s) cannot be confirmed as they are not in 'Draft' or 'Pro-Forma' state."))
wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_open', cr) wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_open', cr)
return {'type': 'ir.actions.act_window_close'} return {'type': 'ir.actions.act_window_close'}
@ -65,7 +65,7 @@ class account_invoice_cancel(osv.osv_memory):
for record in data_inv: for record in data_inv:
if record['state'] in ('cancel','paid'): if record['state'] in ('cancel','paid'):
raise osv.except_osv(_('Warning!'), _("Selected Invoice(s) cannot be cancelled as they are already in 'Cancelled' or 'Done' state!")) raise osv.except_osv(_('Warning!'), _("Selected invoice(s) cannot be cancelled as they are already in 'Cancelled' or 'Done' state."))
wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_cancel', cr) wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_cancel', cr)
return {'type': 'ir.actions.act_window_close'} return {'type': 'ir.actions.act_window_close'}

View File

@ -83,25 +83,25 @@ class account_move_journal(osv.osv_memory):
if context: if context:
if not view_id: if not view_id:
return res return res
period_pool = self.pool.get('account.period') period_pool = self.pool.get('account.period')
journal_pool = self.pool.get('account.journal') journal_pool = self.pool.get('account.journal')
journal_id = self._get_journal(cr, uid, context) journal_id = self._get_journal(cr, uid, context)
period_id = self._get_period(cr, uid, context) period_id = self._get_period(cr, uid, context)
journal = False journal = False
if journal_id: if journal_id:
journal = journal_pool.read(cr, uid, [journal_id], ['name'])[0]['name'] journal = journal_pool.read(cr, uid, [journal_id], ['name'])[0]['name']
journal_string = _("Journal: %s") % tools.ustr(journal) journal_string = _("Journal: %s") % tools.ustr(journal)
else: else:
journal_string = _("Journal: All") journal_string = _("Journal: All")
period = False period = False
if period_id: if period_id:
period = period_pool.browse(cr, uid, [period_id], ['name'])[0]['name'] period = period_pool.browse(cr, uid, [period_id], ['name'])[0]['name']
period_string = _("Period: %s") % tools.ustr(period) period_string = _("Period: %s") % tools.ustr(period)
open_string = _("Open") open_string = _("Open")
view = """<?xml version="1.0" encoding="utf-8"?> view = """<?xml version="1.0" encoding="utf-8"?>
<form string="Standard entries" version="7.0"> <form string="Standard entries" version="7.0">
@ -116,7 +116,7 @@ class account_move_journal(osv.osv_memory):
<button string="Cancel" class="oe_link" special="cancel"/> <button string="Cancel" class="oe_link" special="cancel"/>
</footer> </footer>
</form>""" % (_('Journal'), journal_string, _('Period'), period_string, open_string) </form>""" % (_('Journal'), journal_string, _('Period'), period_string, open_string)
view = etree.fromstring(view.encode('utf8')) view = etree.fromstring(view.encode('utf8'))
xarch, xfields = self._view_look_dom_arch(cr, uid, view, view_id, context=context) xarch, xfields = self._view_look_dom_arch(cr, uid, view, view_id, context=context)
view = xarch view = xarch
@ -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(_('UserError!'), _('This period is already closed.'))
company = period.company_id.id company = period.company_id.id
res = { res = {

View File

@ -36,7 +36,7 @@ class account_open_closed_fiscalyear(osv.osv_memory):
data = self.browse(cr, uid, ids, context=context)[0] data = self.browse(cr, uid, ids, context=context)[0]
period_journal = data.fyear_id.end_journal_period_id or False period_journal = data.fyear_id.end_journal_period_id or False
if not period_journal: if not period_journal:
raise osv.except_osv(_('Error !'), _('Please define End of year journal for the fiscal year.')) raise osv.except_osv(_('Error !'), _('You have to set the end of the fiscal year for this journal.'))
ids_move = move_obj.search(cr, uid, [('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)]) ids_move = move_obj.search(cr, uid, [('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
if ids_move: if ids_move:

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 enter a period length greater than 0 !')) raise osv.except_osv(_('UserError!'), _('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!'), _('Enter a Start date !')) raise osv.except_osv(_('UserError!'), _('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

@ -150,7 +150,7 @@ class account_common_report(osv.osv_memory):
return result return result
def _print_report(self, cr, uid, ids, data, context=None): def _print_report(self, cr, uid, ids, data, context=None):
raise (_('Error!'), _('Not implemented!')) raise (_('Error!'), _('Not implemented.'))
def check_report(self, cr, uid, ids, context=None): def check_report(self, cr, uid, ids, context=None):
if context is None: if context is None:

View File

@ -36,7 +36,7 @@ class validate_account_move(osv.osv_memory):
data = self.browse(cr, uid, ids, context=context)[0] data = self.browse(cr, uid, ids, context=context)[0]
ids_move = obj_move.search(cr, uid, [('state','=','draft'),('journal_id','=',data.journal_id.id),('period_id','=',data.period_id.id)]) ids_move = obj_move.search(cr, uid, [('state','=','draft'),('journal_id','=',data.journal_id.id),('period_id','=',data.period_id.id)])
if not ids_move: if not ids_move:
raise osv.except_osv(_('Warning!'), _('Specified Journal does not have any account move entries in draft state for this period.')) raise osv.except_osv(_('Warning!'), _('Specified journal does not have any account move entries in draft state for this period.'))
obj_move.button_validate(cr, uid, ids_move, context=context) obj_move.button_validate(cr, uid, ids_move, context=context)
return {'type': 'ir.actions.act_window_close'} return {'type': 'ir.actions.act_window_close'}
@ -58,7 +58,7 @@ class validate_account_move_lines(osv.osv_memory):
move_ids.append(line.move_id.id) move_ids.append(line.move_id.id)
move_ids = list(set(move_ids)) move_ids = list(set(move_ids))
if not move_ids: if not move_ids:
raise osv.except_osv(_('Warning'), _('Selected Entry Lines does not have any account move enties in draft state')) raise osv.except_osv(_('Warning'), _('Selected Entry Lines does not have any account move enties in draft state.'))
obj_move.button_validate(cr, uid, move_ids, context) obj_move.button_validate(cr, uid, move_ids, context)
return {'type': 'ir.actions.act_window_close'} return {'type': 'ir.actions.act_window_close'}
validate_account_move_lines() validate_account_move_lines()

View File

@ -218,7 +218,7 @@ class account_analytic_plan_instance(osv.osv):
pids = ana_plan_instance_obj.search(cr, uid, [('name','=',vals['name']), ('code','=',vals['code']), ('plan_id','<>',False)], context=context) pids = ana_plan_instance_obj.search(cr, uid, [('name','=',vals['name']), ('code','=',vals['code']), ('plan_id','<>',False)], context=context)
if pids: if pids:
raise osv.except_osv(_('Error!'), _('A model having this name and code already exists !')) raise osv.except_osv(_('Error!'), _('A model with this name and code already exists.'))
res = acct_anal_plan_line_obj.search(cr, uid, [('plan_id','=',journal.plan_id.id)], context=context) res = acct_anal_plan_line_obj.search(cr, uid, [('plan_id','=',journal.plan_id.id)], context=context)
for i in res: for i in res:

View File

@ -58,7 +58,7 @@ class account_crossovered_analytic(osv.osv_memory):
flag = False flag = False
break break
if flag: if flag:
raise osv.except_osv(_('User Error!'),_('There are no Analytic lines related to Account %s.' % name)) raise osv.except_osv(_('User Error!'),_('There are no analytic lines related to account %s.' % name))
datas = { datas = {
'ids': [], 'ids': [],

View File

@ -38,7 +38,7 @@ class analytic_plan_create_model(osv.osv_memory):
raise osv.except_osv(_('Error!'), _('Please put a name and a code before saving the model.')) raise osv.except_osv(_('Error!'), _('Please put a name and a code before saving the model.'))
pids = anlytic_plan_obj.search(cr, uid, [], context=context) pids = anlytic_plan_obj.search(cr, uid, [], context=context)
if not pids: if not pids:
raise osv.except_osv(_('Error!'), _('Please define analytic plan.')) raise osv.except_osv(_('Error!'), _('There is no analytic plan defined.'))
plan_obj.write(cr, uid, [context['active_id']], {'plan_id':pids[0]}, context=context) plan_obj.write(cr, uid, [context['active_id']], {'plan_id':pids[0]}, context=context)
model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'),('name', '=', 'view_analytic_plan_create_model')], context=context) model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'),('name', '=', 'view_analytic_plan_create_model')], context=context)
@ -57,4 +57,4 @@ class analytic_plan_create_model(osv.osv_memory):
analytic_plan_create_model() analytic_plan_create_model()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -34,7 +34,7 @@ class account_bank_statement(osv.osv):
# bypass obsolete statement line resequencing # bypass obsolete statement line resequencing
if vals.get('line_ids', False) or context.get('ebanking_import', False): if vals.get('line_ids', False) or context.get('ebanking_import', False):
res = super(osv.osv, self).write(cr, uid, ids, vals, context=context) res = super(osv.osv, self).write(cr, uid, ids, vals, context=context)
else: else:
res = super(account_bank_statement, self).write(cr, uid, ids, vals, context=context) res = super(account_bank_statement, self).write(cr, uid, ids, vals, context=context)
return res return res
@ -70,7 +70,7 @@ class account_bank_statement_line_global(osv.osv):
'type': fields.selection([ 'type': fields.selection([
('iso20022', 'ISO 20022'), ('iso20022', 'ISO 20022'),
('coda', 'CODA'), ('coda', 'CODA'),
('manual', 'Manual'), ('manual', 'Manual'),
], 'Type', required=True), ], 'Type', required=True),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')), 'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
'bank_statement_line_ids': fields.one2many('account.bank.statement.line', 'globalisation_id', 'Bank Statement Lines'), 'bank_statement_line_ids': fields.one2many('account.bank.statement.line', 'globalisation_id', 'Bank Statement Lines'),
@ -108,12 +108,12 @@ class account_bank_statement_line(osv.osv):
'date': fields.date('Entry Date', required=True, states={'confirm': [('readonly', True)]}), 'date': fields.date('Entry Date', required=True, states={'confirm': [('readonly', True)]}),
'val_date': fields.date('Valuta Date', states={'confirm': [('readonly', True)]}), 'val_date': fields.date('Valuta Date', states={'confirm': [('readonly', True)]}),
'globalisation_id': fields.many2one('account.bank.statement.line.global', 'Globalisation ID', 'globalisation_id': fields.many2one('account.bank.statement.line.global', 'Globalisation ID',
states={'confirm': [('readonly', True)]}, states={'confirm': [('readonly', True)]},
help="Code to identify transactions belonging to the same globalisation level within a batch payment"), help="Code to identify transactions belonging to the same globalisation level within a batch payment"),
'globalisation_amount': fields.related('globalisation_id', 'amount', type='float', 'globalisation_amount': fields.related('globalisation_id', 'amount', type='float',
relation='account.bank.statement.line.global', string='Glob. Amount', readonly=True), relation='account.bank.statement.line.global', string='Glob. Amount', readonly=True),
'state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed')], 'state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed')],
'Status', required=True, readonly=True), 'Status', required=True, readonly=True),
'counterparty_name': fields.char('Counterparty Name', size=35), 'counterparty_name': fields.char('Counterparty Name', size=35),
'counterparty_bic': fields.char('Counterparty BIC', size=11), 'counterparty_bic': fields.char('Counterparty BIC', size=11),
'counterparty_number': fields.char('Counterparty Number', size=34), 'counterparty_number': fields.char('Counterparty Number', size=34),
@ -127,7 +127,7 @@ class account_bank_statement_line(osv.osv):
if context is None: if context is None:
context = {} context = {}
if context.get('block_statement_line_delete', False): if context.get('block_statement_line_delete', False):
raise osv.except_osv(_('Warning!'), _('Delete operation not allowed ! \ raise osv.except_osv(_('Warning!'), _('Delete operation not allowed. \
Please go to the associated bank statement in order to delete and/or modify bank statement line.')) Please go to the associated bank statement in order to delete and/or modify bank statement line.'))
return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context) return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context)

View File

@ -2,9 +2,9 @@
############################################################################## ##############################################################################
# #
# OpenERP, Open Source Management Solution # OpenERP, Open Source Management Solution
# #
# Copyright (c) 2011 Noviat nv/sa (www.noviat.be). All rights reserved. # Copyright (c) 2011 Noviat nv/sa (www.noviat.be). All rights reserved.
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the # published by the Free Software Foundation, either version 3 of the
@ -36,7 +36,7 @@ class coda_bank_account(osv.osv):
_columns = { _columns = {
'name': fields.char('Name', size=64, required=True), 'name': fields.char('Name', size=64, required=True),
'bank_id': fields.many2one('res.partner.bank', 'Bank Account', required=True, 'bank_id': fields.many2one('res.partner.bank', 'Bank Account', required=True,
help='Bank Account Number.\nThe CODA import function will find its CODA processing parameters on this number.'), help='Bank Account Number.\nThe CODA import function will find its CODA processing parameters on this number.'),
'description1': fields.char('Primary Account Description', size=35, 'description1': fields.char('Primary Account Description', size=35,
help='The Primary or Secondary Account Description should match the corresponding Account Description in the CODA file.'), help='The Primary or Secondary Account Description should match the corresponding Account Description in the CODA file.'),
@ -44,18 +44,18 @@ class coda_bank_account(osv.osv):
help='The Primary or Secondary Account Description should match the corresponding Account Description in the CODA file.'), help='The Primary or Secondary Account Description should match the corresponding Account Description in the CODA file.'),
'state': fields.selection([ 'state': fields.selection([
('normal', 'Normal'), ('normal', 'Normal'),
('info', 'Info')], ('info', 'Info')],
'Type', required=True, select=1, 'Type', required=True, select=1,
help='No Bank Statements will be generated for CODA Bank Statements from Bank Accounts of type \'Info\'.'), help='No Bank Statements will be generated for CODA Bank Statements from Bank Accounts of type \'Info\'.'),
'journal': fields.many2one('account.journal', 'Journal', 'journal': fields.many2one('account.journal', 'Journal',
domain=[('type', '=', 'bank')], domain=[('type', '=', 'bank')],
states={'normal':[('required',True)],'info':[('required',False)]}, states={'normal':[('required',True)],'info':[('required',False)]},
help='Bank Journal for the Bank Statement'), help='Bank Journal for the Bank Statement'),
'currency': fields.many2one('res.currency', 'Currency', required=True, 'currency': fields.many2one('res.currency', 'Currency', required=True,
help='The currency of the CODA Bank Statement'), help='The currency of the CODA Bank Statement'),
'coda_st_naming': fields.char('Bank Statement Naming Policy', size=64, 'coda_st_naming': fields.char('Bank Statement Naming Policy', size=64,
help="Define the rules to create the name of the Bank Statements generated by the CODA processing." \ help="Define the rules to create the name of the Bank Statements generated by the CODA processing." \
"\nE.g. %(code)s%(y)s/%(paper)s" "\nE.g. %(code)s%(y)s/%(paper)s"
"\n\nVariables:" \ "\n\nVariables:" \
"\nBank Journal Code: %(code)s" \ "\nBank Journal Code: %(code)s" \
"\nCurrent Year with Century: %(year)s" \ "\nCurrent Year with Century: %(year)s" \
@ -79,9 +79,9 @@ class coda_bank_account(osv.osv):
'currency': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id, 'currency': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
'state': 'normal', 'state': 'normal',
'coda_st_naming': '%(code)s/%(y)s/%(coda)s', 'coda_st_naming': '%(code)s/%(y)s/%(coda)s',
'active': True, 'active': True,
'find_bbacom': True, 'find_bbacom': True,
'find_partner': True, 'find_partner': True,
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
} }
_sql_constraints = [ _sql_constraints = [
@ -107,12 +107,12 @@ class coda_bank_account(osv.osv):
if not default: if not default:
default = {} default = {}
default = default.copy() default = default.copy()
default.update({'journal_id': None}) default.update({'journal_id': None})
default['description1'] = cba['description1'] or '' default['description1'] = cba['description1'] or ''
default['description2'] = cba['description2'] or '' default['description2'] = cba['description2'] or ''
default['name'] = (cba['name'] or '') + ' (copy)' default['name'] = (cba['name'] or '') + ' (copy)'
default['state'] = cba['state'] default['state'] = cba['state']
return super(coda_bank_account, self).copy(cr, uid, id, default, context) return super(coda_bank_account, self).copy(cr, uid, id, default, context)
def onchange_state(self, cr, uid, ids, state): def onchange_state(self, cr, uid, ids, state):
return state =='info' and {'value': {'journal': None}} or {} return state =='info' and {'value': {'journal': None}} or {}
@ -137,10 +137,10 @@ class account_coda(osv.osv):
'date': fields.date.context_today, 'date': fields.date.context_today,
'user_id': lambda self,cr,uid,context: uid, 'user_id': lambda self,cr,uid,context: uid,
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.coda', context=c), 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.coda', context=c),
} }
_sql_constraints = [ _sql_constraints = [
('coda_uniq', 'unique (name, coda_creation_date)', 'This CODA has already been imported !') ('coda_uniq', 'unique (name, coda_creation_date)', 'This CODA has already been imported !')
] ]
def unlink(self, cr, uid, ids, context=None): def unlink(self, cr, uid, ids, context=None):
if context is None: if context is None:
@ -149,22 +149,22 @@ class account_coda(osv.osv):
coda_st_obj = self.pool.get('coda.bank.statement') coda_st_obj = self.pool.get('coda.bank.statement')
bank_st_obj = self.pool.get('account.bank.statement') bank_st_obj = self.pool.get('account.bank.statement')
for coda in self.browse(cr, uid, ids, context=context): for coda in self.browse(cr, uid, ids, context=context):
for coda_statement in coda.statement_ids: for coda_statement in coda.statement_ids:
if not context.get('coda_statement_unlink', False): if not context.get('coda_statement_unlink', False):
if coda_st_obj.exists(cr, uid, coda_statement.id, context=context): if coda_st_obj.exists(cr, uid, coda_statement.id, context=context):
coda_st_obj.unlink(cr, uid, [coda_statement.id], context=context) coda_st_obj.unlink(cr, uid, [coda_statement.id], context=context)
if not context.get('bank_statement_unlink', False): if not context.get('bank_statement_unlink', False):
if coda_st_obj.exists(cr, uid, coda_statement.id, context=context) and (coda_statement.type == 'normal') and bank_st_obj.exists(cr, uid, coda_statement.statement_id.id, context=context): if coda_st_obj.exists(cr, uid, coda_statement.id, context=context) and (coda_statement.type == 'normal') and bank_st_obj.exists(cr, uid, coda_statement.statement_id.id, context=context):
bank_st_obj.unlink(cr, uid, [coda_statement.statement_id.id], context=context) bank_st_obj.unlink(cr, uid, [coda_statement.statement_id.id], context=context)
context.update({'coda_unlink': False}) context.update({'coda_unlink': False})
return super(account_coda, self).unlink(cr, uid, ids, context=context) return super(account_coda, self).unlink(cr, uid, ids, context=context)
account_coda() account_coda()
class account_coda_trans_type(osv.osv): class account_coda_trans_type(osv.osv):
_name = 'account.coda.trans.type' _name = 'account.coda.trans.type'
_description = 'CODA transaction type' _description = 'CODA transaction type'
_rec_name = 'type' _rec_name = 'type'
_columns = { _columns = {
'type': fields.char('Transaction Type', size=1, required=True), 'type': fields.char('Transaction Type', size=1, required=True),
'parent_id': fields.many2one('account.coda.trans.type', 'Parent'), 'parent_id': fields.many2one('account.coda.trans.type', 'Parent'),
@ -172,36 +172,36 @@ class account_coda_trans_type(osv.osv):
} }
account_coda_trans_type() account_coda_trans_type()
class account_coda_trans_code(osv.osv): class account_coda_trans_code(osv.osv):
_name = 'account.coda.trans.code' _name = 'account.coda.trans.code'
_description = 'CODA transaction code' _description = 'CODA transaction code'
_rec_name = 'code' _rec_name = 'code'
_columns = { _columns = {
'code': fields.char('Code', size=2, required=True, select=1), 'code': fields.char('Code', size=2, required=True, select=1),
'type': fields.selection([ 'type': fields.selection([
('code', 'Transaction Code'), ('code', 'Transaction Code'),
('family', 'Transaction Family')], ('family', 'Transaction Family')],
'Type', required=True, select=1), 'Type', required=True, select=1),
'parent_id': fields.many2one('account.coda.trans.code', 'Family', select=1), 'parent_id': fields.many2one('account.coda.trans.code', 'Family', select=1),
'description': fields.char('Description', size=128, translate=True, select=2), 'description': fields.char('Description', size=128, translate=True, select=2),
'comment': fields.text('Comment', translate=True), 'comment': fields.text('Comment', translate=True),
} }
account_coda_trans_code() account_coda_trans_code()
class account_coda_trans_category(osv.osv): class account_coda_trans_category(osv.osv):
_name = 'account.coda.trans.category' _name = 'account.coda.trans.category'
_description = 'CODA transaction category' _description = 'CODA transaction category'
_rec_name = 'category' _rec_name = 'category'
_columns = { _columns = {
'category': fields.char('Transaction Category', size=3, required=True), 'category': fields.char('Transaction Category', size=3, required=True),
'description': fields.char('Description', size=256, translate=True), 'description': fields.char('Description', size=256, translate=True),
} }
account_coda_trans_category() account_coda_trans_category()
class account_coda_comm_type(osv.osv): class account_coda_comm_type(osv.osv):
_name = 'account.coda.comm.type' _name = 'account.coda.comm.type'
_description = 'CODA structured communication type' _description = 'CODA structured communication type'
_rec_name = 'code' _rec_name = 'code'
_columns = { _columns = {
'code': fields.char('Structured Communication Type', size=3, required=True, select=1), 'code': fields.char('Structured Communication Type', size=3, required=True, select=1),
'description': fields.char('Description', size=128, translate=True), 'description': fields.char('Description', size=128, translate=True),
@ -212,9 +212,9 @@ class account_coda_comm_type(osv.osv):
account_coda_comm_type() account_coda_comm_type()
class coda_bank_statement(osv.osv): class coda_bank_statement(osv.osv):
_name = 'coda.bank.statement' _name = 'coda.bank.statement'
_description = 'CODA Bank Statement' _description = 'CODA Bank Statement'
def _default_journal_id(self, cr, uid, context={}): def _default_journal_id(self, cr, uid, context={}):
if context.get('journal_id', False): if context.get('journal_id', False):
return context['journal_id'] return context['journal_id']
@ -245,16 +245,16 @@ class coda_bank_statement(osv.osv):
'coda_id': fields.many2one('account.coda', 'CODA Data File', ondelete='cascade'), 'coda_id': fields.many2one('account.coda', 'CODA Data File', ondelete='cascade'),
'type': fields.selection([ 'type': fields.selection([
('normal', 'Normal'), ('normal', 'Normal'),
('info', 'Info')], ('info', 'Info')],
'Type', required=True, readonly=True, 'Type', required=True, readonly=True,
help='No Bank Statements are associated with CODA Bank Statements of type \'Info\'.'), help='No Bank Statements are associated with CODA Bank Statements of type \'Info\'.'),
'statement_id': fields.many2one('account.bank.statement', 'Associated Bank Statement'), 'statement_id': fields.many2one('account.bank.statement', 'Associated Bank Statement'),
'journal_id': fields.many2one('account.journal', 'Journal', readonly=True, domain=[('type', '=', 'bank')]), 'journal_id': fields.many2one('account.journal', 'Journal', readonly=True, domain=[('type', '=', 'bank')]),
'coda_bank_account_id': fields.many2one('coda.bank.account', 'Bank Account', readonly=True), 'coda_bank_account_id': fields.many2one('coda.bank.account', 'Bank Account', readonly=True),
'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True), 'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True),
'balance_start': fields.float('Starting Balance', digits_compute=dp.get_precision('Account'), readonly=True), 'balance_start': fields.float('Starting Balance', digits_compute=dp.get_precision('Account'), readonly=True),
'balance_end_real': fields.float('Ending Balance', digits_compute=dp.get_precision('Account'), readonly=True), 'balance_end_real': fields.float('Ending Balance', digits_compute=dp.get_precision('Account'), readonly=True),
'balance_end': fields.function(_end_balance, method=True, store=True, string='Balance'), 'balance_end': fields.function(_end_balance, method=True, store=True, string='Balance'),
'line_ids': fields.one2many('coda.bank.statement.line', 'line_ids': fields.one2many('coda.bank.statement.line',
'statement_id', 'CODA Bank Statement lines', readonly=True), 'statement_id', 'CODA Bank Statement lines', readonly=True),
'currency': fields.many2one('res.currency', 'Currency', required=True, readonly=True, 'currency': fields.many2one('res.currency', 'Currency', required=True, readonly=True,
@ -262,14 +262,14 @@ class coda_bank_statement(osv.osv):
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), 'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
} }
_defaults = { _defaults = {
'type': 'normal', 'type': 'normal',
'currency': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id, 'currency': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
'journal_id': _default_journal_id, 'journal_id': _default_journal_id,
'period_id': _get_period, 'period_id': _get_period,
} }
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
if context is None: if context is None:
context = {} context = {}
res = super(coda_bank_statement, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order, res = super(coda_bank_statement, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order,
context=context, count=count) context=context, count=count)
@ -283,16 +283,16 @@ class coda_bank_statement(osv.osv):
context.update({'coda_statement_unlink': True}) context.update({'coda_statement_unlink': True})
coda_obj = self.pool.get('account.coda') coda_obj = self.pool.get('account.coda')
bank_st_obj = self.pool.get('account.bank.statement') bank_st_obj = self.pool.get('account.bank.statement')
# find all CODA bank statements that are associated with the selected CODA bank statements via a common CODA file # find all CODA bank statements that are associated with the selected CODA bank statements via a common CODA file
new_ids = [] new_ids = []
for coda_statement in self.browse(cr, uid, ids, context=context): for coda_statement in self.browse(cr, uid, ids, context=context):
if coda_obj.exists(cr, uid, coda_statement.coda_id.id, context=context): if coda_obj.exists(cr, uid, coda_statement.coda_id.id, context=context):
new_ids += [x.id for x in coda_obj.browse(cr, uid, coda_statement.coda_id.id, context=context).statement_ids] new_ids += [x.id for x in coda_obj.browse(cr, uid, coda_statement.coda_id.id, context=context).statement_ids]
# 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 !" \
@ -304,11 +304,11 @@ class coda_bank_statement(osv.osv):
coda_obj.unlink(cr, uid, [coda_statement.coda_id.id], context=context) coda_obj.unlink(cr, uid, [coda_statement.coda_id.id], context=context)
if not context.get('bank_statement_unlink', False): if not context.get('bank_statement_unlink', False):
if coda_statement.statement_id and bank_st_obj.exists(cr, uid, coda_statement.statement_id.id, context=context): if coda_statement.statement_id and bank_st_obj.exists(cr, uid, coda_statement.statement_id.id, context=context):
bank_st_obj.unlink(cr, uid, [coda_statement.statement_id.id], context=context) bank_st_obj.unlink(cr, uid, [coda_statement.statement_id.id], context=context)
context.update({'coda_statement_unlink': False}) context.update({'coda_statement_unlink': False})
return super(coda_bank_statement, self).unlink(cr, uid, new_ids, context=context) return super(coda_bank_statement, self).unlink(cr, uid, new_ids, context=context)
coda_bank_statement() coda_bank_statement()
class account_bank_statement(osv.osv): class account_bank_statement(osv.osv):
@ -316,7 +316,7 @@ class account_bank_statement(osv.osv):
_columns = { _columns = {
'coda_statement_id': fields.many2one('coda.bank.statement', 'Associated CODA Bank Statement'), 'coda_statement_id': fields.many2one('coda.bank.statement', 'Associated CODA Bank Statement'),
} }
def unlink(self, cr, uid, ids, context=None): def unlink(self, cr, uid, ids, context=None):
if context is None: if context is None:
context = {} context = {}
@ -325,15 +325,15 @@ class account_bank_statement(osv.osv):
coda_st_obj = self.pool.get('coda.bank.statement') coda_st_obj = self.pool.get('coda.bank.statement')
# find all statements that are associated with the selected bank statements via a common CODA file # find all statements that are associated with the selected bank statements via a common CODA file
ids_plus = [] ids_plus = []
for statement in self.browse(cr, uid, ids, context=context): for statement in self.browse(cr, uid, ids, context=context):
if statement.coda_statement_id: if statement.coda_statement_id:
for x in coda_obj.browse(cr, uid, statement.coda_statement_id.coda_id.id, context=context).statement_ids: for x in coda_obj.browse(cr, uid, statement.coda_statement_id.coda_id.id, context=context).statement_ids:
if x.type == 'normal': if x.type == 'normal':
ids_plus += [x.statement_id.id] ids_plus += [x.statement_id.id]
# unlink banks statements as well as associated CODA bank statements and CODA files # unlink banks statements as well as associated CODA bank statements and CODA files
for statement in self.browse(cr, uid, ids_plus, context=context): for statement in self.browse(cr, uid, ids_plus, context=context):
if not context.get('coda_statement_unlink', False): if not context.get('coda_statement_unlink', False):
if statement.coda_statement_id and coda_st_obj.exists(cr, uid, statement.coda_statement_id.id, context=context): if statement.coda_statement_id and coda_st_obj.exists(cr, uid, statement.coda_statement_id.id, context=context):
coda_st_obj.unlink(cr, uid, [statement.coda_statement_id.id], context=context) coda_st_obj.unlink(cr, uid, [statement.coda_statement_id.id], context=context)
@ -347,56 +347,56 @@ class account_bank_statement(osv.osv):
context.update({'bank_statement_unlink': False}) context.update({'bank_statement_unlink': False})
new_ids = list(set(ids + ids_plus)) new_ids = list(set(ids + ids_plus))
return super(account_bank_statement, self).unlink(cr, uid, new_ids, context=context) return super(account_bank_statement, self).unlink(cr, uid, new_ids, context=context)
account_bank_statement() account_bank_statement()
class coda_bank_statement_line(osv.osv): class coda_bank_statement_line(osv.osv):
_name = 'coda.bank.statement.line' _name = 'coda.bank.statement.line'
_order = 'sequence' _order = 'sequence'
_description = 'CODA Bank Statement Line' _description = 'CODA Bank Statement Line'
_columns = { _columns = {
'name': fields.char('Communication', size=268, required=True), 'name': fields.char('Communication', size=268, required=True),
'sequence': fields.integer('Sequence'), 'sequence': fields.integer('Sequence'),
'date': fields.date('Entry Date', required=True), 'date': fields.date('Entry Date', required=True),
'val_date': fields.date('Valuta Date'), 'val_date': fields.date('Valuta Date'),
'account_id': fields.many2one('account.account','Account'), # remove required=True 'account_id': fields.many2one('account.account','Account'), # remove required=True
'type': fields.selection([ 'type': fields.selection([
('supplier','Supplier'), ('supplier','Supplier'),
('customer','Customer'), ('customer','Customer'),
('general','General'), ('general','General'),
('globalisation','Globalisation'), ('globalisation','Globalisation'),
('information','Information'), ('information','Information'),
('communication','Free Communication'), ('communication','Free Communication'),
], 'Type', required=True), ], 'Type', required=True),
'globalisation_level': fields.integer('Globalisation Level', 'globalisation_level': fields.integer('Globalisation Level',
help="The value which is mentioned (1 to 9), specifies the hierarchy level" help="The value which is mentioned (1 to 9), specifies the hierarchy level"
" of the globalisation of which this record is the first." " of the globalisation of which this record is the first."
"\nThe same code will be repeated at the end of the globalisation."), "\nThe same code will be repeated at the end of the globalisation."),
'globalisation_amount': fields.float('Globalisation Amount', digits_compute=dp.get_precision('Account')), 'globalisation_amount': fields.float('Globalisation Amount', digits_compute=dp.get_precision('Account')),
'globalisation_id': fields.many2one('account.bank.statement.line.global', 'Globalisation ID', readonly=True, 'globalisation_id': fields.many2one('account.bank.statement.line.global', 'Globalisation ID', readonly=True,
help="Code to identify transactions belonging to the same globalisation level within a batch payment"), help="Code to identify transactions belonging to the same globalisation level within a batch payment"),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')), 'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
'partner_id': fields.many2one('res.partner', 'Partner'), 'partner_id': fields.many2one('res.partner', 'Partner'),
'counterparty_name': fields.char('Counterparty Name', size=35), 'counterparty_name': fields.char('Counterparty Name', size=35),
'counterparty_bic': fields.char('Counterparty BIC', size=11), 'counterparty_bic': fields.char('Counterparty BIC', size=11),
'counterparty_number': fields.char('Counterparty Number', size=34), 'counterparty_number': fields.char('Counterparty Number', size=34),
'counterparty_currency': fields.char('Counterparty Currency', size=3), 'counterparty_currency': fields.char('Counterparty Currency', size=3),
'statement_id': fields.many2one('coda.bank.statement', 'CODA Bank Statement', 'statement_id': fields.many2one('coda.bank.statement', 'CODA Bank Statement',
select=True, required=True, ondelete='cascade'), select=True, required=True, ondelete='cascade'),
'coda_bank_account_id': fields.related('statement_id', 'coda_bank_account_id', type='many2one', relation='coda.bank.account', string='Bank Account', store=True, readonly=True), 'coda_bank_account_id': fields.related('statement_id', 'coda_bank_account_id', type='many2one', relation='coda.bank.account', string='Bank Account', store=True, readonly=True),
'ref': fields.char('Reference', size=32), 'ref': fields.char('Reference', size=32),
'note': fields.text('Notes'), 'note': fields.text('Notes'),
'company_id': fields.related('statement_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), 'company_id': fields.related('statement_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
} }
def unlink(self, cr, uid, ids, context=None): def unlink(self, cr, uid, ids, context=None):
if context is None: if context is None:
context = {} context = {}
if context.get('block_statement_line_delete', False): if context.get('block_statement_line_delete', False):
raise osv.except_osv('Warning', _('Delete operation not allowed !')) raise osv.except_osv('Warning', _('Delete operation not allowed.'))
return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context) return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context)
coda_bank_statement_line() coda_bank_statement_line()
class account_bank_statement_line_global(osv.osv): class account_bank_statement_line_global(osv.osv):
_inherit = 'account.bank.statement.line.global' _inherit = 'account.bank.statement.line.global'

View File

@ -107,7 +107,7 @@ class account_move_line(osv.osv):
if line.id not in line2bank and line.partner_id.bank_ids: if line.id not in line2bank and line.partner_id.bank_ids:
line2bank[line.id] = line.partner_id.bank_ids[0].id line2bank[line.id] = line.partner_id.bank_ids[0].id
else: else:
raise osv.except_osv(_('Error !'), _('No partner is defined on entry line.')) raise osv.except_osv(_('Error !'), _('There is no partner defined on the entry line.'))
return line2bank return line2bank
_columns = { _columns = {

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'):
@ -952,11 +952,11 @@ class account_voucher(osv.osv):
if amount_residual > 0: if amount_residual > 0:
account_id = line.voucher_id.company_id.expense_currency_exchange_account_id account_id = line.voucher_id.company_id.expense_currency_exchange_account_id
if not account_id: if not account_id:
raise osv.except_osv(_('Warning!'),_("First configure the 'Income Currency Rate' on the company,after that create accounting entry for currency rate difference.")) raise osv.except_osv(_('Warning!'),_("First you have to configure the 'Income Currency Rate' on the company, then create accounting entry for currency rate difference."))
else: else:
account_id = line.voucher_id.company_id.income_currency_exchange_account_id account_id = line.voucher_id.company_id.income_currency_exchange_account_id
if not account_id: if not account_id:
raise osv.except_osv(_('Warning!'),_("First configure the 'Expense Currency Rate' on the company,after that create accounting entry for currency rate difference.")) raise osv.except_osv(_('Warning!'),_("First you have to configure the 'Expense Currency Rate' on the company, then create accounting entry for currency rate difference."))
# Even if the amount_currency is never filled, we need to pass the foreign currency because otherwise # Even if the amount_currency is never filled, we need to pass the foreign currency because otherwise
# the receivable/payable account may have a secondary currency, which render this field mandatory # the receivable/payable account may have a secondary currency, which render this field mandatory
account_currency_id = company_currency <> current_currency and current_currency or False account_currency_id = company_currency <> current_currency and current_currency or False