diff --git a/account_fiscal_position_vat_check/__manifest__.py b/account_fiscal_position_vat_check/__manifest__.py index a220f95a..76c3619c 100644 --- a/account_fiscal_position_vat_check/__manifest__.py +++ b/account_fiscal_position_vat_check/__manifest__.py @@ -13,6 +13,7 @@ "depends": ["account", "base_vat"], "data": [ "views/account_fiscal_position.xml", + "views/res_partner.xml", ], "installable": True, } diff --git a/account_fiscal_position_vat_check/models/partner.py b/account_fiscal_position_vat_check/models/partner.py index 5e76aafa..8b29e54d 100644 --- a/account_fiscal_position_vat_check/models/partner.py +++ b/account_fiscal_position_vat_check/models/partner.py @@ -1,28 +1,23 @@ -# Copyright 2013-2020 Akretion France (https://akretion.com/) +# Copyright 2013-2022 Akretion France (https://akretion.com/) # @author: Alexis de Lattre # 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): _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 not self.vat: - return { - "warning": { - "title": _("Missing VAT number:"), - "message": _( - "You have set the fiscal position '%s' " - "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, - } - } + show_warning_vat_required = fields.Boolean( + compute="_compute_show_warning_vat_required" + ) + + @api.depends("property_account_position_id", "vat") + @api.depends_context("company") + def _compute_show_warning_vat_required(self): + for partner in self: + show = False + fp = partner.property_account_position_id + if fp and fp.vat_required and not partner.vat: + show = True + partner.show_warning_vat_required = show diff --git a/account_fiscal_position_vat_check/readme/CONFIGURE.rst b/account_fiscal_position_vat_check/readme/CONFIGURE.rst index c7845cb8..bf676fc1 100644 --- a/account_fiscal_position_vat_check/readme/CONFIGURE.rst +++ b/account_fiscal_position_vat_check/readme/CONFIGURE.rst @@ -1,3 +1,6 @@ To configure this module, go to the menu *Invoicing > Configuration > Accounting > Fiscal Positions* and enable the option **VAT Required** on the relevant fiscal positions. + +.. figure:: static/description/fiscal_position_form.png + :alt: Fiscal Position form view diff --git a/account_fiscal_position_vat_check/readme/DESCRIPTION.rst b/account_fiscal_position_vat_check/readme/DESCRIPTION.rst index 088a0172..c6c46612 100644 --- a/account_fiscal_position_vat_check/readme/DESCRIPTION.rst +++ b/account_fiscal_position_vat_check/readme/DESCRIPTION.rst @@ -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 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 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 diff --git a/account_fiscal_position_vat_check/readme/USAGE.rst b/account_fiscal_position_vat_check/readme/USAGE.rst index ea821cf3..c3175eea 100644 --- a/account_fiscal_position_vat_check/readme/USAGE.rst +++ b/account_fiscal_position_vat_check/readme/USAGE.rst @@ -1,3 +1,6 @@ -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. +On the partner form view, Odoo will display a yellow warning banner +when the partner has a fiscal position that has the option **VAT Required** +but its VAT number is not set. + +.. figure:: static/description/warning_banner_vat_required.png + :alt: Warning Banner on partner form view diff --git a/account_fiscal_position_vat_check/static/description/fiscal_position_form.jpg b/account_fiscal_position_vat_check/static/description/fiscal_position_form.jpg deleted file mode 100644 index 1868f8b4..00000000 Binary files a/account_fiscal_position_vat_check/static/description/fiscal_position_form.jpg and /dev/null differ diff --git a/account_fiscal_position_vat_check/static/description/fiscal_position_form.png b/account_fiscal_position_vat_check/static/description/fiscal_position_form.png new file mode 100644 index 00000000..c5a224af Binary files /dev/null and b/account_fiscal_position_vat_check/static/description/fiscal_position_form.png differ diff --git a/account_fiscal_position_vat_check/static/description/vat_check_invoice_validation.jpg b/account_fiscal_position_vat_check/static/description/vat_check_invoice_validation.jpg deleted file mode 100644 index c8766e47..00000000 Binary files a/account_fiscal_position_vat_check/static/description/vat_check_invoice_validation.jpg and /dev/null differ diff --git a/account_fiscal_position_vat_check/static/description/vat_check_invoice_validation.png b/account_fiscal_position_vat_check/static/description/vat_check_invoice_validation.png new file mode 100644 index 00000000..e6a4ebb3 Binary files /dev/null and b/account_fiscal_position_vat_check/static/description/vat_check_invoice_validation.png differ diff --git a/account_fiscal_position_vat_check/static/description/warning_banner_vat_required.png b/account_fiscal_position_vat_check/static/description/warning_banner_vat_required.png new file mode 100644 index 00000000..369d2772 Binary files /dev/null and b/account_fiscal_position_vat_check/static/description/warning_banner_vat_required.png differ diff --git a/account_fiscal_position_vat_check/views/res_partner.xml b/account_fiscal_position_vat_check/views/res_partner.xml new file mode 100644 index 00000000..f805e58f --- /dev/null +++ b/account_fiscal_position_vat_check/views/res_partner.xml @@ -0,0 +1,36 @@ + + + + + + res.partner + + + +
+ +
+ + + +
+
+ +