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.

59 lines
2.8 KiB

10 years ago
10 years ago
  1. # -*- coding: utf-8 -*-
  2. # © 2014-2016 Aurélien DUMAINE
  3. # © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  5. from odoo import models, fields, api, _
  6. from odoo.exceptions import ValidationError
  7. class PosConfig(models.Model):
  8. _inherit = 'pos.config'
  9. iface_customer_display = fields.Boolean(
  10. string='Customer Display', help="Display data on the customer display")
  11. customer_display_line_length = fields.Integer(
  12. string='Line Length of the Customer Display', default=20,
  13. help="Length of the LEDs lines of the customer display")
  14. customer_display_msg_next_l1 = fields.Char(
  15. string="Next Customer (top line)", default="Welcome!",
  16. help="Top line of the message on the customer display which is "
  17. "displayed after starting POS and also after validation of an order")
  18. customer_display_msg_next_l2 = fields.Char(
  19. string="Next Customer (bottom line)", default="Point of Sale Open",
  20. help="Bottom line of the message on the customer display which is "
  21. "displayed after starting POS and also after validation of an order")
  22. customer_display_msg_closed_l1 = fields.Char(
  23. string="POS Closed (top line)", default="Point of Sale Closed",
  24. help="Top line of the message on the customer display which "
  25. "is displayed when POS is closed")
  26. customer_display_msg_closed_l2 = fields.Char(
  27. string="POS Closed (bottom line)", default="See you soon!",
  28. help="Bottom line of the message on the customer display which "
  29. "is displayed when POS is closed")
  30. @api.one
  31. @api.constrains(
  32. 'customer_display_line_length',
  33. 'customer_display_msg_next_l1', 'customer_display_msg_next_l2',
  34. 'customer_display_msg_closed_l1', 'customer_display_msg_closed_l2')
  35. def _check_customer_display_length(self):
  36. if self.customer_display_line_length:
  37. maxsize = self.customer_display_line_length
  38. to_check = {
  39. _('Next Customer (top line)'):
  40. self.customer_display_msg_next_l1,
  41. _('Next Customer (bottom line)'):
  42. self.customer_display_msg_next_l2,
  43. _('POS Closed (top line)'):
  44. self.customer_display_msg_closed_l1,
  45. _('POS Closed (bottom line)'):
  46. self.customer_display_msg_closed_l2,
  47. }
  48. for field, msg in to_check.iteritems():
  49. if msg and len(msg) > maxsize:
  50. raise ValidationError(_(
  51. "The message for customer display '%s' is too "
  52. "long: it has %d chars whereas the maximum "
  53. "is %d chars.")
  54. % (field, len(msg), maxsize))