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.

30 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2019 Coop IT Easy SCRLfs
  3. # Vincent Van Rossem <vvrossem@gmail.com>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from odoo import models, fields, api, _
  6. from odoo.exceptions import ValidationError
  7. class PosConfig(models.Model):
  8. _inherit = 'pos.config'
  9. # TODO(Vincent) add field customer_display_currency_code or use/fetch Odoo's default currency
  10. customer_display_currency_char = fields.Char(
  11. size=1,
  12. required=True,
  13. string="User-defined Currency Character", default="$",
  14. help="The ASCII character to use for drawing the default currency symbol on the device.")
  15. @api.constrains('customer_display_currency_char')
  16. def _check_currency_char(self):
  17. """
  18. char_code can only be defined between character hex codes \x20 and \xFF
  19. (or decimal codes 32 and 255)
  20. """
  21. self.ensure_one()
  22. if not 32 <= ord(self.customer_display_currency_char) <= 255:
  23. raise ValidationError("User-defined Currency Character must be defined between "
  24. "character codes 20h (32) and FFh (255)")