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.

23 lines
901 B

  1. # Copyright (C) 2004-Today Apertoso NV (<http://www.apertoso.be>)
  2. # Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>)
  3. # Copyright (C) 2019-Today: Druidoo (<https://www.druidoo.io>)
  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 odoo import fields, models, exceptions, api, _
  8. class PosOrder(models.Model):
  9. _inherit = 'pos.order'
  10. require_customer = fields.Selection(
  11. related='session_id.config_id.require_customer',
  12. )
  13. @api.constrains('partner_id', 'require_customer')
  14. def _check_partner(self):
  15. for rec in self:
  16. if rec.require_customer != 'no' and not rec.partner_id:
  17. raise exceptions.ValidationError(_(
  18. 'Customer is required for this order and is missing.'))