2019-01-31 23:21:17 +01:00
|
|
|
# Copyright 2013-2019 Akretion France (https://akretion.com/)
|
|
|
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
2016-10-11 12:09:26 +02:00
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
|
2019-01-31 23:21:17 +01:00
|
|
|
from odoo import api, models, _
|
2016-10-11 12:09:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ResPartner(models.Model):
|
|
|
|
_inherit = 'res.partner'
|
|
|
|
|
|
|
|
@api.onchange('property_account_position_id')
|
|
|
|
def fiscal_position_change(self):
|
|
|
|
"""Warning if the fiscal position requires a VAT number and the
|
|
|
|
partner doesn't have one yet"""
|
|
|
|
fp = self.property_account_position_id
|
|
|
|
if fp.vat_required and self.customer and not self.vat:
|
|
|
|
return {
|
|
|
|
'warning': {
|
|
|
|
'title': _('Missing VAT number:'),
|
|
|
|
'message': _(
|
|
|
|
"You have set the fiscal position '%s' "
|
|
|
|
"that require the customer to have a VAT number, "
|
|
|
|
"but the VAT number is missing.") % fp.name
|
|
|
|
}
|
|
|
|
}
|