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.

33 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2004-Today Apertoso NV (<http://www.apertoso.be>)
  3. # Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>)
  4. # @author: Jos DE GRAEVE (<Jos.DeGraeve@apertoso.be>)
  5. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  6. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  7. from openerp import fields, models, exceptions, api
  8. from openerp.tools.translate import _
  9. class PosOrder(models.Model):
  10. _inherit = 'pos.order'
  11. @api.multi
  12. @api.depends('session_id.config_id.require_customer')
  13. def compute_require_customer(self):
  14. for order in self:
  15. order.require_customer = (
  16. order.session_id.config_id.require_customer == 'order')
  17. require_customer = fields.Boolean(
  18. compute='compute_require_customer', string='Require customer',
  19. help="True if a customer is required to begin the order.\n"
  20. "See the PoS Config to change this setting")
  21. @api.one
  22. @api.constrains('partner_id', 'require_customer')
  23. def _check_partner(self):
  24. if (self.session_id.config_id.require_customer == 'order' and
  25. not self.partner_id):
  26. raise exceptions.ValidationError(
  27. _('Customer is required for this order and is missing.'))