Skip to content

Commit

Permalink
[IMP] readable code
Browse files Browse the repository at this point in the history
  • Loading branch information
fpodoo committed Aug 21, 2014
1 parent 9c175fe commit 9dc9169
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions addons/account/account_cash_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,24 +306,24 @@ def button_confirm_cash(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
if obj.difference == 0.0:
continue

for item_label, item_account in TABLES:
if not getattr(obj.journal_id, item_account):
raise osv.except_osv(_('Error!'),
_('There is no %s Account on the journal %s.') % (item_label, obj.journal_id.name,))

is_profit = obj.difference < 0.0

account = getattr(obj.journal_id, TABLES[is_profit][1])
elif obj.difference < 0.0:
account = obj.journal_id.loss_account_id
name = _('Loss')
if not obj.journal_id.loss_account_id:
raise osv.except_osv(_('Error!'), _('There is no Loss Account on the journal %s.') % (obj.journal_id.name,))
else: # obj.difference > 0.0
account = obj.journal_id.profit_account_id
name = _('Profit')
if not obj.journal_id.profit_account_id:
raise osv.except_osv(_('Error!'), _('There is no Profit Account on the journal %s.') % (obj.journal_id.name,))

values = {
'statement_id' : obj.id,
'journal_id' : obj.journal_id.id,
'account_id' : account.id,
'amount' : obj.difference,
'name' : 'Exceptional %s' % TABLES[is_profit][0],
'name' : name,
}

absl_proxy.create(cr, uid, values, context=context)

return super(account_cash_statement, self).button_confirm_bank(cr, uid, ids, context=context)
Expand Down

0 comments on commit 9dc9169

Please sign in to comment.