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.

28 lines
979 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2017-TODAY Camptocamp SA (<http://www.camptocamp.com>).
  3. # @author: Simone Orsi (https://twitter.com/simahawk)
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from odoo import fields, models, api, exceptions, _
  6. class PosConfig(models.Model):
  7. _inherit = 'pos.config'
  8. default_payment_method_id = fields.Many2one(
  9. comodel_name='account.journal',
  10. string='Default payment method',
  11. domain=[('journal_user', '=', True),
  12. ('type', 'in', ['bank', 'cash'])],
  13. )
  14. @api.constrains('journal_ids', 'default_payment_method_id')
  15. def _check_default_payment_method_id(self):
  16. if not self.default_payment_method_id:
  17. return
  18. if self.default_payment_method_id not in self.journal_ids:
  19. raise exceptions.ValidationError(_(
  20. "The default payment journal "
  21. "is not enabled on this configuration."
  22. ))