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.

39 lines
1.4 KiB

  1. # coding: utf-8
  2. # Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
  3. # @author: Julien WESTE
  4. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  5. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  6. from openerp import _, api, fields, models
  7. from openerp.exceptions import Warning as UserError
  8. class AccountInvoice(models.Model):
  9. _inherit = 'account.invoice'
  10. pos_pending_payment = fields.Boolean(
  11. string='PoS - Pending Payment', readonly=True,
  12. oldname='forbid_payment',
  13. help="Indicates an invoice for which there are pending payments in the"
  14. " Point of Sale. \nThe invoice will be marked as paid when the session"
  15. " will be closed.")
  16. # Overload Section
  17. @api.multi
  18. def action_cancel(self):
  19. self._check_pos_pending_payment()
  20. return super(AccountInvoice, self).action_cancel()
  21. @api.multi
  22. def invoice_pay_customer(self):
  23. self._check_pos_pending_payment()
  24. return super(AccountInvoice, self).invoice_pay_customer()
  25. @api.multi
  26. def _check_pos_pending_payment(self):
  27. invoices = self.filtered(lambda x: x.pos_pending_payment)
  28. if invoices:
  29. raise UserError(_(
  30. "You can not realize this action on the invoice(s) %s because"
  31. " there are pending payments in the Point of Sale.") % (
  32. ', '.join(invoices.mapped('name'))))