# -*- coding: utf-8 -*-fromopenerpimportapi,models,_fromopenerp.exceptionsimportValidationErrorclassAccountPayment(models.Model):_inherit="account.payment"@api.multidefcheck_post(self):new_context=dict(self.env.context,**{'account_payment_confirm':True})self.with_context(new_context).post()@api.multidefpost(self):ifself.env.context.get('account_payment_confirm',False):forrecinself:error_invoices=rec.invoice_ids.filtered(lambdai:i.state!='open')iflen(error_invoices):msg="\n".join(["%s: %s - %s - %s: %s - %s"%(_("invoice"),inv.partner_id.name,inv.number,_("payment"),rec.name,rec.payment_date)forinvinerror_invoices])raiseValidationError(_("""The payment cannot be processed because some """"""invoices are not open!\n""""""%s""")%msg)returnsuper(AccountPayment,self).post()