# -*- coding: utf-8 -*-
##############################################################################
#
#    Odoo, Open Source Management Solution
#    Copyright (C) 2016 Prime Consulting SA, Cape Verde (<http://prime.cv>).
#
##############################################################################

from odoo import models, api
from datetime import datetime
from odoo.exceptions import ValidationError

class account_invoice(models.Model):
	_inherit = "account.invoice"

	@api.multi
	def invoice_validate(self):
		for invoice in self:
			if datetime.strptime(invoice.date_invoice, "%Y-%m-%d") < datetime.now().date():
				raise ValidationError('Validation Error!\n\nYou are not allowed to Register Invoices with Invoice date in past.')
		return super(account_invoice, self).invoice_validate()
