|
@@ -0,0 +1,41 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+import time
|
|
|
+
|
|
|
+from openerp.osv import fields, osv
|
|
|
+from openerp.tools import float_compare
|
|
|
+from openerp.tools.translate import _
|
|
|
+import openerp.addons.decimal_precision as dp
|
|
|
+
|
|
|
+class AccountBankStatement(osv.osv):
|
|
|
+ _inherit = "account.bank.statement"
|
|
|
+
|
|
|
+ def button_confirm_cash(self, cr, uid, ids, context=None):
|
|
|
+ absl_proxy = self.pool.get('account.bank.statement.line')
|
|
|
+
|
|
|
+ TABLES = ((_('Profit'), 'profit_account_id'), (_('Loss'), 'loss_account_id'),)
|
|
|
+
|
|
|
+ for obj in self.browse(cr, uid, ids, context=context):
|
|
|
+ obj.difference = 0.0
|
|
|
+ if obj.difference == 0.0:
|
|
|
+ continue
|
|
|
+ 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' : name,
|
|
|
+ }
|
|
|
+ absl_proxy.create(cr, uid, values, context=context)
|
|
|
+
|
|
|
+ return super(AccountBankStatement, self).button_confirm_bank(cr, uid, ids, context=context)
|