From 1c3b69c497d58fb112a56a730477141731d9cb5d Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 19 Oct 2013 21:56:42 +0200 Subject: [PATCH] Add warning when the user sets a fiscal position "must have vat" on a partner and this partner doesn't have a VAT number in openerp yet. Remove the cut at 80 lines on some messages as it doesn't work with translation files. Update FR translation. --- account_fiscal_position_vat_check/__init__.py | 1 + .../__openerp__.py | 3 ++ .../account_invoice.py | 11 ++--- .../account_fiscal_position_vat_check.pot | 29 +++++++++++--- account_fiscal_position_vat_check/i18n/fr.po | 29 +++++++++++--- account_fiscal_position_vat_check/partner.py | 40 +++++++++++++++++++ .../partner_view.xml | 26 ++++++++++++ 7 files changed, 119 insertions(+), 20 deletions(-) create mode 100644 account_fiscal_position_vat_check/partner.py create mode 100644 account_fiscal_position_vat_check/partner_view.xml diff --git a/account_fiscal_position_vat_check/__init__.py b/account_fiscal_position_vat_check/__init__.py index b234380bc..299cab6fa 100644 --- a/account_fiscal_position_vat_check/__init__.py +++ b/account_fiscal_position_vat_check/__init__.py @@ -21,3 +21,4 @@ ############################################################################## from . import account_invoice +from . import partner diff --git a/account_fiscal_position_vat_check/__openerp__.py b/account_fiscal_position_vat_check/__openerp__.py index 2fa13e41c..6b010f9da 100644 --- a/account_fiscal_position_vat_check/__openerp__.py +++ b/account_fiscal_position_vat_check/__openerp__.py @@ -35,6 +35,8 @@ This module adds an option **Customer must have VAT** on fiscal positions. When 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. +This module also displays a warning when a user sets a fiscal position with the option **Customer must have VAT** on a partner and this partner doesn't have a VAT number in OpenERP yet. + Please contact Alexis de Lattre from Akretion for any help or question about this module. """, 'author': 'Akretion', @@ -42,6 +44,7 @@ Please contact Alexis de Lattre from Akretion for 'depends': ['account'], 'data': [ 'account_fiscal_position_view.xml', + 'partner_view.xml', ], 'images': [ 'fiscal_position_form.jpg', diff --git a/account_fiscal_position_vat_check/account_invoice.py b/account_fiscal_position_vat_check/account_invoice.py index 35b978ef9..543dd80a3 100644 --- a/account_fiscal_position_vat_check/account_invoice.py +++ b/account_fiscal_position_vat_check/account_invoice.py @@ -30,8 +30,7 @@ class account_fiscal_position(orm.Model): _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."), + help="If enabled, OpenERP will check that the customer has a VAT number when the user validates a customer invoice/refund."), } @@ -52,12 +51,8 @@ class account_invoice(orm.Model): 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.") + _("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)) + 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.pot b/account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.pot index 646d2cd25..077278974 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 @@ -6,8 +6,8 @@ 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" +"POT-Creation-Date: 2013-10-19 19:46+0000\n" +"PO-Revision-Date: 2013-10-19 19:46+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,13 +16,18 @@ msgstr "" "Plural-Forms: \n" #. module: account_fiscal_position_vat_check -#: code:addons/account_fiscal_position_vat_check/account_invoice.py:47 +#: view:res.partner:0 +msgid "fiscal_position_change(property_account_position, vat)" +msgstr "" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:54 #, 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 +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:51 #, python-format msgid "a Customer Refund" msgstr "" @@ -48,14 +53,26 @@ msgid "Invoice" msgstr "" #. module: account_fiscal_position_vat_check -#: code:addons/account_fiscal_position_vat_check/account_invoice.py:44 +#: model:ir.model,name:account_fiscal_position_vat_check.model_res_partner +msgid "Partner" +msgstr "" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:49 #, python-format msgid "a Customer Invoice" msgstr "" #. module: account_fiscal_position_vat_check -#: code:addons/account_fiscal_position_vat_check/account_invoice.py:47 +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:53 +#: code:addons/account_fiscal_position_vat_check/partner.py:38 #, python-format msgid "Missing VAT number:" msgstr "" +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/partner.py:39 +#, python-format +msgid "You have set the fiscal position '%s' that require the customer to have a VAT number. You should add the VAT number of this customer in OpenERP." +msgstr "" + diff --git a/account_fiscal_position_vat_check/i18n/fr.po b/account_fiscal_position_vat_check/i18n/fr.po index cd5d662c8..50d547450 100644 --- a/account_fiscal_position_vat_check/i18n/fr.po +++ b/account_fiscal_position_vat_check/i18n/fr.po @@ -6,8 +6,8 @@ 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" +"POT-Creation-Date: 2013-10-19 19:47+0000\n" +"PO-Revision-Date: 2013-10-19 19:47+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,13 +16,18 @@ msgstr "" "Plural-Forms: \n" #. module: account_fiscal_position_vat_check -#: code:addons/account_fiscal_position_vat_check/account_invoice.py:47 +#: view:res.partner:0 +msgid "fiscal_position_change(property_account_position, vat)" +msgstr "fiscal_position_change(property_account_position, vat)" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:54 #, 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 +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:51 #, python-format msgid "a Customer Refund" msgstr "un avoir client" @@ -48,14 +53,26 @@ msgid "Invoice" msgstr "Facture" #. module: account_fiscal_position_vat_check -#: code:addons/account_fiscal_position_vat_check/account_invoice.py:44 +#: model:ir.model,name:account_fiscal_position_vat_check.model_res_partner +msgid "Partner" +msgstr "Partenaire" + +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:49 #, 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 +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:53 +#: code:addons/account_fiscal_position_vat_check/partner.py:38 #, python-format msgid "Missing VAT number:" msgstr "Numéro de TVA manquant :" +#. module: account_fiscal_position_vat_check +#: code:addons/account_fiscal_position_vat_check/partner.py:39 +#, python-format +msgid "You have set the fiscal position '%s' that require the customer to have a VAT number. You should add the VAT number of this customer in OpenERP." +msgstr "Vous avez sélectionné la position fiscale '%s' qui exige que le client ait un numéro de TVA. Vous devez ajouter le numéro de TVA de ce client dans OpenERP." + diff --git a/account_fiscal_position_vat_check/partner.py b/account_fiscal_position_vat_check/partner.py new file mode 100644 index 000000000..4b0716522 --- /dev/null +++ b/account_fiscal_position_vat_check/partner.py @@ -0,0 +1,40 @@ +# -*- 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 orm +from openerp.tools.translate import _ + + +class res_partner(orm.Model): + _inherit = 'res.partner' + + def fiscal_position_change(self, cr, uid, ids, account_position, vat): + '''Warning is the fiscal position requires a vat number and the partner + doesn't have one yet''' + if account_position and not vat: + fp = self.pool['account.fiscal.position'].read( + cr, uid, account_position, ['customer_must_have_vat', 'name']) + if fp['customer_must_have_vat']: + return {'warning': { + 'title': _('Missing VAT number:'), + 'message': _("You have set the fiscal position '%s' that require the customer to have a VAT number. You should add the VAT number of this customer in OpenERP.") % fp['name']}} + return True diff --git a/account_fiscal_position_vat_check/partner_view.xml b/account_fiscal_position_vat_check/partner_view.xml new file mode 100644 index 000000000..773aa9ee7 --- /dev/null +++ b/account_fiscal_position_vat_check/partner_view.xml @@ -0,0 +1,26 @@ + + + + + + + + + + customer.must.have.vat.fiscal_position_form + res.partner + + + + fiscal_position_change(property_account_position, vat) + + + + + + +