You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.2 KiB

  1. # Copyright 2020 ForgeFlow, S.L.
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. from odoo import api, models, _
  4. from odoo.exceptions import ValidationError
  5. class PosSession(models.Model):
  6. _inherit = "pos.session"
  7. @api.multi
  8. def button_update_statement_ending_balance(self):
  9. self.ensure_one()
  10. action = self.env.ref(
  11. "pos_statement_closing_balance."
  12. "action_pos_update_bank_statement_closing_balance")
  13. result = action.read()[0]
  14. return result
  15. @api.multi
  16. def _check_pos_session_bank_balance(self):
  17. for session in self:
  18. for statement in session.statement_ids:
  19. if statement.journal_id.pos_control_ending_balance and \
  20. (statement != session.cash_register_id) and (
  21. statement.balance_end != statement.balance_end_real):
  22. raise ValidationError(_(
  23. 'Mismatch in the closing balance '
  24. 'for a non-cash statement.'))
  25. return True
  26. @api.multi
  27. def action_pos_session_closing_control(self):
  28. self._check_pos_session_bank_balance()
  29. return super(PosSession, self).action_pos_session_closing_control()