[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>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Account Fiscal Position VAT Check',
|
||||
'version': '12.0.1.0.0',
|
||||
'version': '14.0.1.0.0',
|
||||
'category': 'Invoices & Payments',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Check VAT on invoice validation',
|
||||
|
@ -1,2 +1,2 @@
|
||||
from . import account_invoice
|
||||
from . import account_move
|
||||
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>
|
||||
# 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
|
||||
|
||||
|
||||
class AccountInvoice(models.Model):
|
||||
_inherit = 'account.invoice'
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
@api.multi
|
||||
def action_move_create(self):
|
||||
def _post(self, soft=True):
|
||||
"""Check that the customer has VAT set if required by the
|
||||
fiscal position"""
|
||||
for invoice in self:
|
||||
for move in self:
|
||||
if (
|
||||
invoice.type in ('out_invoice', 'out_refund') and
|
||||
invoice.fiscal_position_id.vat_required and
|
||||
not invoice.partner_id.vat):
|
||||
move.move_type in ('out_invoice', 'out_refund') and
|
||||
move.fiscal_position_id.vat_required and
|
||||
not move.commercial_partner_id.vat):
|
||||
raise UserError(_(
|
||||
"You are trying to validate a customer invoice/refund "
|
||||
"with the fiscal position '%s' that require the customer "
|
||||
"to have a VAT number. But the Customer '%s' doesn't have "
|
||||
"a VAT number in Odoo. Please add the VAT number of this "
|
||||
"Customer in Odoo and try to validate again.") % (
|
||||
invoice.fiscal_position_id.name,
|
||||
invoice.partner_id.display_name))
|
||||
return super(AccountInvoice, self).action_move_create()
|
||||
move.fiscal_position_id.display_name,
|
||||
move.commercial_partner_id.display_name))
|
||||
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>
|
||||
# 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
|
||||
partner doesn't have one yet"""
|
||||
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 {
|
||||
'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
|
||||
"that require customers to have a VAT number. "
|
||||
"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
|
||||
a fiscal position that has the option **VAT Required** on a customer
|
||||
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 partner
|
||||
that doesn't have a VAT number yet.
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?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>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
Loading…
Reference in New Issue
Block a user