|
|
|
@ -115,15 +115,6 @@ class AccountBankStmtCashWizard(models.Model):
|
|
|
|
|
self._validate_cashbox()
|
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
def _check_closing(self):
|
|
|
|
|
self.ensure_one()
|
|
|
|
|
context = dict(self.env.context or {})
|
|
|
|
|
stmt = self.end_bank_stmt_ids[0]
|
|
|
|
|
difference = stmt.currency_id.round(stmt.balance_end_real - stmt.balance_end)
|
|
|
|
|
|
|
|
|
|
if difference != 0:
|
|
|
|
|
return difference
|
|
|
|
|
|
|
|
|
|
def _validate_cashbox(self):
|
|
|
|
|
for cashbox in self:
|
|
|
|
|
context = dict(self.env.context or {})
|
|
|
|
@ -137,12 +128,20 @@ class BankStatement(models.Model):
|
|
|
|
|
|
|
|
|
|
cashbox_start_id = fields.Many2one('gn_cash.account.bank.statement.cashbox', string="Starting Cashbox")
|
|
|
|
|
cashbox_end_id = fields.Many2one('gn_cash.account.bank.statement.cashbox', string="Ending Cashbox")
|
|
|
|
|
is_reconciled = fields.Boolean(compute='_compute_is_reconciled', store=True)
|
|
|
|
|
|
|
|
|
|
@api.depends('line_ids.is_reconciled')
|
|
|
|
|
def _compute_is_reconciled(self):
|
|
|
|
|
for stmt in self:
|
|
|
|
|
stmt.is_reconciled = len(stmt.line_ids.filtered(lambda l: l.is_reconciled == True)) == len(stmt.line_ids)
|
|
|
|
|
|
|
|
|
|
def _create_closing_difference_line_values(self):
|
|
|
|
|
""" Check the balance_end_real (encoded manually by the user) is equals to the balance_end (computed by odoo).
|
|
|
|
|
For a cash statement, if there is a difference, the different is set automatically to a profit/loss account.
|
|
|
|
|
"""
|
|
|
|
|
for statement in self.filtered(lambda stmt: stmt.journal_id.type == 'cash'):
|
|
|
|
|
for statement in self.filtered(lambda stmt: stmt.journal_id.type == 'cash'):
|
|
|
|
|
if not statement.is_reconciled:
|
|
|
|
|
raise UserError("you need to first reconcile all lines of statement")
|
|
|
|
|
if not statement.is_complete:
|
|
|
|
|
difference = statement.currency_id.round(statement.balance_end_real - statement.balance_end)
|
|
|
|
|
if difference != 0:
|
|
|
|
@ -204,12 +203,17 @@ class BankStatement(models.Model):
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _compute_closing_diff(self):
|
|
|
|
|
for stmt in self:
|
|
|
|
|
difference = stmt.currency_id.round(stmt.balance_end_real - stmt.balance_end)
|
|
|
|
|
if difference != 0:
|
|
|
|
|
return difference
|
|
|
|
|
|
|
|
|
|
def button_validate(self):
|
|
|
|
|
for statement in self:
|
|
|
|
|
if not statement.is_complete:
|
|
|
|
|
difference = statement.cashbox_end_id._check_closing()
|
|
|
|
|
difference = statement.currency_id.format(difference)
|
|
|
|
|
difference = statement._compute_closing_diff()
|
|
|
|
|
if difference:
|
|
|
|
|
action_id = self.env.ref('gn_cash.action_validate_cash_statement').id
|
|
|
|
|
raise RedirectWarning(
|
|
|
|
|