1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
7
# info Vauxoo (info@vauxoo.com)
8
############################################################################
9
# Coded by: moylop260 (moylop260@vauxoo.com)
10
# Launchpad Project Manager for Publication: Nhomar Hernandez - nhomar@vauxoo.com
11
############################################################################
13
# This program is free software: you can redistribute it and/or modify
14
# it under the terms of the GNU Affero General Public License as
15
# published by the Free Software Foundation, either version 3 of the
16
# License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU Affero General Public License for more details.
23
# You should have received a copy of the GNU Affero General Public License
24
# along with this program. If not, see <http://www.gnu.org/licenses/>.
26
##############################################################################
27
from openerp.osv import osv, fields
28
from openerp.tools.translate import _
29
from string import upper
32
class account_invoice(osv.Model):
33
_inherit = 'account.invoice'
35
def invoice_validate(self, cr, uid, ids, context=None):
38
for invoice in self.browse(cr, uid, ids, context=context):
39
partner_id = invoice.partner_id
40
partner_vat = upper((partner_id.vat_split or '').replace('-', '').
41
replace('_', '').replace(' ', ''))
43
for tax in invoice.tax_line:
44
if tax.tax_id and tax.tax_id.type_tax_use == 'purchase':
47
if tax_purchase and (not partner_vat or not partner_id.\
48
type_of_third or not partner_id.type_of_operation or (
49
partner_id.type_of_third == '05' and not partner_id.\
50
diot_country) or (partner_id.type_of_third == '04' and not\
51
self.pool.get('res.partner').check_vat_mx(partner_vat))):
52
raise osv.except_osv(_('Error!'), _(
53
'Please review the RFC and data for DIOT Report in the partner.'))
54
return super(account_invoice, self).invoice_validate(cr, uid, ids,