[MIG] account_fiscal_position_vat_check from v12 to v14
This commit is contained in:
parent
f88dd56928
commit
32073277ab
@ -1,10 +1,10 @@
|
|||||||
# Copyright 2013-2019 Akretion France (https://akretion.com/)
|
# Copyright 2013-2020 Akretion France (https://akretion.com/)
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Account Fiscal Position VAT Check',
|
'name': 'Account Fiscal Position VAT Check',
|
||||||
'version': '12.0.1.0.0',
|
'version': '14.0.1.0.0',
|
||||||
'category': 'Invoices & Payments',
|
'category': 'Invoices & Payments',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'summary': 'Check VAT on invoice validation',
|
'summary': 'Check VAT on invoice validation',
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
from . import account_invoice
|
from . import account_move
|
||||||
from . import partner
|
from . import partner
|
||||||
|
@ -1,29 +1,28 @@
|
|||||||
# Copyright 2013-2019 Akretion France (https://akretion.com/)
|
# Copyright 2013-2020 Akretion France (https://akretion.com/)
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import api, models, _
|
from odoo import models, _
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
class AccountInvoice(models.Model):
|
class AccountMove(models.Model):
|
||||||
_inherit = 'account.invoice'
|
_inherit = 'account.move'
|
||||||
|
|
||||||
@api.multi
|
def _post(self, soft=True):
|
||||||
def action_move_create(self):
|
|
||||||
"""Check that the customer has VAT set if required by the
|
"""Check that the customer has VAT set if required by the
|
||||||
fiscal position"""
|
fiscal position"""
|
||||||
for invoice in self:
|
for move in self:
|
||||||
if (
|
if (
|
||||||
invoice.type in ('out_invoice', 'out_refund') and
|
move.move_type in ('out_invoice', 'out_refund') and
|
||||||
invoice.fiscal_position_id.vat_required and
|
move.fiscal_position_id.vat_required and
|
||||||
not invoice.partner_id.vat):
|
not move.commercial_partner_id.vat):
|
||||||
raise UserError(_(
|
raise UserError(_(
|
||||||
"You are trying to validate a customer invoice/refund "
|
"You are trying to validate a customer invoice/refund "
|
||||||
"with the fiscal position '%s' that require the customer "
|
"with the fiscal position '%s' that require the customer "
|
||||||
"to have a VAT number. But the Customer '%s' doesn't have "
|
"to have a VAT number. But the Customer '%s' doesn't have "
|
||||||
"a VAT number in Odoo. Please add the VAT number of this "
|
"a VAT number in Odoo. Please add the VAT number of this "
|
||||||
"Customer in Odoo and try to validate again.") % (
|
"Customer in Odoo and try to validate again.") % (
|
||||||
invoice.fiscal_position_id.name,
|
move.fiscal_position_id.display_name,
|
||||||
invoice.partner_id.display_name))
|
move.commercial_partner_id.display_name))
|
||||||
return super(AccountInvoice, self).action_move_create()
|
return super()._post(soft=soft)
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright 2013-2019 Akretion France (https://akretion.com/)
|
# Copyright 2013-2020 Akretion France (https://akretion.com/)
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
@ -13,13 +13,14 @@ class ResPartner(models.Model):
|
|||||||
"""Warning if the fiscal position requires a VAT number and the
|
"""Warning if the fiscal position requires a VAT number and the
|
||||||
partner doesn't have one yet"""
|
partner doesn't have one yet"""
|
||||||
fp = self.property_account_position_id
|
fp = self.property_account_position_id
|
||||||
if fp.vat_required and self.customer and not self.vat:
|
if fp.vat_required and not self.vat:
|
||||||
return {
|
return {
|
||||||
'warning': {
|
'warning': {
|
||||||
'title': _('Missing VAT number:'),
|
'title': _('Missing VAT number:'),
|
||||||
'message': _(
|
'message': _(
|
||||||
"You have set the fiscal position '%s' "
|
"You have set the fiscal position '%s' "
|
||||||
"that require the customer to have a VAT number, "
|
"that require customers to have a VAT number. "
|
||||||
"but the VAT number is missing.") % fp.name
|
"If you plan to use this partner as a customer, you "
|
||||||
|
"should add its VAT number.") % fp.display_name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
On the customer form view, Odoo will display a warning when a user sets
|
On the partner form view, Odoo will display a warning when a user sets
|
||||||
a fiscal position that has the option **VAT Required** on a customer
|
a fiscal position that has the option **VAT Required** on a partner
|
||||||
that doesn't have a VAT number yet.
|
that doesn't have a VAT number yet.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright 2013-2019 Akretion France (https://akretion.com/)
|
Copyright 2013-2020 Akretion France (https://akretion.com/)
|
||||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user