-
- 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,))