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.

22 lines
827 B

  1. # Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
  2. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import _, api, models
  5. from odoo.exceptions import Warning as UserError
  6. class AccountPayment(models.Model):
  7. _inherit = 'account.payment'
  8. @api.multi
  9. def post(self):
  10. payments = self.filtered(
  11. lambda x: any(x.mapped('invoice_ids.pos_pending_payment')))
  12. if payments:
  13. raise UserError(_(
  14. "You can not realize this action on the payments(s) %s because"
  15. " there are pending payments in the Point of Sale.") % (
  16. ', '.join(
  17. [x for x in payments.mapped('communication') if x])))
  18. return super().post()