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.

49 lines
1.6 KiB

  1. # Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
  2. # @author Quentin DUPONT (quentin.dupont@grap.coop)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import api, fields, models
  5. class PosConfig(models.Model):
  6. _inherit = "pos.config"
  7. # Columns Section
  8. autosolve_pos_move_reason = fields.Many2one(
  9. string="Autosolve pos move reason",
  10. description="Product used to autosolve control difference",
  11. comodel_name="pos.move.reason",
  12. domain="['|', \
  13. ('is_income_reason', '=', True), ('is_expense_reason', '=', True)]",
  14. default="",
  15. )
  16. autosolve_limit = fields.Float(
  17. string="Autosolve limit",
  18. description="Limit for autosolving bank statement", default=20
  19. )
  20. @api.multi
  21. def open_new_session(self, openui):
  22. self.ensure_one()
  23. # Check if some opening / opened session exists
  24. session_obj = self.env['pos.session']
  25. sessions = session_obj.search([
  26. ('user_id', '=', self.env.uid),
  27. ('config_id', '=', self.id),
  28. ('state', 'in', ['opened', 'opening_control']),
  29. ], limit=1)
  30. if sessions:
  31. # An opening / opened session exists
  32. session = sessions[0]
  33. else:
  34. # Create a session
  35. session = session_obj.create({
  36. 'user_id': self.env.uid,
  37. 'config_id': self.id,
  38. })
  39. if session.state == 'opening_control' or openui is False:
  40. return self._open_session(session.id)
  41. return self.open_ui()