account_fiscal_position_vat_check: warning banner
A yellow warning banner is now displayed on the partner form view when the fiscal position requires a VAT number and the VAT number is missing. This banner replaces the warning message triggered by the onchange. Improve README of the module with v14 screenshots.
This commit is contained in:
parent
470286c4f6
commit
f2463936bd
@ -13,6 +13,7 @@
|
|||||||
"depends": ["account", "base_vat"],
|
"depends": ["account", "base_vat"],
|
||||||
"data": [
|
"data": [
|
||||||
"views/account_fiscal_position.xml",
|
"views/account_fiscal_position.xml",
|
||||||
|
"views/res_partner.xml",
|
||||||
],
|
],
|
||||||
"installable": True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,23 @@
|
|||||||
# Copyright 2013-2020 Akretion France (https://akretion.com/)
|
# Copyright 2013-2022 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 api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class ResPartner(models.Model):
|
class ResPartner(models.Model):
|
||||||
_inherit = "res.partner"
|
_inherit = "res.partner"
|
||||||
|
|
||||||
@api.onchange("property_account_position_id")
|
show_warning_vat_required = fields.Boolean(
|
||||||
def fiscal_position_change(self):
|
compute="_compute_show_warning_vat_required"
|
||||||
"""Warning if the fiscal position requires a VAT number and the
|
)
|
||||||
partner doesn't have one yet"""
|
|
||||||
fp = self.property_account_position_id
|
@api.depends("property_account_position_id", "vat")
|
||||||
if fp.vat_required and not self.vat:
|
@api.depends_context("company")
|
||||||
return {
|
def _compute_show_warning_vat_required(self):
|
||||||
"warning": {
|
for partner in self:
|
||||||
"title": _("Missing VAT number:"),
|
show = False
|
||||||
"message": _(
|
fp = partner.property_account_position_id
|
||||||
"You have set the fiscal position '%s' "
|
if fp and fp.vat_required and not partner.vat:
|
||||||
"that require customers to have a VAT number. "
|
show = True
|
||||||
"If you plan to use this partner as a customer, you "
|
partner.show_warning_vat_required = show
|
||||||
"should add its VAT number."
|
|
||||||
)
|
|
||||||
% fp.display_name,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
To configure this module, go to the menu *Invoicing > Configuration > Accounting
|
To configure this module, go to the menu *Invoicing > Configuration > Accounting
|
||||||
> Fiscal Positions* and enable the option **VAT Required** on the relevant
|
> Fiscal Positions* and enable the option **VAT Required** on the relevant
|
||||||
fiscal positions.
|
fiscal positions.
|
||||||
|
|
||||||
|
.. figure:: static/description/fiscal_position_form.png
|
||||||
|
:alt: Fiscal Position form view
|
||||||
|
@ -2,6 +2,9 @@ With this module, when a user tries to validate a customer invoice or refund
|
|||||||
with a fiscal position that requires VAT, Odoo blocks the validation of the invoice
|
with a fiscal position that requires VAT, Odoo blocks the validation of the invoice
|
||||||
if the customer doesn't have a VAT number in Odoo.
|
if the customer doesn't have a VAT number in Odoo.
|
||||||
|
|
||||||
|
.. figure:: static/description/vat_check_invoice_validation.png
|
||||||
|
:alt: Error upon customer invoice validation
|
||||||
|
|
||||||
In the European Union (EU), when an EU company sends an invoice to
|
In the European Union (EU), when an EU company sends an invoice to
|
||||||
another EU company in another country, it can invoice without VAT
|
another EU company in another country, it can invoice without VAT
|
||||||
(most of the time) but the VAT number of the customer must be displayed
|
(most of the time) but the VAT number of the customer must be displayed
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
On the partner form view, Odoo will display a warning when a user sets
|
On the partner form view, Odoo will display a yellow warning banner
|
||||||
a fiscal position that has the option **VAT Required** on a partner
|
when the partner has a fiscal position that has the option **VAT Required**
|
||||||
that doesn't have a VAT number yet.
|
but its VAT number is not set.
|
||||||
|
|
||||||
|
.. figure:: static/description/warning_banner_vat_required.png
|
||||||
|
:alt: Warning Banner on partner form view
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 25 KiB |
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
Before Width: | Height: | Size: 66 KiB |
Binary file not shown.
After Width: | Height: | Size: 89 KiB |
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
36
account_fiscal_position_vat_check/views/res_partner.xml
Normal file
36
account_fiscal_position_vat_check/views/res_partner.xml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<!--
|
||||||
|
Copyright 2022 Akretion France (http://www.akretion.com/)
|
||||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="view_partner_property_form" model="ir.ui.view">
|
||||||
|
<field name="model">res.partner</field>
|
||||||
|
<field name="inherit_id" ref="account.view_partner_property_form" />
|
||||||
|
<field
|
||||||
|
name="groups_id"
|
||||||
|
eval="[(4, ref('account.group_account_invoice')), (4, ref('account.group_account_readonly'))]"
|
||||||
|
/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<div role="alert" position="after">
|
||||||
|
<div
|
||||||
|
class="alert alert-warning"
|
||||||
|
role="alert"
|
||||||
|
attrs="{'invisible': [('show_warning_vat_required', '=', False)]}"
|
||||||
|
>
|
||||||
|
<b>Missing VAT number</b>: this partner has the fiscal position <em
|
||||||
|
><field
|
||||||
|
name="property_account_position_id"
|
||||||
|
readonly="1"
|
||||||
|
/></em> that require to know the VAT number of the partner.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<group name="fiscal_information" position="inside">
|
||||||
|
<field name="show_warning_vat_required" invisible="1" />
|
||||||
|
</group>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue
Block a user