diff --git a/account_fiscal_position_vat_check/__manifest__.py b/account_fiscal_position_vat_check/__manifest__.py index 59ef8d1c..a220f95a 100644 --- a/account_fiscal_position_vat_check/__manifest__.py +++ b/account_fiscal_position_vat_check/__manifest__.py @@ -3,16 +3,16 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Account Fiscal Position VAT Check', - 'version': '14.0.1.0.0', - 'category': 'Invoices & Payments', - 'license': 'AGPL-3', - 'summary': 'Check VAT on invoice validation', - 'author': "Akretion,Odoo Community Association (OCA)", - 'website': 'https://github.com/OCA/account-financial-tools', - 'depends': ['account', 'base_vat'], - 'data': [ - 'views/account_fiscal_position.xml', + "name": "Account Fiscal Position VAT Check", + "version": "14.0.1.0.0", + "category": "Invoices & Payments", + "license": "AGPL-3", + "summary": "Check VAT on invoice validation", + "author": "Akretion,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-financial-tools", + "depends": ["account", "base_vat"], + "data": [ + "views/account_fiscal_position.xml", ], - 'installable': True, + "installable": True, } diff --git a/account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.pot b/account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.pot index a11a7ae4..1ffe732d 100644 --- a/account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.pot +++ b/account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_fiscal_position_vat_check +# * account_fiscal_position_vat_check # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -19,25 +19,49 @@ msgid "Contact" msgstr "" #. module: account_fiscal_position_vat_check -#: model:ir.model,name:account_fiscal_position_vat_check.model_account_invoice -msgid "Invoice" +#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_account_move__display_name +#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_res_partner__display_name +msgid "Display Name" msgstr "" #. module: account_fiscal_position_vat_check -#: code:addons/account_fiscal_position_vat_check/models/partner.py:19 +#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_account_move__id +#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_res_partner__id +msgid "ID" +msgstr "" + +#. module: account_fiscal_position_vat_check +#: model:ir.model,name:account_fiscal_position_vat_check.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_fiscal_position_vat_check +#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_account_move____last_update +#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_res_partner____last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/models/partner.py:0 #, python-format msgid "Missing VAT number:" msgstr "" #. module: account_fiscal_position_vat_check -#: code:addons/account_fiscal_position_vat_check/models/account_invoice.py:21 +#: code:addons/account_fiscal_position_vat_check/models/account_move.py:0 #, python-format -msgid "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." +msgid "" +"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." msgstr "" #. module: account_fiscal_position_vat_check -#: code:addons/account_fiscal_position_vat_check/models/partner.py:20 +#: code:addons/account_fiscal_position_vat_check/models/partner.py:0 #, python-format -msgid "You have set the fiscal position '%s' that require the customer to have a VAT number, but the VAT number is missing." +msgid "" +"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." msgstr "" - diff --git a/account_fiscal_position_vat_check/models/account_move.py b/account_fiscal_position_vat_check/models/account_move.py index 26fdfe82..726b10c3 100644 --- a/account_fiscal_position_vat_check/models/account_move.py +++ b/account_fiscal_position_vat_check/models/account_move.py @@ -2,27 +2,33 @@ # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, _ +from odoo import _, models from odoo.exceptions import UserError class AccountMove(models.Model): - _inherit = 'account.move' + _inherit = "account.move" def _post(self, soft=True): """Check that the customer has VAT set if required by the fiscal position""" for move in self: if ( - 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.") % ( + 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." + ) + % ( move.fiscal_position_id.display_name, - move.commercial_partner_id.display_name)) + move.commercial_partner_id.display_name, + ) + ) return super()._post(soft=soft) diff --git a/account_fiscal_position_vat_check/models/partner.py b/account_fiscal_position_vat_check/models/partner.py index 8f40d24e..5e76aafa 100644 --- a/account_fiscal_position_vat_check/models/partner.py +++ b/account_fiscal_position_vat_check/models/partner.py @@ -2,25 +2,27 @@ # @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, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" - @api.onchange('property_account_position_id') + @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': _( + "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 + "should add its VAT number." + ) + % fp.display_name, } } diff --git a/account_fiscal_position_vat_check/views/account_fiscal_position.xml b/account_fiscal_position_vat_check/views/account_fiscal_position.xml index eaf3951e..99d0c984 100644 --- a/account_fiscal_position_vat_check/views/account_fiscal_position.xml +++ b/account_fiscal_position_vat_check/views/account_fiscal_position.xml @@ -1,36 +1,29 @@ - + - - - - - customer.must.have.vat.fiscal_position_form - account.fiscal.position - - - - - {} + + customer.must.have.vat.fiscal_position_form + account.fiscal.position + + + + + {} + - - - - - - customer.must.have.vat.fiscal_position_tree - account.fiscal.position - - - - + + + customer.must.have.vat.fiscal_position_tree + account.fiscal.position + + + + + - - - - +