diff --git a/account_fiscal_position_vat_check/__init__.py b/account_fiscal_position_vat_check/__init__.py new file mode 100644 index 000000000..3ac42a65f --- /dev/null +++ b/account_fiscal_position_vat_check/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Fiscal Position VAT Check module for OpenERP +# Copyright (C) 2013 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import account_invoice diff --git a/account_fiscal_position_vat_check/__openerp__.py b/account_fiscal_position_vat_check/__openerp__.py new file mode 100644 index 000000000..20bb368a2 --- /dev/null +++ b/account_fiscal_position_vat_check/__openerp__.py @@ -0,0 +1,53 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Fiscal Position VAT Check module for OpenERP +# Copyright (C) 2013 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +{ + 'name': 'Account Fiscal Position VAT Check', + 'version': '0.1', + 'category': 'Accounting & Finance', + 'license': 'AGPL-3', + 'summary': 'Check VAT on invoice validation', + 'description': """ +Check that the Customer has a VAT number on invoice validation +============================================================== + +This module adds an option **Customer must have VAT** on fiscal positions. When a user tries to validate a customer invoice or refund with a fiscal position that have this option, OpenERP will check that the customer has a VAT number. If it doesn't, OpenERP will block the validation of the invoice and display an error message. + +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 on the invoice. + +Please contact Alexis de Lattre from Akretion for any help or question about this module. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['account'], + 'data': [ + 'account_fiscal_position_view.xml', + ], + 'images': [ + 'fiscal_position_form.jpg', + 'vat_check_invoice_validation.jpg', + ], + 'installable': True, + 'active': False, + 'application': True, +} diff --git a/account_fiscal_position_vat_check/account_fiscal_position_view.xml b/account_fiscal_position_vat_check/account_fiscal_position_view.xml new file mode 100644 index 000000000..d29e2b14b --- /dev/null +++ b/account_fiscal_position_vat_check/account_fiscal_position_view.xml @@ -0,0 +1,37 @@ + + + + + + + + + + customer.must.have.vat.fiscal_position_form + account.fiscal.position + + + + + + + + + + + customer.must.have.vat.fiscal_position_tree + account.fiscal.position + + + + + + + + + + diff --git a/account_fiscal_position_vat_check/account_invoice.py b/account_fiscal_position_vat_check/account_invoice.py new file mode 100644 index 000000000..c3f5d9003 --- /dev/null +++ b/account_fiscal_position_vat_check/account_invoice.py @@ -0,0 +1,48 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Fiscal Position VAT Check module for OpenERP +# Copyright (C) 2013 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import osv, orm, fields +from openerp.tools.translate import _ + + +class account_fiscal_position(osv.Model): + _inherit = 'account.fiscal.position' + + _columns = { + 'customer_must_have_vat': fields.boolean('Customer Must Have VAT number', + help="If enabled, OpenERP will check that the customer has a VAT number when the user validates a customer invoice/refund."), + } + + +class account_invoice(osv.Model): + _inherit = 'account.invoice' + + def action_move_create(self, cr, uid, ids, context=None): + '''Check that the customer has VAT set if the fiscal position require it''' + for invoice in self.browse(cr, uid, ids, context=context): + if invoice.type in ('out_invoice', 'out_refund') and invoice.fiscal_position and invoice.fiscal_position.customer_must_have_vat and not invoice.partner_id.vat: + if invoice.type == 'out_invoice': + type_label = _('a Customer Invoice') + else: + type_label = _('a Customer Refund') + raise orm.except_orm(_('Missing VAT number:'), _("You are trying to validate %s 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 OpenERP. Please add the VAT number of this Customer in OpenERP and try to validate again.") %(type_label, invoice.fiscal_position.name, invoice.partner_id.name)) + return super(account_invoice, self).action_move_create(cr, uid, ids, context=context) diff --git a/account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.po b/account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.po new file mode 100644 index 000000000..646d2cd25 --- /dev/null +++ b/account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.po @@ -0,0 +1,61 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_fiscal_position_vat_check +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-09-13 15:46+0000\n" +"PO-Revision-Date: 2013-09-13 15:46+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:47 +#, python-format +msgid "You are trying to validate %s 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 OpenERP. Please add the VAT number of this Customer in OpenERP and try to validate again." +msgstr "" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:46 +#, python-format +msgid "a Customer Refund" +msgstr "" + +#. module: account_fiscal_position_vat_check +#: field:account.fiscal.position,customer_must_have_vat:0 +msgid "Customer Must Have VAT number" +msgstr "" + +#. module: account_fiscal_position_vat_check +#: help:account.fiscal.position,customer_must_have_vat:0 +msgid "If enabled, OpenERP will check that the customer has a VAT number when the user validates a customer invoice/refund." +msgstr "" + +#. module: account_fiscal_position_vat_check +#: model:ir.model,name:account_fiscal_position_vat_check.model_account_fiscal_position +msgid "Fiscal Position" +msgstr "" + +#. module: account_fiscal_position_vat_check +#: model:ir.model,name:account_fiscal_position_vat_check.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:44 +#, python-format +msgid "a Customer Invoice" +msgstr "" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:47 +#, python-format +msgid "Missing VAT number:" +msgstr "" + diff --git a/account_fiscal_position_vat_check/i18n/fr.po b/account_fiscal_position_vat_check/i18n/fr.po new file mode 100644 index 000000000..cd5d662c8 --- /dev/null +++ b/account_fiscal_position_vat_check/i18n/fr.po @@ -0,0 +1,61 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_fiscal_position_vat_check +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-09-13 15:45+0000\n" +"PO-Revision-Date: 2013-09-13 15:45+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:47 +#, python-format +msgid "You are trying to validate %s 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 OpenERP. Please add the VAT number of this Customer in OpenERP and try to validate again." +msgstr "Vous essayez de valider %s avec la position fiscale '%s' qui oblige à connaître le numéro de TVA du client. Mais le client '%s' n'a pas de numéro de TVA dans OpenERP. Veuillez ajouter le numéro de TVA de ce client dans OpenERP et essayer de valider à nouveau." + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:46 +#, python-format +msgid "a Customer Refund" +msgstr "un avoir client" + +#. module: account_fiscal_position_vat_check +#: field:account.fiscal.position,customer_must_have_vat:0 +msgid "Customer Must Have VAT number" +msgstr "Numéro de TVA obligatoire pour le client" + +#. module: account_fiscal_position_vat_check +#: help:account.fiscal.position,customer_must_have_vat:0 +msgid "If enabled, OpenERP will check that the customer has a VAT number when the user validates a customer invoice/refund." +msgstr "Si activé, OpenERP vérifiera que le client a un numéro de TVA quand l'utilisasteur valide la facture/avoir client." + +#. module: account_fiscal_position_vat_check +#: model:ir.model,name:account_fiscal_position_vat_check.model_account_fiscal_position +msgid "Fiscal Position" +msgstr "Position fiscale" + +#. module: account_fiscal_position_vat_check +#: model:ir.model,name:account_fiscal_position_vat_check.model_account_invoice +msgid "Invoice" +msgstr "Facture" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:44 +#, python-format +msgid "a Customer Invoice" +msgstr "une facture client" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:47 +#, python-format +msgid "Missing VAT number:" +msgstr "Numéro de TVA manquant :" + diff --git a/account_fiscal_position_vat_check/images/fiscal_position_form.jpg b/account_fiscal_position_vat_check/images/fiscal_position_form.jpg new file mode 100644 index 000000000..1868f8b4a Binary files /dev/null and b/account_fiscal_position_vat_check/images/fiscal_position_form.jpg differ diff --git a/account_fiscal_position_vat_check/images/vat_check_invoice_validation.jpg b/account_fiscal_position_vat_check/images/vat_check_invoice_validation.jpg new file mode 100644 index 000000000..c8766e474 Binary files /dev/null and b/account_fiscal_position_vat_check/images/vat_check_invoice_validation.jpg differ