From b5f1d9ac8f1c219046576159f72f3d014a240037 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 5 Apr 2011 00:57:21 +0200 Subject: [PATCH 01/39] [ADD] intrastat_base: Redesign for 6.1 Complete change of design for intrastat_type ! Now that report_intrastat_product/service object is stored in database, we don't need the legal_intrastat state on invoices any more, because we will be able to create entry lines for DEB for a repair of equipment under warranty without using a legal_intrastat. Report_intrastat_type is now only required for DEB -> object moved to module l10n_fr_intrastat_product. For DEB, the button "regenerate lines" only regenerate DEB lines related to invoices. Renamed intrastat base module, because it doesn't have France-specific parameters any more. Add demo data. Full re-design of intrastat types : probably requires deleting the report_intrastat_type table, restarting OpenERP and re-creating intrastat types. Moved intrastat departments from stock.warehouse to stock.location. Dropped SQL queries ; replaced by traditionnal python code logic. No more need to have one rate per day for invoices with foreign currency. Add total fiscal value for DEB More code factorization. Prepare translation work. Moved some demo data from l10n_fr_intrastat_product to intrastat_base Moved configuration about taxes from company form to tax form Some modifications to ease v5 -> v6 migration : - object report_intrastat_code now belong to group account manager - button functions now return True Tried to implement the following feature : open attachement form when the XML file as been generated : works on v6, but make client crash en v5 -> code has been commented DEB lines with procedure code = 25 are now deducted from the fiscal total. Round invoice total. Moved the field exclude_from_intrastat_if_present of account.tax from l10n_fr_intrastat_product to intrastat_base, because it should also be used in the module l10n_fr_intrastat_service. Take this field into account in the generation of DEB lines (module l10n_fr_intrastat_service). It is now possible to set the H.S. code on the product category. Some "return None" changed to "return True" Implemented the fiscal representative : for example, when you ship to the EU but invoice outside of the EU, your customer needs to have a fiscal representative inside the EU, which will be used for the DEB . depend on base_vat instead of account. Same modification as my previous commit for DEB : when we sell to a physical person in the EU with VAT, the move is not declared in DEB, so it must not block with a "raise" if the partner doesn't have a VAT number. Add option "is_accessory_cost" on product.template : If the invoice has is_accessory_cost services but no regular product -> DES If the invoice has is_accessory_cost services and regular product -> added to the cost of products in DEB Now allows "pricelist for statistical value" which is not in EUR (the currency conversion will be made from the pricelist currency to EUR) Usability improvements : - Order for DEB and DES tree view : "the more recent at the top" - distinction between "Information to declare" and "Additionnal information" in intrastat lines Better string. Update French translation. Use the new logger API of OpenERP 6.1 Move the "EU fiscal representative" field in order to avoid the "compression" of the VAT field that made it too small. Code clean-up : - context is not passed in constraints - don't use lambda when not necessary IMPORTANT CHANGE : - All EU countries should now be intrastat=True, including your own country - When generating lines for Intrastat Product/Service, all invoices for which country == Company's country are excluded Update help message according to my change of commit 61. Fix copyright header. --- intrastat_base/__init__.py | 28 ++++ intrastat_base/__openerp__.py | 54 ++++++ intrastat_base/country.py | 35 ++++ intrastat_base/country_data.xml | 87 ++++++++++ intrastat_base/country_view.xml | 36 ++++ intrastat_base/i18n/fr_FR.po | 176 ++++++++++++++++++++ intrastat_base/i18n/intrastat_base.pot | 166 ++++++++++++++++++ intrastat_base/intrastat_common.py | 132 +++++++++++++++ intrastat_base/intrastat_demo.xml | 57 +++++++ intrastat_base/intrastat_menu.xml | 16 ++ intrastat_base/partner_address.py | 35 ++++ intrastat_base/product.py | 49 ++++++ intrastat_base/product_view.xml | 53 ++++++ intrastat_base/security/ir.model.access.csv | 2 + intrastat_base/tax.py | 33 ++++ intrastat_base/tax_view.xml | 28 ++++ 16 files changed, 987 insertions(+) create mode 100644 intrastat_base/__init__.py create mode 100644 intrastat_base/__openerp__.py create mode 100644 intrastat_base/country.py create mode 100644 intrastat_base/country_data.xml create mode 100644 intrastat_base/country_view.xml create mode 100644 intrastat_base/i18n/fr_FR.po create mode 100644 intrastat_base/i18n/intrastat_base.pot create mode 100644 intrastat_base/intrastat_common.py create mode 100644 intrastat_base/intrastat_demo.xml create mode 100644 intrastat_base/intrastat_menu.xml create mode 100644 intrastat_base/partner_address.py create mode 100644 intrastat_base/product.py create mode 100644 intrastat_base/product_view.xml create mode 100644 intrastat_base/security/ir.model.access.csv create mode 100644 intrastat_base/tax.py create mode 100644 intrastat_base/tax_view.xml diff --git a/intrastat_base/__init__.py b/intrastat_base/__init__.py new file mode 100644 index 0000000..13ca149 --- /dev/null +++ b/intrastat_base/__init__.py @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Report intrastat base module for OpenERP +# Copyright (C) 2011 Akretion (http://www.akretion.com). All Rights Reserved +# @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 country +import product +import tax +import partner_address +import intrastat_common + diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py new file mode 100644 index 0000000..089173a --- /dev/null +++ b/intrastat_base/__openerp__.py @@ -0,0 +1,54 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Report intrastat base module for OpenERP +# Copyright (C) 2011 Akretion (http://www.akretion.com). All Rights Reserved +# @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': 'Base module for Intrastat reporting', + 'version': '1.1', + 'category': 'Localisation/Report Intrastat', + 'license': 'AGPL-3', + 'description': """This module contains the common functions for 2 other modules : +- l10n_fr_intrastat_service : the module for the "Déclaration Européenne des Services" (DES) +- l10n_fr_intrastat_product : the module for the "Déclaration d'Echange de Biens" (DEB) +This module is not usefull if it's not used together with one of those 2 modules. + +This module doesn't have any France-specific stuff. So it can be used as a basis for other intrastat modules for other EU countries. + +WARNING : this module conflicts with the module "report_intrastat" from the addons. If you have already installed the module "report_intrastat", you should uninstall it first before installing this module. + +Please contact Alexis de Lattre from Akretion for any help or question about this module. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['base_vat'], + 'init_xml': ['country_data.xml'], + 'update_xml': [ + 'security/ir.model.access.csv', + 'product_view.xml', + 'country_view.xml', + 'tax_view.xml', + 'intrastat_menu.xml', + ], + 'demo_xml': ['intrastat_demo.xml'], + 'installable': True, + 'active': False, +} diff --git a/intrastat_base/country.py b/intrastat_base/country.py new file mode 100644 index 0000000..2542d72 --- /dev/null +++ b/intrastat_base/country.py @@ -0,0 +1,35 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Report intrastat base module for OpenERP +# Copyright (C) 2011-2013 Akretion (http://www.akretion.com). All Rights Reserved +# @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 osv import osv, fields + +class res_country(osv.osv): + _inherit = 'res.country' + _columns = { + 'intrastat': fields.boolean('EU country', help="Set to True for all European Union countries."), + } + + _defaults = { + 'intrastat': False, + } + +res_country() diff --git a/intrastat_base/country_data.xml b/intrastat_base/country_data.xml new file mode 100644 index 0000000..04fb439 --- /dev/null +++ b/intrastat_base/country_data.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/intrastat_base/country_view.xml b/intrastat_base/country_view.xml new file mode 100644 index 0000000..bf62fa3 --- /dev/null +++ b/intrastat_base/country_view.xml @@ -0,0 +1,36 @@ + + + + + + + + + + intrastat.base.country.tree + res.country + + + + + + + + + + intrastat.base.country.form + res.country + + + + + + + + + + + diff --git a/intrastat_base/i18n/fr_FR.po b/intrastat_base/i18n/fr_FR.po new file mode 100644 index 0000000..c3a85fe --- /dev/null +++ b/intrastat_base/i18n/fr_FR.po @@ -0,0 +1,176 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * intrastat_base +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.4\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2012-06-05 13:28+0000\n" +"PO-Revision-Date: 2012-06-05 13:28+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: intrastat_base +#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root +msgid "Intrastat reporting" +msgstr "DEB et DES" + +#. module: intrastat_base +#: sql_constraint:res.country:0 +msgid "The code of the country must be unique !" +msgstr "Le code du pays doit être unique !" + +#. module: intrastat_base +#: constraint:product.template:0 +msgid "Error: The default UOM and the purchase UOM must be in the same category." +msgstr "Erreur: l'UdM par défaut et l'UdM d'achat doivent appartenir à la même catégorie." + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:64 +#: code:addons/intrastat_base/intrastat_common.py:70 +#: code:addons/intrastat_base/intrastat_common.py:85 +#: code:addons/intrastat_base/intrastat_common.py:93 +#: code:addons/intrastat_base/product.py:41 +#, python-format +msgid "Error :" +msgstr "Erreur :" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_account_tax +msgid "account.tax" +msgstr "account.tax" + +#. module: intrastat_base +#: field:account.tax,exclude_from_intrastat_if_present:0 +msgid "Exclude invoice line from intrastat if this tax is present" +msgstr "Exclue la ligne de facture de la DEB/DES si cette taxe est présente" + +#. module: intrastat_base +#: help:res.country,intrastat:0 +msgid "Set as True for countries that must be selected in the intrastat reports, i.e. for all European Union countries other than your own country." +msgstr "Activer cette option pour les pays qui doivent être inclus dans la DEB et la DES, i.e. tous les pays de l'Union Européenne sauf votre propre pays." + +#. module: intrastat_base +#: view:product.product:0 +#: view:product.template:0 +msgid "Intrastat properties" +msgstr "Paramètres pour la DEB et la DES" + +#. module: intrastat_base +#: model:ir.module.module,description:intrastat_base.module_meta_information +msgid "This module contains the common functions for 2 other modules :\n" +"- l10n_fr_intrastat_service : the module for the \"Déclaration Européenne des Services\" (DES)\n" +"- l10n_fr_intrastat_product : the module for the \"Déclaration d'Echange de Biens\" (DEB)\n" +"This module is not usefull if it's not used together with one of those 2 modules.\n" +"\n" +"This module doesn't have any France-specific stuff. So it can be used as a basis for other intrastat modules for other EU countries.\n" +"\n" +"WARNING : this module conflicts with the module \"report_intrastat\" from the addons. If you have already installed the module \"report_intrastat\", you should uninstall it first before installing this module.\n" +"\n" +"Please contact Alexis de Lattre from Akretion for any help or question about this module.\n" +" " +msgstr "This module contains the common functions for 2 other modules :\n" +"- l10n_fr_intrastat_service : the module for the \"Déclaration Européenne des Services\" (DES)\n" +"- l10n_fr_intrastat_product : the module for the \"Déclaration d'Echange de Biens\" (DEB)\n" +"This module is not usefull if it's not used together with one of those 2 modules.\n" +"\n" +"This module doesn't have any France-specific stuff. So it can be used as a basis for other intrastat modules for other EU countries.\n" +"\n" +"WARNING : this module conflicts with the module \"report_intrastat\" from the addons. If you have already installed the module \"report_intrastat\", you should uninstall it first before installing this module.\n" +"\n" +"Please contact Alexis de Lattre from Akretion for any help or question about this module.\n" +" " + +#. module: intrastat_base +#: sql_constraint:res.country:0 +msgid "The name of the country must be unique !" +msgstr "Le nom du pays doit être unique !" + +#. module: intrastat_base +#: constraint:product.template:0 +msgid "Error msg is in raise" +msgstr "Error msg is in raise" + +#. module: intrastat_base +#: help:account.tax,exclude_from_intrastat_if_present:0 +msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." +msgstr "Si cette taxe est présente sur une ligne de facture, cette ligne de facture ne sera pas prise en compte lors de la génération de la DEB et de la DES depuis les factures." + +#. module: intrastat_base +#: field:product.template,is_accessory_cost:0 +msgid "Is accessory cost" +msgstr "Frais accessoires" + +#. module: intrastat_base +#: field:res.country,intrastat:0 +msgid "Intrastat country" +msgstr "Pays intrastat" + +#. module: intrastat_base +#: help:product.template,exclude_from_intrastat:0 +msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason." +msgstr "Si l'option est activée, le produit ou service ne sera pris en compte ni pour la DEB ni pour la DES. Cette option doit donc rester désactivée sauf si vous avez une très bonne raison." + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:64 +#, python-format +msgid "The company currency must be 'EUR', but is currently '%s'." +msgstr "La monnaie de la société doit être 'EUR', mais est actuellement '%s'." + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:70 +#, python-format +msgid "The VAT number is not set for the partner '%s'." +msgstr "Le numéro de TVA n'est pas renseigné pour le partenaire '%s'." + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_report_intrastat_common +msgid "Common functions for intrastat reports for products and services" +msgstr "Common functions for intrastat reports for products and services" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_country +msgid "Country" +msgstr "Pays" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_product_template +msgid "Product Template" +msgstr "Modèle de produit" + +#. module: intrastat_base +#: model:ir.module.module,shortdesc:intrastat_base.module_meta_information +msgid "Base module for Intrastat reporting" +msgstr "Module de base pour les rapports intrastat" + +#. module: intrastat_base +#: field:product.template,exclude_from_intrastat:0 +msgid "Exclude from Intrastat reports" +msgstr "Exclure de la DEB et de la DES" + +#. module: intrastat_base +#: help:product.template,is_accessory_cost:0 +msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." +msgstr "Activez cette option pour les frais de port, les frais d'emballage et tous les services liés à la vente de produits physiques. Cette option est utilisée pour la DEB et la DES." + +#. module: intrastat_base +#: model:product.template,name:intrastat_base.shipping_costs_exclude_product_template +msgid "Shipping costs" +msgstr "Frais de port" + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:85 +#, python-format +msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." +msgstr "La validation du fichier XML avec le schéma XML officiel a échoué. Le fichier XML généré et le détail de l'erreur ont été écrits dans les logs du serveur. Voici le message d'erreur, qui peut vous donner une idée de la cause du problème : %s." + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_partner_address +msgid "Partner Addresses" +msgstr "Carnet d'adresses" + diff --git a/intrastat_base/i18n/intrastat_base.pot b/intrastat_base/i18n/intrastat_base.pot new file mode 100644 index 0000000..d7baf12 --- /dev/null +++ b/intrastat_base/i18n/intrastat_base.pot @@ -0,0 +1,166 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * intrastat_base +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.4\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2012-06-05 13:28+0000\n" +"PO-Revision-Date: 2012-06-05 13:28+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: intrastat_base +#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root +msgid "Intrastat reporting" +msgstr "" + +#. module: intrastat_base +#: sql_constraint:res.country:0 +msgid "The code of the country must be unique !" +msgstr "" + +#. module: intrastat_base +#: constraint:product.template:0 +msgid "Error: The default UOM and the purchase UOM must be in the same category." +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:64 +#: code:addons/intrastat_base/intrastat_common.py:70 +#: code:addons/intrastat_base/intrastat_common.py:85 +#: code:addons/intrastat_base/intrastat_common.py:93 +#: code:addons/intrastat_base/product.py:41 +#, python-format +msgid "Error :" +msgstr "" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_account_tax +msgid "account.tax" +msgstr "" + +#. module: intrastat_base +#: field:account.tax,exclude_from_intrastat_if_present:0 +msgid "Exclude invoice line from intrastat if this tax is present" +msgstr "" + +#. module: intrastat_base +#: help:res.country,intrastat:0 +msgid "Set as True for countries that must be selected in the intrastat reports, i.e. for all European Union countries other than your own country." +msgstr "" + +#. module: intrastat_base +#: view:product.product:0 +#: view:product.template:0 +msgid "Intrastat properties" +msgstr "" + +#. module: intrastat_base +#: model:ir.module.module,description:intrastat_base.module_meta_information +msgid "This module contains the common functions for 2 other modules :\n" +"- l10n_fr_intrastat_service : the module for the \"Déclaration Européenne des Services\" (DES)\n" +"- l10n_fr_intrastat_product : the module for the \"Déclaration d'Echange de Biens\" (DEB)\n" +"This module is not usefull if it's not used together with one of those 2 modules.\n" +"\n" +"This module doesn't have any France-specific stuff. So it can be used as a basis for other intrastat modules for other EU countries.\n" +"\n" +"WARNING : this module conflicts with the module \"report_intrastat\" from the addons. If you have already installed the module \"report_intrastat\", you should uninstall it first before installing this module.\n" +"\n" +"Please contact Alexis de Lattre from Akretion for any help or question about this module.\n" +" " +msgstr "" + +#. module: intrastat_base +#: sql_constraint:res.country:0 +msgid "The name of the country must be unique !" +msgstr "" + +#. module: intrastat_base +#: constraint:product.template:0 +msgid "Error msg is in raise" +msgstr "" + +#. module: intrastat_base +#: help:account.tax,exclude_from_intrastat_if_present:0 +msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." +msgstr "" + +#. module: intrastat_base +#: field:product.template,is_accessory_cost:0 +msgid "Is accessory cost" +msgstr "" + +#. module: intrastat_base +#: field:res.country,intrastat:0 +msgid "Intrastat country" +msgstr "" + +#. module: intrastat_base +#: help:product.template,exclude_from_intrastat:0 +msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason." +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:64 +#, python-format +msgid "The company currency must be 'EUR', but is currently '%s'." +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:70 +#, python-format +msgid "The VAT number is not set for the partner '%s'." +msgstr "" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_report_intrastat_common +msgid "Common functions for intrastat reports for products and services" +msgstr "" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_country +msgid "Country" +msgstr "" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_product_template +msgid "Product Template" +msgstr "" + +#. module: intrastat_base +#: model:ir.module.module,shortdesc:intrastat_base.module_meta_information +msgid "Base module for Intrastat reporting" +msgstr "" + +#. module: intrastat_base +#: field:product.template,exclude_from_intrastat:0 +msgid "Exclude from Intrastat reports" +msgstr "" + +#. module: intrastat_base +#: help:product.template,is_accessory_cost:0 +msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." +msgstr "" + +#. module: intrastat_base +#: model:product.template,name:intrastat_base.shipping_costs_exclude_product_template +msgid "Shipping costs" +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:85 +#, python-format +msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." +msgstr "" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_partner_address +msgid "Partner Addresses" +msgstr "" + diff --git a/intrastat_base/intrastat_common.py b/intrastat_base/intrastat_common.py new file mode 100644 index 0000000..8320b8a --- /dev/null +++ b/intrastat_base/intrastat_common.py @@ -0,0 +1,132 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Report intrastat base module for OpenERP +# Copyright (C) 2010-2011 Akretion (http://www.akretion.com/). All rights reserved. +# @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 osv import osv, fields +from datetime import datetime +from dateutil.relativedelta import relativedelta +from tools.translate import _ + +class report_intrastat_common(osv.osv_memory): + _name = "report.intrastat.common" + _description = "Common functions for intrastat reports for products and services" + + def _compute_numbers(self, cr, uid, ids, object, context=None): + result = {} + for intrastat in object.browse(cr, uid, ids, context=context): + total_amount = 0.0 + num_lines = 0 + for line in intrastat.intrastat_line_ids: + total_amount += line.amount_company_currency + num_lines += 1 + result[intrastat.id] = {'num_lines': num_lines, 'total_amount': total_amount} + return result + + + def _compute_end_date(self, cr, uid, ids, object, context=None): + result = {} + for intrastat in object.browse(cr, uid, ids, context=context): + start_date_datetime = datetime.strptime(intrastat.start_date, '%Y-%m-%d') + end_date_str = datetime.strftime(start_date_datetime + relativedelta(day=31), '%Y-%m-%d') + result[intrastat.id] = end_date_str + return result + + + def _check_start_date(self, cr, uid, ids, object, context=None): + '''Check that the start date is the first day of the month''' + for date_to_check in object.read(cr, uid, ids, ['start_date'], context=context): + datetime_to_check = datetime.strptime(date_to_check['start_date'], '%Y-%m-%d') + if datetime_to_check.day != 1: + return False + return True + + + def _check_generate_lines(self, cr, uid, intrastat, context=None): + if not intrastat.company_id.country_id: + raise osv.except_osv(_('Error :'), _("The country is not set on the company '%s'.") %intrastat.company_id.name) + if not intrastat.currency_id.name == 'EUR': + raise osv.except_osv(_('Error :'), _("The company currency must be 'EUR', but is currently '%s'.") %intrastat.currency_id.name) + return True + + + def _check_generate_xml(self, cr, uid, intrastat, context=None): + if not intrastat.company_id.partner_id.vat: + raise osv.except_osv(_('Error :'), _("The VAT number is not set for the partner '%s'.") %intrastat.company_id.partner_id.name) + return True + + + def _check_xml_schema(self, cr, uid, xml_root, xml_string, xsd, context=None): + '''Validate the XML file against the XSD''' + from lxml import etree + official_des_xml_schema = etree.XMLSchema(etree.fromstring(xsd)) + try: official_des_xml_schema.assertValid(xml_root) + except Exception, e: # if the validation of the XSD fails, we arrive here + import logging + _logger = logging.getLogger(__name__) + _logger.warning("The XML file is invalid against the XML Schema Definition") + _logger.warning(xml_string) + _logger.warning(e) + raise osv.except_osv(_('Error :'), _('The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s.') % str(e)) + return True + + + def _attach_xml_file(self, cr, uid, ids, object, xml_string, start_date_datetime, declaration_name, context=None): + '''Attach the XML file to the report_intrastat_product/service object''' + import base64 + if len(ids) != 1: + raise osv.except_osv(_('Error :'), 'Hara kiri in attach_xml_file') + filename = datetime.strftime(start_date_datetime, '%Y-%m') + '_' + declaration_name + '.xml' + attach_name = declaration_name.upper() + ' ' + datetime.strftime(start_date_datetime, '%Y-%m') + attach_obj = self.pool.get('ir.attachment') + if not context: + context = {} + context.update({'default_res_id' : ids[0], 'default_res_model': object._name}) + attach_id = attach_obj.create(cr, uid, {'name': attach_name, 'datas': base64.encodestring(xml_string), 'datas_fname': filename}, context=context) + return attach_id + + + def _open_attach_view(self, cr, uid, attach_id, title='XML file', context=None): + '''Returns an action which opens the form view of the corresponding attachement''' + # Only works in v6 -> not used in v5 + action = { + 'name': title, + 'view_type': 'form', + 'view_mode': 'form,tree', + 'view_id': False, + 'res_model': 'ir.attachment', + 'type': 'ir.actions.act_window', + 'nodestroy': True, + 'target': 'current', + 'res_id': [attach_id], + } + return action + + + def partner_on_change(self, cr, uid, ids, partner_id=False): + result = {} + result['value'] = {} + if partner_id: + company = self.pool.get('res.partner').read(cr, uid, partner_id, ['vat']) + result['value'].update({'partner_vat': company['vat']}) + return result + +report_intrastat_common() + diff --git a/intrastat_base/intrastat_demo.xml b/intrastat_base/intrastat_demo.xml new file mode 100644 index 0000000..d83640e --- /dev/null +++ b/intrastat_base/intrastat_demo.xml @@ -0,0 +1,57 @@ + + + + + + + + + FR58441019213 + + + + BE0828696437 + True + + + + BE0443167858 + True + + + + BE0884025633 + True + + + + True + + + + True + + + + True + + + + True + + + + Shipping costs + SHIP + service + + 30 + True + + + + diff --git a/intrastat_base/intrastat_menu.xml b/intrastat_base/intrastat_menu.xml new file mode 100644 index 0000000..b078c6a --- /dev/null +++ b/intrastat_base/intrastat_menu.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + diff --git a/intrastat_base/partner_address.py b/intrastat_base/partner_address.py new file mode 100644 index 0000000..f36329b --- /dev/null +++ b/intrastat_base/partner_address.py @@ -0,0 +1,35 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Report intrastat base module for OpenERP +# Copyright (C) 2010-2011 Akretion (http://www.akretion.com/) All Rights Reserved +# @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 osv import osv, fields + +# We want to have the country field on res_partner_address always set +# because the selection of invoices for intrastat reports is based +# on the country of the invoice partner address ! +class res_partner_address(osv.osv): + _inherit = 'res.partner.address' + _columns = { + 'country_id': fields.many2one('res.country', 'Country', required=True), + } + +res_partner_address() + diff --git a/intrastat_base/product.py b/intrastat_base/product.py new file mode 100644 index 0000000..c535a72 --- /dev/null +++ b/intrastat_base/product.py @@ -0,0 +1,49 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Report intrastat base module for OpenERP +# Copyright (C) 2010-2012 Akretion (http://www.akretion.com/) All Rights Reserved +# @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 osv import osv, fields +from tools.translate import _ + +class product_template(osv.osv): + _inherit = "product.template" + _columns = { + 'exclude_from_intrastat': fields.boolean('Exclude from Intrastat reports', help="If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason."), + 'is_accessory_cost' : fields.boolean('Is accessory cost', help='Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports.'), + } + + _defaults = { + 'exclude_from_intrastat': False, + } + + + def _check_accessory_cost(self, cr, uid, ids): + for product in self.browse(cr, uid, ids): + if product.is_accessory_cost and product.type != 'service': + raise osv.except_osv(_('Error :'), _("The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" % (product.name, product.type))) + return True + + _constraints = [ + (_check_accessory_cost, "Error msg is in raise", ['is_accessory_cost', 'type']) + ] + +product_template() + diff --git a/intrastat_base/product_view.xml b/intrastat_base/product_view.xml new file mode 100644 index 0000000..28b026e --- /dev/null +++ b/intrastat_base/product_view.xml @@ -0,0 +1,53 @@ + + + + + + + + + + intrastat.base.product.normal.form + product.product + + + + + + + + + + + + + + + + + + + intrastat.base.product.template.form + product.template + + + + + + + + + + + + + + + + + + diff --git a/intrastat_base/security/ir.model.access.csv b/intrastat_base/security/ir.model.access.csv new file mode 100644 index 0000000..d7a2bf1 --- /dev/null +++ b/intrastat_base/security/ir.model.access.csv @@ -0,0 +1,2 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_report_intrastat_common","Read access on report.intrastat.common","model_report_intrastat_common","base.group_user",1,0,0,0 diff --git a/intrastat_base/tax.py b/intrastat_base/tax.py new file mode 100644 index 0000000..4d12d32 --- /dev/null +++ b/intrastat_base/tax.py @@ -0,0 +1,33 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Report intrastat base module for OpenERP +# Copyright (C) 2011 Akretion (http://www.akretion.com). All Rights Reserved +# @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 osv import osv, fields + + +class account_tax(osv.osv): + _inherit = "account.tax" + _columns = { + 'exclude_from_intrastat_if_present': fields.boolean('Exclude invoice line from intrastat if this tax is present', help="If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices."), + } + +account_tax() + diff --git a/intrastat_base/tax_view.xml b/intrastat_base/tax_view.xml new file mode 100644 index 0000000..e60a327 --- /dev/null +++ b/intrastat_base/tax_view.xml @@ -0,0 +1,28 @@ + + + + + + + + + + intrastat.base.tax + account.tax + form + + + + + + + + + + + + From 769956e322574c99d591f2fa11844e0e1b1d916b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 24 Apr 2013 10:55:14 +0200 Subject: [PATCH 02/39] [MIG] intrastat_base: Migration to 7.0 Should now be compatible with both OCB and RS-OCB Add field import_obligation_level on res.company Add group group_detailed_intrastat_product, so that companies that only use obligation = simplified don't see all the additionnal fields. Remove transaction code corresponding to repairs in intrastat types Better on_change on intrastat types (code is mutualised with field.function) Update syntax : demo_xml/update_xml/init_xml -> data/demo Welcome to Croatia in the European Union ! Add an e-mail reminder for l10n_fr_intrastat_product and l10n_fr_intrastat_service (hope that Akretion France won't forget it's own declarations now !!!) On report.intrastat.product and report.intrastat.service : add copy() fonctions, tracking of important fields, a year_month function field and enhance views. Remove date_done field (the tracking in the chatter does the job). Remove class instanciation in the code. Better form view of product category, courtesy of David Beal. Raise an explicit exception (take into account Stefan remark on the merge proposal) Fix to make the module truly usable when user is not part of the group "Detailed intrastat product". Remove dead code and fields that was used when we had to put DEB lines for repair operations (a thing of the past !). Update coding style. Reduce the number of flake8 warnings. On OpenERP 7, when you have the document module installed and you download the attachement via the drop down list on the form view, the name of the file will be the name of the attachement and not datas_fname ; so we need to have name = datas_fname. --- intrastat_base/__init__.py | 14 ++--- intrastat_base/__openerp__.py | 15 ++--- intrastat_base/company.py | 62 ++++++++++++++++++ intrastat_base/company_view.xml | 29 +++++++++ intrastat_base/country.py | 7 +-- intrastat_base/country_data.xml | 3 + intrastat_base/country_view.xml | 4 +- intrastat_base/intrastat_common.py | 63 ++++++++++--------- intrastat_base/intrastat_demo.xml | 8 +-- intrastat_base/intrastat_menu.xml | 2 +- .../{partner_address.py => partner.py} | 16 +++-- intrastat_base/product.py | 20 +++--- intrastat_base/product_view.xml | 32 ++++------ intrastat_base/tax.py | 9 +-- intrastat_base/tax_view.xml | 4 +- 15 files changed, 186 insertions(+), 102 deletions(-) create mode 100644 intrastat_base/company.py create mode 100644 intrastat_base/company_view.xml rename intrastat_base/{partner_address.py => partner.py} (77%) diff --git a/intrastat_base/__init__.py b/intrastat_base/__init__.py index 13ca149..8e2eaa0 100644 --- a/intrastat_base/__init__.py +++ b/intrastat_base/__init__.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for OpenERP -# Copyright (C) 2011 Akretion (http://www.akretion.com). All Rights Reserved +# Copyright (C) 2011-2013 Akretion (http://www.akretion.com) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,9 +20,9 @@ # ############################################################################## -import country -import product -import tax -import partner_address -import intrastat_common - +from . import country +from . import product +from . import tax +from . import partner +from . import company +from . import intrastat_common diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py index 089173a..973786b 100644 --- a/intrastat_base/__openerp__.py +++ b/intrastat_base/__openerp__.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for OpenERP -# Copyright (C) 2011 Akretion (http://www.akretion.com). All Rights Reserved +# Copyright (C) 2011-2013 Akretion (http://www.akretion.com) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -22,14 +22,15 @@ { - 'name': 'Base module for Intrastat reporting', + 'name': 'Intrastat Reporting Base', 'version': '1.1', 'category': 'Localisation/Report Intrastat', 'license': 'AGPL-3', + 'summary': 'Base module for Intrastat reporting', 'description': """This module contains the common functions for 2 other modules : - l10n_fr_intrastat_service : the module for the "Déclaration Européenne des Services" (DES) - l10n_fr_intrastat_product : the module for the "Déclaration d'Echange de Biens" (DEB) -This module is not usefull if it's not used together with one of those 2 modules. +This module is not usefull if it's not used together with one of those 2 modules or other country-specific intrastat modules. This module doesn't have any France-specific stuff. So it can be used as a basis for other intrastat modules for other EU countries. @@ -40,15 +41,15 @@ Please contact Alexis de Lattre from Akretion for 'author': 'Akretion', 'website': 'http://www.akretion.com', 'depends': ['base_vat'], - 'init_xml': ['country_data.xml'], - 'update_xml': [ - 'security/ir.model.access.csv', + 'data': [ + 'country_data.xml', 'product_view.xml', 'country_view.xml', 'tax_view.xml', + 'company_view.xml', 'intrastat_menu.xml', ], - 'demo_xml': ['intrastat_demo.xml'], + 'demo': ['intrastat_demo.xml'], 'installable': True, 'active': False, } diff --git a/intrastat_base/company.py b/intrastat_base/company.py new file mode 100644 index 0000000..69163f5 --- /dev/null +++ b/intrastat_base/company.py @@ -0,0 +1,62 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Intrastat base 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, fields +from openerp.tools.translate import _ + + +class res_company(orm.Model): + _inherit = "res.company" + + def _compute_intrastat_email_list(self, cr, uid, ids, name, arg, context=None): + result = {} + for company in self.browse(cr, uid, ids, context=context): + result[company.id] = '' + for user in company.intrastat_remind_user_ids: + if result[company.id]: + result[company.id] += ',%s' % (user.email) + else: + result[company.id] = user.email + return result + + _columns = { + 'intrastat_remind_user_ids': fields.many2many('res.users', + id1='company_id', id2='user_id', + string="Users Receiving the Intrastat Reminder", + help="List of OpenERP users who will receive a notification to remind them about the Intrastat declaration."), + 'intrastat_email_list': fields.function(_compute_intrastat_email_list, + type='char', size=1000, + string='List of emails of Users Receiving the Intrastat Reminder', + help='Comma-separated list of email addresses of Users Receiving the Intrastat Reminder. For use in the email template.'), + } + + def _check_intrastat_remind_users(self, cr, uid, ids): + for company in self.browse(cr, uid, ids): + for user in company.intrastat_remind_user_ids: + if not user.email: + raise orm.except_orm(_('Error :'), _("Missing e-mail address on user '%s'.") % (user.name)) + return True + + _constraints = [ + (_check_intrastat_remind_users, "error msg in raise", + ['intrastat_remind_user_ids']), + ] diff --git a/intrastat_base/company_view.xml b/intrastat_base/company_view.xml new file mode 100644 index 0000000..14cf1fe --- /dev/null +++ b/intrastat_base/company_view.xml @@ -0,0 +1,29 @@ + + + + + + + + + intrastat.company.form + res.company + + + + + + + + + + + + + + + diff --git a/intrastat_base/country.py b/intrastat_base/country.py index 2542d72..2cb923f 100644 --- a/intrastat_base/country.py +++ b/intrastat_base/country.py @@ -20,9 +20,10 @@ # ############################################################################## -from osv import osv, fields +from openerp.osv import orm, fields -class res_country(osv.osv): + +class res_country(orm.Model): _inherit = 'res.country' _columns = { 'intrastat': fields.boolean('EU country', help="Set to True for all European Union countries."), @@ -31,5 +32,3 @@ class res_country(osv.osv): _defaults = { 'intrastat': False, } - -res_country() diff --git a/intrastat_base/country_data.xml b/intrastat_base/country_data.xml index 04fb439..c77f548 100644 --- a/intrastat_base/country_data.xml +++ b/intrastat_base/country_data.xml @@ -83,5 +83,8 @@ + + + diff --git a/intrastat_base/country_view.xml b/intrastat_base/country_view.xml index bf62fa3..87e7ec9 100644 --- a/intrastat_base/country_view.xml +++ b/intrastat_base/country_view.xml @@ -1,7 +1,7 @@ @@ -26,7 +26,7 @@ - + diff --git a/intrastat_base/intrastat_common.py b/intrastat_base/intrastat_common.py index 8320b8a..7a21a62 100644 --- a/intrastat_base/intrastat_common.py +++ b/intrastat_base/intrastat_common.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for OpenERP -# Copyright (C) 2010-2011 Akretion (http://www.akretion.com/). All rights reserved. +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/). All rights reserved. # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,12 +20,16 @@ # ############################################################################## -from osv import osv, fields +from openerp.osv import orm +from openerp.tools.translate import _ from datetime import datetime from dateutil.relativedelta import relativedelta -from tools.translate import _ +import logging -class report_intrastat_common(osv.osv_memory): +logger = logging.getLogger(__name__) + + +class report_intrastat_common(orm.TransientModel): _name = "report.intrastat.common" _description = "Common functions for intrastat reports for products and services" @@ -40,16 +44,17 @@ class report_intrastat_common(osv.osv_memory): result[intrastat.id] = {'num_lines': num_lines, 'total_amount': total_amount} return result - - def _compute_end_date(self, cr, uid, ids, object, context=None): + def _compute_dates(self, cr, uid, ids, object, context=None): result = {} for intrastat in object.browse(cr, uid, ids, context=context): start_date_datetime = datetime.strptime(intrastat.start_date, '%Y-%m-%d') end_date_str = datetime.strftime(start_date_datetime + relativedelta(day=31), '%Y-%m-%d') - result[intrastat.id] = end_date_str + result[intrastat.id] = { + 'end_date': end_date_str, + 'year_month': start_date_datetime.strftime('%Y-%m'), + } return result - def _check_start_date(self, cr, uid, ids, object, context=None): '''Check that the start date is the first day of the month''' for date_to_check in object.read(cr, uid, ids, ['start_date'], context=context): @@ -58,54 +63,47 @@ class report_intrastat_common(osv.osv_memory): return False return True - def _check_generate_lines(self, cr, uid, intrastat, context=None): if not intrastat.company_id.country_id: - raise osv.except_osv(_('Error :'), _("The country is not set on the company '%s'.") %intrastat.company_id.name) + raise orm.except_orm(_('Error :'), _("The country is not set on the company '%s'.") % intrastat.company_id.name) if not intrastat.currency_id.name == 'EUR': - raise osv.except_osv(_('Error :'), _("The company currency must be 'EUR', but is currently '%s'.") %intrastat.currency_id.name) + raise orm.except_orm(_('Error :'), _("The company currency must be 'EUR', but is currently '%s'.") % intrastat.currency_id.name) return True - def _check_generate_xml(self, cr, uid, intrastat, context=None): if not intrastat.company_id.partner_id.vat: - raise osv.except_osv(_('Error :'), _("The VAT number is not set for the partner '%s'.") %intrastat.company_id.partner_id.name) + raise orm.except_orm(_('Error :'), _("The VAT number is not set for the partner '%s'.") % intrastat.company_id.partner_id.name) return True - def _check_xml_schema(self, cr, uid, xml_root, xml_string, xsd, context=None): '''Validate the XML file against the XSD''' from lxml import etree official_des_xml_schema = etree.XMLSchema(etree.fromstring(xsd)) - try: official_des_xml_schema.assertValid(xml_root) + try: + official_des_xml_schema.assertValid(xml_root) except Exception, e: # if the validation of the XSD fails, we arrive here import logging _logger = logging.getLogger(__name__) _logger.warning("The XML file is invalid against the XML Schema Definition") _logger.warning(xml_string) _logger.warning(e) - raise osv.except_osv(_('Error :'), _('The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s.') % str(e)) + raise orm.except_orm(_('Error :'), _('The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s.') % str(e)) return True - def _attach_xml_file(self, cr, uid, ids, object, xml_string, start_date_datetime, declaration_name, context=None): '''Attach the XML file to the report_intrastat_product/service object''' import base64 - if len(ids) != 1: - raise osv.except_osv(_('Error :'), 'Hara kiri in attach_xml_file') + assert len(ids) == 1, "Only one ID accepted" filename = datetime.strftime(start_date_datetime, '%Y-%m') + '_' + declaration_name + '.xml' - attach_name = declaration_name.upper() + ' ' + datetime.strftime(start_date_datetime, '%Y-%m') attach_obj = self.pool.get('ir.attachment') if not context: context = {} - context.update({'default_res_id' : ids[0], 'default_res_model': object._name}) - attach_id = attach_obj.create(cr, uid, {'name': attach_name, 'datas': base64.encodestring(xml_string), 'datas_fname': filename}, context=context) + context.update({'default_res_id': ids[0], 'default_res_model': object._name}) + attach_id = attach_obj.create(cr, uid, {'name': filename, 'datas': base64.encodestring(xml_string), 'datas_fname': filename}, context=context) return attach_id - def _open_attach_view(self, cr, uid, attach_id, title='XML file', context=None): '''Returns an action which opens the form view of the corresponding attachement''' - # Only works in v6 -> not used in v5 action = { 'name': title, 'view_type': 'form', @@ -115,11 +113,10 @@ class report_intrastat_common(osv.osv_memory): 'type': 'ir.actions.act_window', 'nodestroy': True, 'target': 'current', - 'res_id': [attach_id], + 'res_id': attach_id, } return action - def partner_on_change(self, cr, uid, ids, partner_id=False): result = {} result['value'] = {} @@ -128,5 +125,15 @@ class report_intrastat_common(osv.osv_memory): result['value'].update({'partner_vat': company['vat']}) return result -report_intrastat_common() - + def send_reminder_email(self, cr, uid, company, module_name, template_xmlid, intrastat_id, context=None): + template_data = self.pool['ir.model.data'].get_object_reference(cr, uid, module_name, template_xmlid) + if template_data and template_data[0] == 'email.template': + template_id = template_data[1] + else: + raise orm.except_orm(_('Error :'), _("Wrong model for XMLID '%s.%s': model is '%s' and it should be 'email.template'.") % (module_name, template_xmlid, template_data[0])) + if company.intrastat_remind_user_ids: + self.pool['email.template'].send_mail(cr, uid, template_id, intrastat_id, context=context) + logger.info('Intrastat Reminder email has been sent (XMLID: %s).' % template_xmlid) + else: + logger.warning('The list of users receiving the Intrastat Reminder is empty on company %s' % company.name) + return True diff --git a/intrastat_base/intrastat_demo.xml b/intrastat_base/intrastat_demo.xml index d83640e..07c68ab 100644 --- a/intrastat_base/intrastat_demo.xml +++ b/intrastat_base/intrastat_demo.xml @@ -1,7 +1,7 @@ @@ -13,7 +13,7 @@ FR58441019213 - + BE0828696437 True @@ -23,7 +23,7 @@ True - + BE0884025633 True @@ -48,7 +48,7 @@ Shipping costs SHIP service - + 30 True diff --git a/intrastat_base/intrastat_menu.xml b/intrastat_base/intrastat_menu.xml index b078c6a..83434cb 100644 --- a/intrastat_base/intrastat_menu.xml +++ b/intrastat_base/intrastat_menu.xml @@ -1,7 +1,7 @@ diff --git a/intrastat_base/partner_address.py b/intrastat_base/partner.py similarity index 77% rename from intrastat_base/partner_address.py rename to intrastat_base/partner.py index f36329b..a87c0ed 100644 --- a/intrastat_base/partner_address.py +++ b/intrastat_base/partner.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for OpenERP -# Copyright (C) 2010-2011 Akretion (http://www.akretion.com/) All Rights Reserved +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,16 +20,14 @@ # ############################################################################## -from osv import osv, fields +from openerp.osv import orm, fields -# We want to have the country field on res_partner_address always set + +# We want to have the country field on res_partner always set # because the selection of invoices for intrastat reports is based -# on the country of the invoice partner address ! -class res_partner_address(osv.osv): - _inherit = 'res.partner.address' +# on the country of the invoice partner ! +class res_partner(orm.Model): + _inherit = 'res.partner' _columns = { 'country_id': fields.many2one('res.country', 'Country', required=True), } - -res_partner_address() - diff --git a/intrastat_base/product.py b/intrastat_base/product.py index c535a72..60132f0 100644 --- a/intrastat_base/product.py +++ b/intrastat_base/product.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for OpenERP -# Copyright (C) 2010-2012 Akretion (http://www.akretion.com/) All Rights Reserved +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,30 +20,28 @@ # ############################################################################## -from osv import osv, fields -from tools.translate import _ +from openerp.osv import orm, fields +from openerp.tools.translate import _ -class product_template(osv.osv): + +class product_template(orm.Model): _inherit = "product.template" _columns = { 'exclude_from_intrastat': fields.boolean('Exclude from Intrastat reports', help="If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason."), - 'is_accessory_cost' : fields.boolean('Is accessory cost', help='Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports.'), + 'is_accessory_cost': fields.boolean('Is accessory cost', help='Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports.'), } _defaults = { 'exclude_from_intrastat': False, } - def _check_accessory_cost(self, cr, uid, ids): for product in self.browse(cr, uid, ids): if product.is_accessory_cost and product.type != 'service': - raise osv.except_osv(_('Error :'), _("The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" % (product.name, product.type))) + raise orm.except_orm(_('Error :'), _("The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" % (product.name, product.type))) return True _constraints = [ - (_check_accessory_cost, "Error msg is in raise", ['is_accessory_cost', 'type']) + (_check_accessory_cost, "Error msg is in raise", + ['is_accessory_cost', 'type']) ] - -product_template() - diff --git a/intrastat_base/product_view.xml b/intrastat_base/product_view.xml index 28b026e..fd7c2d4 100644 --- a/intrastat_base/product_view.xml +++ b/intrastat_base/product_view.xml @@ -1,7 +1,7 @@ @@ -15,17 +15,12 @@ product.product - - - - - - - - + + + - - + + @@ -35,17 +30,12 @@ product.template - - - - - - - - + + + - - + + diff --git a/intrastat_base/tax.py b/intrastat_base/tax.py index 4d12d32..5e933d1 100644 --- a/intrastat_base/tax.py +++ b/intrastat_base/tax.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for OpenERP -# Copyright (C) 2011 Akretion (http://www.akretion.com). All Rights Reserved +# Copyright (C) 2011-2013 Akretion (http://www.akretion.com). All Rights Reserved # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,14 +20,11 @@ # ############################################################################## -from osv import osv, fields +from openerp.osv import orm, fields -class account_tax(osv.osv): +class account_tax(orm.Model): _inherit = "account.tax" _columns = { 'exclude_from_intrastat_if_present': fields.boolean('Exclude invoice line from intrastat if this tax is present', help="If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices."), } - -account_tax() - diff --git a/intrastat_base/tax_view.xml b/intrastat_base/tax_view.xml index e60a327..c481490 100644 --- a/intrastat_base/tax_view.xml +++ b/intrastat_base/tax_view.xml @@ -17,8 +17,8 @@ - - + + From 84b4be792b5fa8c24517da1b505c6422292fbecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=A9al?= Date: Sun, 9 Mar 2014 09:29:59 +0100 Subject: [PATCH 03/39] [FIX] intrastat_base: Several things * switch required=True for country_id from model to views in res.partner * xpath in partner view as Niels Huylebroeck suggest * simplify first xpath too in partner view * xpath in a more generic way --- intrastat_base/__init__.py | 1 - intrastat_base/__openerp__.py | 1 + intrastat_base/partner.py | 33 --------------------------------- intrastat_base/partner_view.xml | 31 +++++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 34 deletions(-) delete mode 100644 intrastat_base/partner.py create mode 100644 intrastat_base/partner_view.xml diff --git a/intrastat_base/__init__.py b/intrastat_base/__init__.py index 8e2eaa0..3070e32 100644 --- a/intrastat_base/__init__.py +++ b/intrastat_base/__init__.py @@ -23,6 +23,5 @@ from . import country from . import product from . import tax -from . import partner from . import company from . import intrastat_common diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py index 973786b..9661bd8 100644 --- a/intrastat_base/__openerp__.py +++ b/intrastat_base/__openerp__.py @@ -44,6 +44,7 @@ Please contact Alexis de Lattre from Akretion for 'data': [ 'country_data.xml', 'product_view.xml', + 'partner_view.xml', 'country_view.xml', 'tax_view.xml', 'company_view.xml', diff --git a/intrastat_base/partner.py b/intrastat_base/partner.py deleted file mode 100644 index a87c0ed..0000000 --- a/intrastat_base/partner.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Report intrastat base module for OpenERP -# Copyright (C) 2010-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, fields - - -# We want to have the country field on res_partner always set -# because the selection of invoices for intrastat reports is based -# on the country of the invoice partner ! -class res_partner(orm.Model): - _inherit = 'res.partner' - _columns = { - 'country_id': fields.many2one('res.country', 'Country', required=True), - } diff --git a/intrastat_base/partner_view.xml b/intrastat_base/partner_view.xml new file mode 100644 index 0000000..7dc9f4e --- /dev/null +++ b/intrastat_base/partner_view.xml @@ -0,0 +1,31 @@ + + + + + + + + + + res.partner + + + + {'readonly': [('use_parent_address','=',True)], 'required': True} + + + + {'required': True} + + + + + + + From 41bab17d0c6d1e846d6a3e210af699db457bddb8 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 14 Apr 2014 16:32:08 +0200 Subject: [PATCH 04/39] [IMP] intrastat_base: Several improvements: * Use l10n_fr_* : use the method _company_default_get() intrastat_base : - the module is now PEP-8 compliant ! - add search view on countries - is_accessory_cost is now invisible when product != service - update POT file and FR translation - remove double import of logging lib * Add context in on_change (to be able to use web_context_tunnel) XSD files are now pure XSD files, not python file with the content as string. Convert l10n_fr_intrastat_service to PEP-8 Start to convert l10n_fr_intrastat_product to PEP-8 (not finished yet) l10n_fr_intrastat_product : Update POT file and FR translation. * l10n_fr_intrastat_service : update POT file and FR translation. l10n_fr_intrastat_product : continue PEP-8 compliance --- intrastat_base/company.py | 22 +- intrastat_base/country.py | 6 +- intrastat_base/country_view.xml | 15 ++ intrastat_base/i18n/fr_FR.po | 271 +++++++++++++------------ intrastat_base/i18n/intrastat_base.pot | 245 ++++++++++++---------- intrastat_base/intrastat_common.py | 124 +++++++---- intrastat_base/product.py | 21 +- intrastat_base/product_view.xml | 6 +- intrastat_base/tax.py | 9 +- 9 files changed, 426 insertions(+), 293 deletions(-) diff --git a/intrastat_base/company.py b/intrastat_base/company.py index 69163f5..030101f 100644 --- a/intrastat_base/company.py +++ b/intrastat_base/company.py @@ -27,7 +27,8 @@ from openerp.tools.translate import _ class res_company(orm.Model): _inherit = "res.company" - def _compute_intrastat_email_list(self, cr, uid, ids, name, arg, context=None): + def _compute_intrastat_email_list( + self, cr, uid, ids, name, arg, context=None): result = {} for company in self.browse(cr, uid, ids, context=context): result[company.id] = '' @@ -39,21 +40,24 @@ class res_company(orm.Model): return result _columns = { - 'intrastat_remind_user_ids': fields.many2many('res.users', - id1='company_id', id2='user_id', + 'intrastat_remind_user_ids': fields.many2many( + 'res.users', id1='company_id', id2='user_id', string="Users Receiving the Intrastat Reminder", - help="List of OpenERP users who will receive a notification to remind them about the Intrastat declaration."), - 'intrastat_email_list': fields.function(_compute_intrastat_email_list, - type='char', size=1000, - string='List of emails of Users Receiving the Intrastat Reminder', - help='Comma-separated list of email addresses of Users Receiving the Intrastat Reminder. For use in the email template.'), + help="List of OpenERP users who will receive a notification to " + "remind them about the Intrastat declaration."), + 'intrastat_email_list': fields.function( + _compute_intrastat_email_list, type='char', size=1000, + string='List of emails of Users Receiving the Intrastat Reminder'), } def _check_intrastat_remind_users(self, cr, uid, ids): for company in self.browse(cr, uid, ids): for user in company.intrastat_remind_user_ids: if not user.email: - raise orm.except_orm(_('Error :'), _("Missing e-mail address on user '%s'.") % (user.name)) + raise orm.except_orm( + _('Error :'), + _("Missing e-mail address on user '%s'.") + % (user.name)) return True _constraints = [ diff --git a/intrastat_base/country.py b/intrastat_base/country.py index 2cb923f..e967e92 100644 --- a/intrastat_base/country.py +++ b/intrastat_base/country.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for OpenERP -# Copyright (C) 2011-2013 Akretion (http://www.akretion.com). All Rights Reserved +# Copyright (C) 2011-2013 Akretion (http://www.akretion.com). # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -26,7 +26,9 @@ from openerp.osv import orm, fields class res_country(orm.Model): _inherit = 'res.country' _columns = { - 'intrastat': fields.boolean('EU country', help="Set to True for all European Union countries."), + 'intrastat': fields.boolean( + 'EU Country', + help="Set to True for all European Union countries."), } _defaults = { diff --git a/intrastat_base/country_view.xml b/intrastat_base/country_view.xml index 87e7ec9..2177dbb 100644 --- a/intrastat_base/country_view.xml +++ b/intrastat_base/country_view.xml @@ -31,6 +31,21 @@ + + + intrastat.base.country.search + res.country + + + + + + + + + + diff --git a/intrastat_base/i18n/fr_FR.po b/intrastat_base/i18n/fr_FR.po index c3a85fe..77ac6e9 100644 --- a/intrastat_base/i18n/fr_FR.po +++ b/intrastat_base/i18n/fr_FR.po @@ -4,11 +4,11 @@ # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 6.0.4\n" -"Report-Msgid-Bugs-To: support@openerp.com\n" -"POT-Creation-Date: 2012-06-05 13:28+0000\n" -"PO-Revision-Date: 2012-06-05 13:28+0000\n" -"Last-Translator: <>\n" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-04-14 14:18+0000\n" +"PO-Revision-Date: 2014-04-14 14:18+0000\n" +"Last-Translator: Alexis de Lattre \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -16,122 +16,24 @@ msgstr "" "Plural-Forms: \n" #. module: intrastat_base -#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root -msgid "Intrastat reporting" -msgstr "DEB et DES" +#: help:product.template,is_accessory_cost:0 +msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." +msgstr "Activez cette option pour les frais de port, les frais d'emballage et tous les services liés à la vente de produits physiques. Cette option est utilisée pour la DEB et la DES." #. module: intrastat_base -#: sql_constraint:res.country:0 -msgid "The code of the country must be unique !" -msgstr "Le code du pays doit être unique !" - -#. module: intrastat_base -#: constraint:product.template:0 -msgid "Error: The default UOM and the purchase UOM must be in the same category." -msgstr "Erreur: l'UdM par défaut et l'UdM d'achat doivent appartenir à la même catégorie." - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:64 -#: code:addons/intrastat_base/intrastat_common.py:70 -#: code:addons/intrastat_base/intrastat_common.py:85 -#: code:addons/intrastat_base/intrastat_common.py:93 -#: code:addons/intrastat_base/product.py:41 -#, python-format -msgid "Error :" -msgstr "Erreur :" - -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_account_tax -msgid "account.tax" -msgstr "account.tax" - -#. module: intrastat_base -#: field:account.tax,exclude_from_intrastat_if_present:0 -msgid "Exclude invoice line from intrastat if this tax is present" -msgstr "Exclue la ligne de facture de la DEB/DES si cette taxe est présente" - -#. module: intrastat_base -#: help:res.country,intrastat:0 -msgid "Set as True for countries that must be selected in the intrastat reports, i.e. for all European Union countries other than your own country." -msgstr "Activer cette option pour les pays qui doivent être inclus dans la DEB et la DES, i.e. tous les pays de l'Union Européenne sauf votre propre pays." - -#. module: intrastat_base -#: view:product.product:0 -#: view:product.template:0 -msgid "Intrastat properties" -msgstr "Paramètres pour la DEB et la DES" - -#. module: intrastat_base -#: model:ir.module.module,description:intrastat_base.module_meta_information -msgid "This module contains the common functions for 2 other modules :\n" -"- l10n_fr_intrastat_service : the module for the \"Déclaration Européenne des Services\" (DES)\n" -"- l10n_fr_intrastat_product : the module for the \"Déclaration d'Echange de Biens\" (DEB)\n" -"This module is not usefull if it's not used together with one of those 2 modules.\n" -"\n" -"This module doesn't have any France-specific stuff. So it can be used as a basis for other intrastat modules for other EU countries.\n" -"\n" -"WARNING : this module conflicts with the module \"report_intrastat\" from the addons. If you have already installed the module \"report_intrastat\", you should uninstall it first before installing this module.\n" -"\n" -"Please contact Alexis de Lattre from Akretion for any help or question about this module.\n" -" " -msgstr "This module contains the common functions for 2 other modules :\n" -"- l10n_fr_intrastat_service : the module for the \"Déclaration Européenne des Services\" (DES)\n" -"- l10n_fr_intrastat_product : the module for the \"Déclaration d'Echange de Biens\" (DEB)\n" -"This module is not usefull if it's not used together with one of those 2 modules.\n" -"\n" -"This module doesn't have any France-specific stuff. So it can be used as a basis for other intrastat modules for other EU countries.\n" -"\n" -"WARNING : this module conflicts with the module \"report_intrastat\" from the addons. If you have already installed the module \"report_intrastat\", you should uninstall it first before installing this module.\n" -"\n" -"Please contact Alexis de Lattre from Akretion for any help or question about this module.\n" -" " - -#. module: intrastat_base -#: sql_constraint:res.country:0 -msgid "The name of the country must be unique !" -msgstr "Le nom du pays doit être unique !" - -#. module: intrastat_base -#: constraint:product.template:0 -msgid "Error msg is in raise" -msgstr "Error msg is in raise" - -#. module: intrastat_base -#: help:account.tax,exclude_from_intrastat_if_present:0 -msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." -msgstr "Si cette taxe est présente sur une ligne de facture, cette ligne de facture ne sera pas prise en compte lors de la génération de la DEB et de la DES depuis les factures." - -#. module: intrastat_base -#: field:product.template,is_accessory_cost:0 -msgid "Is accessory cost" -msgstr "Frais accessoires" - -#. module: intrastat_base -#: field:res.country,intrastat:0 -msgid "Intrastat country" -msgstr "Pays intrastat" - -#. module: intrastat_base -#: help:product.template,exclude_from_intrastat:0 -msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason." -msgstr "Si l'option est activée, le produit ou service ne sera pris en compte ni pour la DEB ni pour la DES. Cette option doit donc rester désactivée sauf si vous avez une très bonne raison." - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:64 -#, python-format -msgid "The company currency must be 'EUR', but is currently '%s'." -msgstr "La monnaie de la société doit être 'EUR', mais est actuellement '%s'." - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:70 -#, python-format -msgid "The VAT number is not set for the partner '%s'." -msgstr "Le numéro de TVA n'est pas renseigné pour le partenaire '%s'." +#: view:res.company:0 +msgid "Common Intrastat Settings" +msgstr "Paramètres communs DEB et DES" #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_report_intrastat_common msgid "Common functions for intrastat reports for products and services" -msgstr "Common functions for intrastat reports for products and services" +msgstr "Fonctions communes pour la DEB et la DES" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_company +msgid "Companies" +msgstr "Sociétés" #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_res_country @@ -139,14 +41,26 @@ msgid "Country" msgstr "Pays" #. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_product_template -msgid "Product Template" -msgstr "Modèle de produit" +#: view:res.country:0 +#: field:res.country,intrastat:0 +msgid "EU Country" +msgstr "Pays UE" #. module: intrastat_base -#: model:ir.module.module,shortdesc:intrastat_base.module_meta_information -msgid "Base module for Intrastat reporting" -msgstr "Module de base pour les rapports intrastat" +#: code:addons/intrastat_base/company.py:58 +#: code:addons/intrastat_base/intrastat_common.py:77 +#: code:addons/intrastat_base/intrastat_common.py:82 +#: code:addons/intrastat_base/intrastat_common.py:90 +#: code:addons/intrastat_base/intrastat_common.py:110 +#: code:addons/intrastat_base/product.py:51 +#, python-format +msgid "Error :" +msgstr "Erreur :" + +#. module: intrastat_base +#: constraint:product.template:0 +msgid "Error msg is in raise" +msgstr "Error msg is in raise" #. module: intrastat_base #: field:product.template,exclude_from_intrastat:0 @@ -154,9 +68,76 @@ msgid "Exclude from Intrastat reports" msgstr "Exclure de la DEB et de la DES" #. module: intrastat_base -#: help:product.template,is_accessory_cost:0 -msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." -msgstr "Activez cette option pour les frais de port, les frais d'emballage et tous les services liés à la vente de produits physiques. Cette option est utilisée pour la DEB et la DES." +#: field:account.tax,exclude_from_intrastat_if_present:0 +msgid "Exclude invoice line from intrastat if this tax is present" +msgstr "Exclue la ligne de facture de la DEB/DES si cette taxe est présente" + +#. module: intrastat_base +#: help:product.template,exclude_from_intrastat:0 +msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason." +msgstr "Si l'option est activée, le produit ou service ne sera pris en compte ni pour la DEB ni pour la DES. Cette option doit donc rester désactivée sauf si vous avez une très bonne raison." + +#. module: intrastat_base +#: help:account.tax,exclude_from_intrastat_if_present:0 +msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." +msgstr "Si cette taxe est présente sur une ligne de facture, cette ligne de facture ne sera pas prise en compte lors de la génération de la DEB et de la DES depuis les factures." + +#. module: intrastat_base +#: view:product.product:0 +#: view:product.template:0 +msgid "Intrastat Properties" +msgstr "Propriétés DEB/DES" + +#. module: intrastat_base +#: view:res.company:0 +msgid "Intrastat Settings" +msgstr "Configuration DEB/DES" + +#. module: intrastat_base +#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root +msgid "Intrastat reporting" +msgstr "DEB et DES" + +#. module: intrastat_base +#: field:product.template,is_accessory_cost:0 +msgid "Is accessory cost" +msgstr "Frais accessoires" + +#. module: intrastat_base +#: help:res.company,intrastat_remind_user_ids:0 +msgid "List of OpenERP users who will receive a notification to remind them about the Intrastat declaration." +msgstr "Liste d'utilisateurs OpenERP qui recevront le rappel pour la DEB et/ou la DES." + +#. module: intrastat_base +#: field:res.company,intrastat_email_list:0 +msgid "List of emails of Users Receiving the Intrastat Reminder" +msgstr "Liste des emails d'utilisateurs qui recevront le rappel pour la DEB et/ou la DES" + +#. module: intrastat_base +#: code:addons/intrastat_base/company.py:59 +#, python-format +msgid "Missing e-mail address on user '%s'." +msgstr "Adresse e-mail manquante sur l'utilisateur '%s'." + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_partner +msgid "Partner" +msgstr "Partenaire" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: intrastat_base +#: view:res.country:0 +msgid "Search Countries" +msgstr "Recherche des pays" + +#. module: intrastat_base +#: help:res.country,intrastat:0 +msgid "Set to True for all European Union countries." +msgstr "A cocher pour tous les pays de l'Union Européenne." #. module: intrastat_base #: model:product.template,name:intrastat_base.shipping_costs_exclude_product_template @@ -164,13 +145,47 @@ msgid "Shipping costs" msgstr "Frais de port" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:85 +#: model:ir.model,name:intrastat_base.model_account_tax +msgid "Tax" +msgstr "Taxes" + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:91 +#, python-format +msgid "The VAT number is not set for the partner '%s'." +msgstr "Le numéro de TVA n'est pas renseigné pour le partenaire '%s'." + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:83 +#, python-format +msgid "The company currency must be 'EUR', but is currently '%s'." +msgstr "La monnaie de la société doit être 'EUR', mais est actuellement '%s'." + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:78 +#, python-format +msgid "The country is not set on the company '%s'." +msgstr "Le pays n'est pas renseigné sur la société '%s'." + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:111 #, python-format msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." msgstr "La validation du fichier XML avec le schéma XML officiel a échoué. Le fichier XML généré et le détail de l'erreur ont été écrits dans les logs du serveur. Voici le message d'erreur, qui peut vous donner une idée de la cause du problème : %s." #. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_res_partner_address -msgid "Partner Addresses" -msgstr "Carnet d'adresses" +#: code:addons/intrastat_base/product.py:56 +#, python-format +msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" +msgstr "L'option 'Frais accessoires' ne doit être activée que sur les produits de type 'Service'. Vous avez activé cette option sur le produit '%s' qui est de type '%s'" + +#. module: intrastat_base +#: field:res.company,intrastat_remind_user_ids:0 +msgid "Users Receiving the Intrastat Reminder" +msgstr "Utilisateurs qui reçoivent le rappel DEB/DES" + +#. module: intrastat_base +#: constraint:res.company:0 +msgid "error msg in raise" +msgstr "error msg in raise" diff --git a/intrastat_base/i18n/intrastat_base.pot b/intrastat_base/i18n/intrastat_base.pot index d7baf12..b170abd 100644 --- a/intrastat_base/i18n/intrastat_base.pot +++ b/intrastat_base/i18n/intrastat_base.pot @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 6.0.4\n" -"Report-Msgid-Bugs-To: support@openerp.com\n" -"POT-Creation-Date: 2012-06-05 13:28+0000\n" -"PO-Revision-Date: 2012-06-05 13:28+0000\n" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-04-14 14:18+0000\n" +"PO-Revision-Date: 2014-04-14 14:18+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,106 +16,13 @@ msgstr "" "Plural-Forms: \n" #. module: intrastat_base -#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root -msgid "Intrastat reporting" +#: help:product.template,is_accessory_cost:0 +msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." msgstr "" #. module: intrastat_base -#: sql_constraint:res.country:0 -msgid "The code of the country must be unique !" -msgstr "" - -#. module: intrastat_base -#: constraint:product.template:0 -msgid "Error: The default UOM and the purchase UOM must be in the same category." -msgstr "" - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:64 -#: code:addons/intrastat_base/intrastat_common.py:70 -#: code:addons/intrastat_base/intrastat_common.py:85 -#: code:addons/intrastat_base/intrastat_common.py:93 -#: code:addons/intrastat_base/product.py:41 -#, python-format -msgid "Error :" -msgstr "" - -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_account_tax -msgid "account.tax" -msgstr "" - -#. module: intrastat_base -#: field:account.tax,exclude_from_intrastat_if_present:0 -msgid "Exclude invoice line from intrastat if this tax is present" -msgstr "" - -#. module: intrastat_base -#: help:res.country,intrastat:0 -msgid "Set as True for countries that must be selected in the intrastat reports, i.e. for all European Union countries other than your own country." -msgstr "" - -#. module: intrastat_base -#: view:product.product:0 -#: view:product.template:0 -msgid "Intrastat properties" -msgstr "" - -#. module: intrastat_base -#: model:ir.module.module,description:intrastat_base.module_meta_information -msgid "This module contains the common functions for 2 other modules :\n" -"- l10n_fr_intrastat_service : the module for the \"Déclaration Européenne des Services\" (DES)\n" -"- l10n_fr_intrastat_product : the module for the \"Déclaration d'Echange de Biens\" (DEB)\n" -"This module is not usefull if it's not used together with one of those 2 modules.\n" -"\n" -"This module doesn't have any France-specific stuff. So it can be used as a basis for other intrastat modules for other EU countries.\n" -"\n" -"WARNING : this module conflicts with the module \"report_intrastat\" from the addons. If you have already installed the module \"report_intrastat\", you should uninstall it first before installing this module.\n" -"\n" -"Please contact Alexis de Lattre from Akretion for any help or question about this module.\n" -" " -msgstr "" - -#. module: intrastat_base -#: sql_constraint:res.country:0 -msgid "The name of the country must be unique !" -msgstr "" - -#. module: intrastat_base -#: constraint:product.template:0 -msgid "Error msg is in raise" -msgstr "" - -#. module: intrastat_base -#: help:account.tax,exclude_from_intrastat_if_present:0 -msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." -msgstr "" - -#. module: intrastat_base -#: field:product.template,is_accessory_cost:0 -msgid "Is accessory cost" -msgstr "" - -#. module: intrastat_base -#: field:res.country,intrastat:0 -msgid "Intrastat country" -msgstr "" - -#. module: intrastat_base -#: help:product.template,exclude_from_intrastat:0 -msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason." -msgstr "" - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:64 -#, python-format -msgid "The company currency must be 'EUR', but is currently '%s'." -msgstr "" - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:70 -#, python-format -msgid "The VAT number is not set for the partner '%s'." +#: view:res.company:0 +msgid "Common Intrastat Settings" msgstr "" #. module: intrastat_base @@ -123,19 +30,36 @@ msgstr "" msgid "Common functions for intrastat reports for products and services" msgstr "" +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_company +msgid "Companies" +msgstr "" + #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_res_country msgid "Country" msgstr "" #. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_product_template -msgid "Product Template" +#: view:res.country:0 +#: field:res.country,intrastat:0 +msgid "EU Country" msgstr "" #. module: intrastat_base -#: model:ir.module.module,shortdesc:intrastat_base.module_meta_information -msgid "Base module for Intrastat reporting" +#: code:addons/intrastat_base/company.py:58 +#: code:addons/intrastat_base/intrastat_common.py:77 +#: code:addons/intrastat_base/intrastat_common.py:82 +#: code:addons/intrastat_base/intrastat_common.py:90 +#: code:addons/intrastat_base/intrastat_common.py:110 +#: code:addons/intrastat_base/product.py:51 +#, python-format +msgid "Error :" +msgstr "" + +#. module: intrastat_base +#: constraint:product.template:0 +msgid "Error msg is in raise" msgstr "" #. module: intrastat_base @@ -144,8 +68,75 @@ msgid "Exclude from Intrastat reports" msgstr "" #. module: intrastat_base -#: help:product.template,is_accessory_cost:0 -msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." +#: field:account.tax,exclude_from_intrastat_if_present:0 +msgid "Exclude invoice line from intrastat if this tax is present" +msgstr "" + +#. module: intrastat_base +#: help:product.template,exclude_from_intrastat:0 +msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason." +msgstr "" + +#. module: intrastat_base +#: help:account.tax,exclude_from_intrastat_if_present:0 +msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." +msgstr "" + +#. module: intrastat_base +#: view:product.product:0 +#: view:product.template:0 +msgid "Intrastat Properties" +msgstr "" + +#. module: intrastat_base +#: view:res.company:0 +msgid "Intrastat Settings" +msgstr "" + +#. module: intrastat_base +#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root +msgid "Intrastat reporting" +msgstr "" + +#. module: intrastat_base +#: field:product.template,is_accessory_cost:0 +msgid "Is accessory cost" +msgstr "" + +#. module: intrastat_base +#: help:res.company,intrastat_remind_user_ids:0 +msgid "List of OpenERP users who will receive a notification to remind them about the Intrastat declaration." +msgstr "" + +#. module: intrastat_base +#: field:res.company,intrastat_email_list:0 +msgid "List of emails of Users Receiving the Intrastat Reminder" +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/company.py:59 +#, python-format +msgid "Missing e-mail address on user '%s'." +msgstr "" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_partner +msgid "Partner" +msgstr "" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_product_template +msgid "Product Template" +msgstr "" + +#. module: intrastat_base +#: view:res.country:0 +msgid "Search Countries" +msgstr "" + +#. module: intrastat_base +#: help:res.country,intrastat:0 +msgid "Set to True for all European Union countries." msgstr "" #. module: intrastat_base @@ -154,13 +145,47 @@ msgid "Shipping costs" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:85 +#: model:ir.model,name:intrastat_base.model_account_tax +msgid "Tax" +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:91 +#, python-format +msgid "The VAT number is not set for the partner '%s'." +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:83 +#, python-format +msgid "The company currency must be 'EUR', but is currently '%s'." +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:78 +#, python-format +msgid "The country is not set on the company '%s'." +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:111 #, python-format msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." msgstr "" #. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_res_partner_address -msgid "Partner Addresses" +#: code:addons/intrastat_base/product.py:56 +#, python-format +msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" +msgstr "" + +#. module: intrastat_base +#: field:res.company,intrastat_remind_user_ids:0 +msgid "Users Receiving the Intrastat Reminder" +msgstr "" + +#. module: intrastat_base +#: constraint:res.company:0 +msgid "error msg in raise" msgstr "" diff --git a/intrastat_base/intrastat_common.py b/intrastat_base/intrastat_common.py index 7a21a62..2129f8d 100644 --- a/intrastat_base/intrastat_common.py +++ b/intrastat_base/intrastat_common.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for OpenERP -# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/). All rights reserved. +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/). # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -22,6 +22,7 @@ from openerp.osv import orm from openerp.tools.translate import _ +from openerp import tools from datetime import datetime from dateutil.relativedelta import relativedelta import logging @@ -31,7 +32,8 @@ logger = logging.getLogger(__name__) class report_intrastat_common(orm.TransientModel): _name = "report.intrastat.common" - _description = "Common functions for intrastat reports for products and services" + _description = "Common functions for intrastat reports for products " + "and services" def _compute_numbers(self, cr, uid, ids, object, context=None): result = {} @@ -41,14 +43,19 @@ class report_intrastat_common(orm.TransientModel): for line in intrastat.intrastat_line_ids: total_amount += line.amount_company_currency num_lines += 1 - result[intrastat.id] = {'num_lines': num_lines, 'total_amount': total_amount} + result[intrastat.id] = { + 'num_lines': num_lines, + 'total_amount': total_amount, + } return result def _compute_dates(self, cr, uid, ids, object, context=None): result = {} for intrastat in object.browse(cr, uid, ids, context=context): - start_date_datetime = datetime.strptime(intrastat.start_date, '%Y-%m-%d') - end_date_str = datetime.strftime(start_date_datetime + relativedelta(day=31), '%Y-%m-%d') + start_date_datetime = datetime.strptime( + intrastat.start_date, '%Y-%m-%d') + end_date_str = datetime.strftime( + start_date_datetime + relativedelta(day=31), '%Y-%m-%d') result[intrastat.id] = { 'end_date': end_date_str, 'year_month': start_date_datetime.strftime('%Y-%m'), @@ -57,53 +64,89 @@ class report_intrastat_common(orm.TransientModel): def _check_start_date(self, cr, uid, ids, object, context=None): '''Check that the start date is the first day of the month''' - for date_to_check in object.read(cr, uid, ids, ['start_date'], context=context): - datetime_to_check = datetime.strptime(date_to_check['start_date'], '%Y-%m-%d') + for date_to_check in object.read( + cr, uid, ids, ['start_date'], context=context): + datetime_to_check = datetime.strptime( + date_to_check['start_date'], '%Y-%m-%d') if datetime_to_check.day != 1: return False return True def _check_generate_lines(self, cr, uid, intrastat, context=None): if not intrastat.company_id.country_id: - raise orm.except_orm(_('Error :'), _("The country is not set on the company '%s'.") % intrastat.company_id.name) + raise orm.except_orm( + _('Error :'), + _("The country is not set on the company '%s'.") + % intrastat.company_id.name) if not intrastat.currency_id.name == 'EUR': - raise orm.except_orm(_('Error :'), _("The company currency must be 'EUR', but is currently '%s'.") % intrastat.currency_id.name) + raise orm.except_orm( + _('Error :'), + _("The company currency must be 'EUR', but is currently '%s'.") + % intrastat.currency_id.name) return True def _check_generate_xml(self, cr, uid, intrastat, context=None): if not intrastat.company_id.partner_id.vat: - raise orm.except_orm(_('Error :'), _("The VAT number is not set for the partner '%s'.") % intrastat.company_id.partner_id.name) + raise orm.except_orm( + _('Error :'), + _("The VAT number is not set for the partner '%s'.") + % intrastat.company_id.partner_id.name) return True - def _check_xml_schema(self, cr, uid, xml_root, xml_string, xsd, context=None): + def _check_xml_schema( + self, cr, uid, xml_root, xml_string, xsd_file, context=None): '''Validate the XML file against the XSD''' from lxml import etree - official_des_xml_schema = etree.XMLSchema(etree.fromstring(xsd)) + xsd_etree_obj = etree.parse( + tools.file_open(xsd_file)) + official_schema = etree.XMLSchema(xsd_etree_obj) try: - official_des_xml_schema.assertValid(xml_root) - except Exception, e: # if the validation of the XSD fails, we arrive here - import logging + official_schema.assertValid(xml_root) + except Exception, e: + # if the validation of the XSD fails, we arrive here _logger = logging.getLogger(__name__) - _logger.warning("The XML file is invalid against the XML Schema Definition") + _logger.warning( + "The XML file is invalid against the XML Schema Definition") _logger.warning(xml_string) _logger.warning(e) - raise orm.except_orm(_('Error :'), _('The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s.') % str(e)) + raise orm.except_orm( + _('Error :'), + _("The generated XML file is not valid against the official " + "XML Schema Definition. The generated XML file and the " + "full error have been written in the server logs. " + "Here is the error, which may give you an idea on the " + "cause of the problem : %s.") + % str(e)) return True - def _attach_xml_file(self, cr, uid, ids, object, xml_string, start_date_datetime, declaration_name, context=None): - '''Attach the XML file to the report_intrastat_product/service object''' + def _attach_xml_file( + self, cr, uid, ids, object, xml_string, start_date_datetime, + declaration_name, context=None): + '''Attach the XML file to the report_intrastat_product/service ''' + '''object''' import base64 assert len(ids) == 1, "Only one ID accepted" - filename = datetime.strftime(start_date_datetime, '%Y-%m') + '_' + declaration_name + '.xml' - attach_obj = self.pool.get('ir.attachment') + filename = '%s_%s.xml' % ( + datetime.strftime(start_date_datetime, '%Y-%m'), + declaration_name) if not context: context = {} - context.update({'default_res_id': ids[0], 'default_res_model': object._name}) - attach_id = attach_obj.create(cr, uid, {'name': filename, 'datas': base64.encodestring(xml_string), 'datas_fname': filename}, context=context) + context.update({ + 'default_res_id': ids[0], + 'default_res_model': object._name + }) + attach_id = self.pool['ir.attachment'].create( + cr, uid, { + 'name': filename, + 'datas': base64.encodestring(xml_string), + 'datas_fname': filename}, + context=context) return attach_id - def _open_attach_view(self, cr, uid, attach_id, title='XML file', context=None): - '''Returns an action which opens the form view of the corresponding attachement''' + def _open_attach_view( + self, cr, uid, attach_id, title='XML file', context=None): + '''Returns an action which opens the form view of the ''' + '''corresponding attachement''' action = { 'name': title, 'view_type': 'form', @@ -117,23 +160,30 @@ class report_intrastat_common(orm.TransientModel): } return action - def partner_on_change(self, cr, uid, ids, partner_id=False): + def partner_on_change(self, cr, uid, ids, partner_id=False, context=None): result = {} result['value'] = {} if partner_id: - company = self.pool.get('res.partner').read(cr, uid, partner_id, ['vat']) - result['value'].update({'partner_vat': company['vat']}) + company = self.pool['res.partner'].read( + cr, uid, partner_id, ['vat'], context=context) + result['value']['partner_vat'] = company['vat'] return result - def send_reminder_email(self, cr, uid, company, module_name, template_xmlid, intrastat_id, context=None): - template_data = self.pool['ir.model.data'].get_object_reference(cr, uid, module_name, template_xmlid) - if template_data and template_data[0] == 'email.template': - template_id = template_data[1] - else: - raise orm.except_orm(_('Error :'), _("Wrong model for XMLID '%s.%s': model is '%s' and it should be 'email.template'.") % (module_name, template_xmlid, template_data[0])) + def send_reminder_email( + self, cr, uid, company, module_name, template_xmlid, + intrastat_id, context=None): + template_model, template_id =\ + self.pool['ir.model.data'].get_object_reference( + cr, uid, module_name, template_xmlid) + assert template_model == 'email.template', 'Wrong model' if company.intrastat_remind_user_ids: - self.pool['email.template'].send_mail(cr, uid, template_id, intrastat_id, context=context) - logger.info('Intrastat Reminder email has been sent (XMLID: %s).' % template_xmlid) + self.pool['email.template'].send_mail( + cr, uid, template_id, intrastat_id, context=context) + logger.info( + 'Intrastat Reminder email has been sent (XMLID: %s).' + % template_xmlid) else: - logger.warning('The list of users receiving the Intrastat Reminder is empty on company %s' % company.name) + logger.warning( + 'The list of users receiving the Intrastat Reminder is empty ' + 'on company %s' % company.name) return True diff --git a/intrastat_base/product.py b/intrastat_base/product.py index 60132f0..7181706 100644 --- a/intrastat_base/product.py +++ b/intrastat_base/product.py @@ -27,8 +27,17 @@ from openerp.tools.translate import _ class product_template(orm.Model): _inherit = "product.template" _columns = { - 'exclude_from_intrastat': fields.boolean('Exclude from Intrastat reports', help="If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason."), - 'is_accessory_cost': fields.boolean('Is accessory cost', help='Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports.'), + 'exclude_from_intrastat': fields.boolean( + 'Exclude from Intrastat reports', + help="If set to True, the product or service will not be " + "taken into account for Intrastat Product or Service reports. " + "So you should leave this field to False unless you have a " + "very good reason."), + 'is_accessory_cost': fields.boolean( + 'Is accessory cost', + help="Activate this option for shipping costs, packaging " + "costs and all services related to the sale of products. " + "This option is used for Intrastat reports."), } _defaults = { @@ -38,7 +47,13 @@ class product_template(orm.Model): def _check_accessory_cost(self, cr, uid, ids): for product in self.browse(cr, uid, ids): if product.is_accessory_cost and product.type != 'service': - raise orm.except_orm(_('Error :'), _("The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" % (product.name, product.type))) + raise orm.except_orm( + _('Error :'), + _("The option 'Is accessory cost?' should only be " + "activated on 'Service' products. You have activated " + "this option for the product '%s' which is of type " + "'%s'" + % (product.name, product.type))) return True _constraints = [ diff --git a/intrastat_base/product_view.xml b/intrastat_base/product_view.xml index fd7c2d4..a551868 100644 --- a/intrastat_base/product_view.xml +++ b/intrastat_base/product_view.xml @@ -18,7 +18,8 @@ - + @@ -33,7 +34,8 @@ - + diff --git a/intrastat_base/tax.py b/intrastat_base/tax.py index 5e933d1..fae6a3d 100644 --- a/intrastat_base/tax.py +++ b/intrastat_base/tax.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for OpenERP -# Copyright (C) 2011-2013 Akretion (http://www.akretion.com). All Rights Reserved +# Copyright (C) 2011-2013 Akretion (http://www.akretion.com). # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -25,6 +25,11 @@ from openerp.osv import orm, fields class account_tax(orm.Model): _inherit = "account.tax" + _columns = { - 'exclude_from_intrastat_if_present': fields.boolean('Exclude invoice line from intrastat if this tax is present', help="If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices."), + 'exclude_from_intrastat_if_present': fields.boolean( + 'Exclude invoice line from intrastat if this tax is present', + help="If this tax is present on an invoice line, this invoice " + "line will be skipped when generating Intrastat Product or " + "Service lines from invoices."), } From a8510ae4d8dc04b3196f7b96be3fd2badbdf790f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 23 Jun 2014 12:12:40 +0200 Subject: [PATCH 05/39] [MIG] intrastat_base: Migration to 8.0 * Add intrastat_type_data and update demo data accordingly Remove version="7.0" from form views Add ondelete='restrict' on M2O pointing to intrastat.type Add graph views on intrastat.product and intrastat.service... because Odoo v8 graph views are so cool ! :) * When the obligation level for import is none, the type of the DEB is automatically set to export. [FIX] country -> country_id type='string' -> type='char' (v8 only accepts char) Change "error msg in raise", because v8 displays this to the user Remove statistical_pricelist_id from demo data Harmonize labels of button between DEB and DES * Add module intrastat_product. Rename report.intrastat.product to l10n.fr.report.intrastat.product (same for service and for lines) + migration scripts * intrastat_base + l10n_fr_intrastat_service : port to new API --- intrastat_base/__init__.py | 4 +- intrastat_base/__openerp__.py | 5 +- intrastat_base/company.py | 70 ++++----- intrastat_base/company_view.xml | 4 +- intrastat_base/country.py | 19 +-- intrastat_base/country_view.xml | 9 +- intrastat_base/i18n/fr_FR.po | 2 +- intrastat_base/i18n/intrastat_base.pot | 2 +- intrastat_base/intrastat_common.py | 189 +++++++++++-------------- intrastat_base/intrastat_demo.xml | 2 +- intrastat_base/intrastat_menu.xml | 4 +- intrastat_base/product.py | 61 ++++---- intrastat_base/product_view.xml | 27 +--- intrastat_base/tax.py | 20 ++- intrastat_base/tax_view.xml | 7 +- 15 files changed, 177 insertions(+), 248 deletions(-) diff --git a/intrastat_base/__init__.py b/intrastat_base/__init__.py index 3070e32..21b2067 100644 --- a/intrastat_base/__init__.py +++ b/intrastat_base/__init__.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for OpenERP -# Copyright (C) 2011-2013 Akretion (http://www.akretion.com) +# Report intrastat base module for Odoo +# Copyright (C) 2011-2014 Akretion (http://www.akretion.com) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py index 9661bd8..179cb4a 100644 --- a/intrastat_base/__openerp__.py +++ b/intrastat_base/__openerp__.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for OpenERP -# Copyright (C) 2011-2013 Akretion (http://www.akretion.com) +# Report intrastat base module for Odoo +# Copyright (C) 2011-2014 Akretion (http://www.akretion.com) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -52,5 +52,4 @@ Please contact Alexis de Lattre from Akretion for ], 'demo': ['intrastat_demo.xml'], 'installable': True, - 'active': False, } diff --git a/intrastat_base/company.py b/intrastat_base/company.py index 030101f..9fea8e4 100644 --- a/intrastat_base/company.py +++ b/intrastat_base/company.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Intrastat base module for OpenERP -# Copyright (C) 2013 Akretion (http://www.akretion.com) +# Intrastat base module for Odoo +# Copyright (C) 2013-2014 Akretion (http://www.akretion.com) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,47 +20,37 @@ # ############################################################################## -from openerp.osv import orm, fields -from openerp.tools.translate import _ +from openerp import models, fields, api, _ +from openerp.exceptions import ValidationError -class res_company(orm.Model): +class ResCompany(models.Model): _inherit = "res.company" - def _compute_intrastat_email_list( - self, cr, uid, ids, name, arg, context=None): - result = {} - for company in self.browse(cr, uid, ids, context=context): - result[company.id] = '' - for user in company.intrastat_remind_user_ids: - if result[company.id]: - result[company.id] += ',%s' % (user.email) - else: - result[company.id] = user.email - return result + @api.one + @api.depends( + 'intrastat_remind_user_ids', 'intrastat_remind_user_ids.email') + def _compute_intrastat_email_list(self): + emails = [] + for user in self.intrastat_remind_user_ids: + if user.email: + emails.append(user.email) + self.intrastat_email_list = ','.join(emails) - _columns = { - 'intrastat_remind_user_ids': fields.many2many( - 'res.users', id1='company_id', id2='user_id', - string="Users Receiving the Intrastat Reminder", - help="List of OpenERP users who will receive a notification to " - "remind them about the Intrastat declaration."), - 'intrastat_email_list': fields.function( - _compute_intrastat_email_list, type='char', size=1000, - string='List of emails of Users Receiving the Intrastat Reminder'), - } + intrastat_remind_user_ids = fields.Many2many( + 'res.users', column1='company_id', column2='user_id', + string="Users Receiving the Intrastat Reminder", + help="List of OpenERP users who will receive a notification to " + "remind them about the Intrastat declaration.") + intrastat_email_list = fields.Char( + compute='_compute_intrastat_email_list', + string='List of emails of Users Receiving the Intrastat Reminder') - def _check_intrastat_remind_users(self, cr, uid, ids): - for company in self.browse(cr, uid, ids): - for user in company.intrastat_remind_user_ids: - if not user.email: - raise orm.except_orm( - _('Error :'), - _("Missing e-mail address on user '%s'.") - % (user.name)) - return True - - _constraints = [ - (_check_intrastat_remind_users, "error msg in raise", - ['intrastat_remind_user_ids']), - ] + @api.one + @api.constrains('intrastat_remind_user_ids') + def _check_intrastat_remind_users(self): + for user in self.intrastat_remind_user_ids: + if not user.email: + raise ValidationError( + _("Missing e-mail address on user '%s'.") + % (user.name)) diff --git a/intrastat_base/company_view.xml b/intrastat_base/company_view.xml index 14cf1fe..87933f4 100644 --- a/intrastat_base/company_view.xml +++ b/intrastat_base/company_view.xml @@ -1,7 +1,7 @@ @@ -9,7 +9,7 @@ - + intrastat.company.form res.company diff --git a/intrastat_base/country.py b/intrastat_base/country.py index e967e92..7f03e5d 100644 --- a/intrastat_base/country.py +++ b/intrastat_base/country.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for OpenERP -# Copyright (C) 2011-2013 Akretion (http://www.akretion.com). +# Report intrastat base module for Odoo +# Copyright (C) 2011-2014 Akretion (http://www.akretion.com). # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,17 +20,12 @@ # ############################################################################## -from openerp.osv import orm, fields +from openerp import models, fields -class res_country(orm.Model): +class ResCountry(models.Model): _inherit = 'res.country' - _columns = { - 'intrastat': fields.boolean( - 'EU Country', - help="Set to True for all European Union countries."), - } - _defaults = { - 'intrastat': False, - } + intrastat = fields.Boolean( + string='EU Country', + help="Set to True for all European Union countries.") diff --git a/intrastat_base/country_view.xml b/intrastat_base/country_view.xml index 2177dbb..d887a22 100644 --- a/intrastat_base/country_view.xml +++ b/intrastat_base/country_view.xml @@ -1,7 +1,7 @@ @@ -9,7 +9,7 @@ - + intrastat.base.country.tree res.country @@ -20,7 +20,7 @@ - + intrastat.base.country.form res.country @@ -32,7 +32,7 @@ - + intrastat.base.country.search res.country @@ -46,6 +46,5 @@ - diff --git a/intrastat_base/i18n/fr_FR.po b/intrastat_base/i18n/fr_FR.po index 77ac6e9..de7e5db 100644 --- a/intrastat_base/i18n/fr_FR.po +++ b/intrastat_base/i18n/fr_FR.po @@ -95,7 +95,7 @@ msgstr "Configuration DEB/DES" #. module: intrastat_base #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root -msgid "Intrastat reporting" +msgid "Intrastat Reporting" msgstr "DEB et DES" #. module: intrastat_base diff --git a/intrastat_base/i18n/intrastat_base.pot b/intrastat_base/i18n/intrastat_base.pot index b170abd..d184def 100644 --- a/intrastat_base/i18n/intrastat_base.pot +++ b/intrastat_base/i18n/intrastat_base.pot @@ -95,7 +95,7 @@ msgstr "" #. module: intrastat_base #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root -msgid "Intrastat reporting" +msgid "Intrastat Reporting" msgstr "" #. module: intrastat_base diff --git a/intrastat_base/intrastat_common.py b/intrastat_base/intrastat_common.py index 2129f8d..fa65afe 100644 --- a/intrastat_base/intrastat_common.py +++ b/intrastat_base/intrastat_common.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for OpenERP -# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/). +# Report intrastat base module for Odoo +# Copyright (C) 2010-2014 Akretion (http://www.akretion.com/). # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,9 +20,9 @@ # ############################################################################## -from openerp.osv import orm -from openerp.tools.translate import _ -from openerp import tools +from openerp import models, api, tools, _ +from openerp.tools import DEFAULT_SERVER_DATE_FORMAT +from openerp.exceptions import Warning, ValidationError from datetime import datetime from dateutil.relativedelta import relativedelta import logging @@ -30,71 +30,64 @@ import logging logger = logging.getLogger(__name__) -class report_intrastat_common(orm.TransientModel): +class ReportIntrastatCommon(models.AbstractModel): _name = "report.intrastat.common" _description = "Common functions for intrastat reports for products " "and services" - def _compute_numbers(self, cr, uid, ids, object, context=None): - result = {} - for intrastat in object.browse(cr, uid, ids, context=context): - total_amount = 0.0 - num_lines = 0 - for line in intrastat.intrastat_line_ids: - total_amount += line.amount_company_currency - num_lines += 1 - result[intrastat.id] = { - 'num_lines': num_lines, - 'total_amount': total_amount, - } - return result + @api.one + @api.depends( + 'intrastat_line_ids', 'intrastat_line_ids.amount_company_currency') + def _compute_numbers(self): + total_amount = 0.0 + num_lines = 0 + for line in self.intrastat_line_ids: + total_amount += line.amount_company_currency + num_lines += 1 + self.num_lines = num_lines + self.total_amount = total_amount - def _compute_dates(self, cr, uid, ids, object, context=None): - result = {} - for intrastat in object.browse(cr, uid, ids, context=context): - start_date_datetime = datetime.strptime( - intrastat.start_date, '%Y-%m-%d') - end_date_str = datetime.strftime( - start_date_datetime + relativedelta(day=31), '%Y-%m-%d') - result[intrastat.id] = { - 'end_date': end_date_str, - 'year_month': start_date_datetime.strftime('%Y-%m'), - } - return result + @api.one + @api.depends('start_date') + def _compute_dates(self): + start_date_dt = datetime.strptime( + self.start_date, DEFAULT_SERVER_DATE_FORMAT) + self.end_date = datetime.strftime( + start_date_dt + relativedelta(day=31), DEFAULT_SERVER_DATE_FORMAT) + self.year_month = start_date_dt.strftime('%Y-%m') - def _check_start_date(self, cr, uid, ids, object, context=None): + @api.one + @api.constrains('start_date') + def _check_start_date(self): '''Check that the start date is the first day of the month''' - for date_to_check in object.read( - cr, uid, ids, ['start_date'], context=context): - datetime_to_check = datetime.strptime( - date_to_check['start_date'], '%Y-%m-%d') - if datetime_to_check.day != 1: - return False - return True + datetime_to_check = datetime.strptime( + self.start_date, DEFAULT_SERVER_DATE_FORMAT) + if datetime_to_check.day != 1: + return ValidationError( + _('The start date must be the first day of the month')) - def _check_generate_lines(self, cr, uid, intrastat, context=None): - if not intrastat.company_id.country_id: - raise orm.except_orm( - _('Error :'), + @api.one + def _check_generate_lines(self): + if not self.company_id.country_id: + raise Warning( _("The country is not set on the company '%s'.") - % intrastat.company_id.name) - if not intrastat.currency_id.name == 'EUR': - raise orm.except_orm( - _('Error :'), + % self.company_id.name) + if self.currency_id.name != 'EUR': + raise Warning( _("The company currency must be 'EUR', but is currently '%s'.") - % intrastat.currency_id.name) + % self.currency_id.name) return True - def _check_generate_xml(self, cr, uid, intrastat, context=None): - if not intrastat.company_id.partner_id.vat: - raise orm.except_orm( - _('Error :'), + @api.one + def _check_generate_xml(self): + if not self.company_id.partner_id.vat: + raise Warning( _("The VAT number is not set for the partner '%s'.") - % intrastat.company_id.partner_id.name) + % self.company_id.partner_id.name) return True - def _check_xml_schema( - self, cr, uid, xml_root, xml_string, xsd_file, context=None): + @api.model + def _check_xml_schema(self, xml_root, xml_string, xsd_file): '''Validate the XML file against the XSD''' from lxml import etree xsd_etree_obj = etree.parse( @@ -104,13 +97,12 @@ class report_intrastat_common(orm.TransientModel): official_schema.assertValid(xml_root) except Exception, e: # if the validation of the XSD fails, we arrive here - _logger = logging.getLogger(__name__) - _logger.warning( + logger = logging.getLogger(__name__) + logger.warning( "The XML file is invalid against the XML Schema Definition") - _logger.warning(xml_string) - _logger.warning(e) - raise orm.except_orm( - _('Error :'), + logger.warning(xml_string) + logger.warning(e) + raise Warning( _("The generated XML file is not valid against the official " "XML Schema Definition. The generated XML file and the " "full error have been written in the server logs. " @@ -119,39 +111,29 @@ class report_intrastat_common(orm.TransientModel): % str(e)) return True - def _attach_xml_file( - self, cr, uid, ids, object, xml_string, start_date_datetime, - declaration_name, context=None): + @api.multi + def _attach_xml_file(self, xml_string, declaration_name): '''Attach the XML file to the report_intrastat_product/service ''' '''object''' + self.ensure_one() import base64 - assert len(ids) == 1, "Only one ID accepted" - filename = '%s_%s.xml' % ( - datetime.strftime(start_date_datetime, '%Y-%m'), - declaration_name) - if not context: - context = {} - context.update({ - 'default_res_id': ids[0], - 'default_res_model': object._name - }) - attach_id = self.pool['ir.attachment'].create( - cr, uid, { - 'name': filename, - 'datas': base64.encodestring(xml_string), - 'datas_fname': filename}, - context=context) - return attach_id + filename = '%s_%s.xml' % (self.year_month, declaration_name) + attach = self.with_context( + default_res_id=self.id, + default_res_model=self._name).env['ir.attachment'].create({ + 'name': filename, + 'datas': base64.encodestring(xml_string), + 'datas_fname': filename}) + return attach.id - def _open_attach_view( - self, cr, uid, attach_id, title='XML file', context=None): + @api.model + def _open_attach_view(self, attach_id, title='XML file'): '''Returns an action which opens the form view of the ''' '''corresponding attachement''' action = { 'name': title, 'view_type': 'form', - 'view_mode': 'form,tree', - 'view_id': False, + 'view_mode': 'form', 'res_model': 'ir.attachment', 'type': 'ir.actions.act_window', 'nodestroy': True, @@ -160,30 +142,27 @@ class report_intrastat_common(orm.TransientModel): } return action - def partner_on_change(self, cr, uid, ids, partner_id=False, context=None): - result = {} - result['value'] = {} - if partner_id: - company = self.pool['res.partner'].read( - cr, uid, partner_id, ['vat'], context=context) - result['value']['partner_vat'] = company['vat'] - return result - - def send_reminder_email( - self, cr, uid, company, module_name, template_xmlid, - intrastat_id, context=None): - template_model, template_id =\ - self.pool['ir.model.data'].get_object_reference( - cr, uid, module_name, template_xmlid) - assert template_model == 'email.template', 'Wrong model' - if company.intrastat_remind_user_ids: + @api.one + def send_reminder_email(self, mail_template_xmlid): + mail_template = self.env.ref(mail_template_xmlid) + if self.company_id.intrastat_remind_user_ids: self.pool['email.template'].send_mail( - cr, uid, template_id, intrastat_id, context=context) + self._cr, self._uid, mail_template.id, self.id, + context=self._context) logger.info( 'Intrastat Reminder email has been sent (XMLID: %s).' - % template_xmlid) + % mail_template_xmlid) else: logger.warning( 'The list of users receiving the Intrastat Reminder is empty ' - 'on company %s' % company.name) + 'on company %s' % self.company_id.name) return True + + @api.multi + def unlink(self): + for intrastat in self: + if intrastat.state == 'done': + raise Warning( + _('Cannot delete the declaration %s ' + 'because it is in Done state') % self.year_month) + return super(ReportIntrastatCommon, self).unlink() diff --git a/intrastat_base/intrastat_demo.xml b/intrastat_base/intrastat_demo.xml index 07c68ab..953d92b 100644 --- a/intrastat_base/intrastat_demo.xml +++ b/intrastat_base/intrastat_demo.xml @@ -1,7 +1,7 @@ diff --git a/intrastat_base/intrastat_menu.xml b/intrastat_base/intrastat_menu.xml index 83434cb..85303c1 100644 --- a/intrastat_base/intrastat_menu.xml +++ b/intrastat_base/intrastat_menu.xml @@ -1,7 +1,7 @@ @@ -9,7 +9,7 @@ - + diff --git a/intrastat_base/product.py b/intrastat_base/product.py index 7181706..ca1652e 100644 --- a/intrastat_base/product.py +++ b/intrastat_base/product.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for OpenERP -# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/) +# Copyright (C) 2010-2014 Akretion (http://www.akretion.com/) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,43 +20,32 @@ # ############################################################################## -from openerp.osv import orm, fields -from openerp.tools.translate import _ +from openerp import models, fields, api, _ +from openerp.exceptions import ValidationError -class product_template(orm.Model): +class ProductTemplate(models.Model): _inherit = "product.template" - _columns = { - 'exclude_from_intrastat': fields.boolean( - 'Exclude from Intrastat reports', - help="If set to True, the product or service will not be " - "taken into account for Intrastat Product or Service reports. " - "So you should leave this field to False unless you have a " - "very good reason."), - 'is_accessory_cost': fields.boolean( - 'Is accessory cost', - help="Activate this option for shipping costs, packaging " - "costs and all services related to the sale of products. " - "This option is used for Intrastat reports."), - } - _defaults = { - 'exclude_from_intrastat': False, - } + exclude_from_intrastat = fields.Boolean( + string='Exclude from Intrastat reports', + help="If set to True, the product or service will not be " + "taken into account for Intrastat Product or Service reports. " + "So you should leave this field to False unless you have a " + "very good reason.") + is_accessory_cost = fields.Boolean( + string='Is accessory cost', + help="Activate this option for shipping costs, packaging " + "costs and all services related to the sale of products. " + "This option is used for Intrastat reports.") - def _check_accessory_cost(self, cr, uid, ids): - for product in self.browse(cr, uid, ids): - if product.is_accessory_cost and product.type != 'service': - raise orm.except_orm( - _('Error :'), - _("The option 'Is accessory cost?' should only be " - "activated on 'Service' products. You have activated " - "this option for the product '%s' which is of type " - "'%s'" - % (product.name, product.type))) - return True - - _constraints = [ - (_check_accessory_cost, "Error msg is in raise", - ['is_accessory_cost', 'type']) - ] + @api.one + @api.constrains('type', 'is_accessory_cost') + def _check_accessory_cost(self): + if self.is_accessory_cost and self.type != 'service': + raise ValidationError( + _("The option 'Is accessory cost?' should only be " + "activated on 'Service' products. You have activated " + "this option for the product '%s' which is of type " + "'%s'" + % (self.name, self.type))) diff --git a/intrastat_base/product_view.xml b/intrastat_base/product_view.xml index a551868..dc61ca5 100644 --- a/intrastat_base/product_view.xml +++ b/intrastat_base/product_view.xml @@ -1,7 +1,7 @@ @@ -9,11 +9,10 @@ - - - intrastat.base.product.normal.form - product.product - + + intrastat.base.product.template.form + product.template + @@ -25,21 +24,5 @@ - - - intrastat.base.product.template.form - product.template - - - - - - - - - - - diff --git a/intrastat_base/tax.py b/intrastat_base/tax.py index fae6a3d..2b98678 100644 --- a/intrastat_base/tax.py +++ b/intrastat_base/tax.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for OpenERP -# Copyright (C) 2011-2013 Akretion (http://www.akretion.com). +# Report intrastat base module for Odoo +# Copyright (C) 2011-2014 Akretion (http://www.akretion.com). # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,16 +20,14 @@ # ############################################################################## -from openerp.osv import orm, fields +from openerp import models, fields -class account_tax(orm.Model): +class AccountTax(models.Model): _inherit = "account.tax" - _columns = { - 'exclude_from_intrastat_if_present': fields.boolean( - 'Exclude invoice line from intrastat if this tax is present', - help="If this tax is present on an invoice line, this invoice " - "line will be skipped when generating Intrastat Product or " - "Service lines from invoices."), - } + exclude_from_intrastat_if_present = fields.Boolean( + string='Exclude invoice line from intrastat if this tax is present', + help="If this tax is present on an invoice line, this invoice " + "line will be skipped when generating Intrastat Product or " + "Service lines from invoices.") diff --git a/intrastat_base/tax_view.xml b/intrastat_base/tax_view.xml index c481490..5defe29 100644 --- a/intrastat_base/tax_view.xml +++ b/intrastat_base/tax_view.xml @@ -1,7 +1,7 @@ @@ -10,17 +10,14 @@ - + intrastat.base.tax account.tax - form - - From 9ea20f0d5ef8f863476ac9f68668e2cda4a86510 Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Wed, 4 Feb 2015 20:11:31 +0100 Subject: [PATCH 06/39] Make dutch ICP report workable on odoo 8.0 [FIX] Some small changes in base, to make check_generate_lines better reusable (no need to force currency field on report), and do away with '_' before method name, as method should not be private, as it is called from other classes. --- intrastat_base/intrastat_common.py | 199 +++++++++++++++++------------ 1 file changed, 115 insertions(+), 84 deletions(-) diff --git a/intrastat_base/intrastat_common.py b/intrastat_base/intrastat_common.py index fa65afe..47c10ac 100644 --- a/intrastat_base/intrastat_common.py +++ b/intrastat_base/intrastat_common.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for Odoo -# Copyright (C) 2010-2014 Akretion (http://www.akretion.com/). +# Report intrastat base module for OpenERP +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/). # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,9 +20,9 @@ # ############################################################################## -from openerp import models, api, tools, _ -from openerp.tools import DEFAULT_SERVER_DATE_FORMAT -from openerp.exceptions import Warning, ValidationError +from openerp.osv import orm +from openerp.tools.translate import _ +from openerp import tools from datetime import datetime from dateutil.relativedelta import relativedelta import logging @@ -30,64 +30,81 @@ import logging logger = logging.getLogger(__name__) -class ReportIntrastatCommon(models.AbstractModel): +class report_intrastat_common(orm.TransientModel): _name = "report.intrastat.common" _description = "Common functions for intrastat reports for products " "and services" - @api.one - @api.depends( - 'intrastat_line_ids', 'intrastat_line_ids.amount_company_currency') - def _compute_numbers(self): - total_amount = 0.0 - num_lines = 0 - for line in self.intrastat_line_ids: - total_amount += line.amount_company_currency - num_lines += 1 - self.num_lines = num_lines - self.total_amount = total_amount + def _compute_numbers(self, cr, uid, ids, object, context=None): + result = {} + for intrastat in object.browse(cr, uid, ids, context=context): + total_amount = 0.0 + num_lines = 0 + for line in intrastat.intrastat_line_ids: + total_amount += line.amount_company_currency + num_lines += 1 + result[intrastat.id] = { + 'num_lines': num_lines, + 'total_amount': total_amount, + } + return result - @api.one - @api.depends('start_date') - def _compute_dates(self): - start_date_dt = datetime.strptime( - self.start_date, DEFAULT_SERVER_DATE_FORMAT) - self.end_date = datetime.strftime( - start_date_dt + relativedelta(day=31), DEFAULT_SERVER_DATE_FORMAT) - self.year_month = start_date_dt.strftime('%Y-%m') + def _compute_dates(self, cr, uid, ids, object, context=None): + result = {} + for intrastat in object.browse(cr, uid, ids, context=context): + start_date_datetime = datetime.strptime( + intrastat.start_date, '%Y-%m-%d') + end_date_str = datetime.strftime( + start_date_datetime + relativedelta(day=31), '%Y-%m-%d') + result[intrastat.id] = { + 'end_date': end_date_str, + 'year_month': start_date_datetime.strftime('%Y-%m'), + } + return result - @api.one - @api.constrains('start_date') - def _check_start_date(self): + def _check_start_date(self, cr, uid, ids, object, context=None): '''Check that the start date is the first day of the month''' - datetime_to_check = datetime.strptime( - self.start_date, DEFAULT_SERVER_DATE_FORMAT) - if datetime_to_check.day != 1: - return ValidationError( - _('The start date must be the first day of the month')) + for date_to_check in object.read( + cr, uid, ids, ['start_date'], context=context): + datetime_to_check = datetime.strptime( + date_to_check['start_date'], '%Y-%m-%d') + if datetime_to_check.day != 1: + return False + return True - @api.one - def _check_generate_lines(self): - if not self.company_id.country_id: - raise Warning( + def check_generate_lines(self, cr, uid, intrastat, context=None): + """Check wether all requirements are met for generating lines.""" + if not intrastat.company_id: + # Should not be possible, but just in case: + raise orm.except_orm( + _('Error :'), + _("Company not yet set on intrastat report.") + ) + company_obj = intrastat.company_id # Simplify references + if not company_obj.country_id: + raise orm.except_orm( + _('Error :'), _("The country is not set on the company '%s'.") - % self.company_id.name) - if self.currency_id.name != 'EUR': - raise Warning( + % company_obj.name + ) + if not company_obj.currency_id.name == 'EUR': + raise orm.except_orm( + _('Error :'), _("The company currency must be 'EUR', but is currently '%s'.") - % self.currency_id.name) + % company_obj.currency_id.name + ) return True - @api.one - def _check_generate_xml(self): - if not self.company_id.partner_id.vat: - raise Warning( + def _check_generate_xml(self, cr, uid, intrastat, context=None): + if not intrastat.company_id.partner_id.vat: + raise orm.except_orm( + _('Error :'), _("The VAT number is not set for the partner '%s'.") - % self.company_id.partner_id.name) + % intrastat.company_id.partner_id.name) return True - @api.model - def _check_xml_schema(self, xml_root, xml_string, xsd_file): + def _check_xml_schema( + self, cr, uid, xml_root, xml_string, xsd_file, context=None): '''Validate the XML file against the XSD''' from lxml import etree xsd_etree_obj = etree.parse( @@ -97,12 +114,13 @@ class ReportIntrastatCommon(models.AbstractModel): official_schema.assertValid(xml_root) except Exception, e: # if the validation of the XSD fails, we arrive here - logger = logging.getLogger(__name__) - logger.warning( + _logger = logging.getLogger(__name__) + _logger.warning( "The XML file is invalid against the XML Schema Definition") - logger.warning(xml_string) - logger.warning(e) - raise Warning( + _logger.warning(xml_string) + _logger.warning(e) + raise orm.except_orm( + _('Error :'), _("The generated XML file is not valid against the official " "XML Schema Definition. The generated XML file and the " "full error have been written in the server logs. " @@ -111,29 +129,39 @@ class ReportIntrastatCommon(models.AbstractModel): % str(e)) return True - @api.multi - def _attach_xml_file(self, xml_string, declaration_name): + def _attach_xml_file( + self, cr, uid, ids, object, xml_string, start_date_datetime, + declaration_name, context=None): '''Attach the XML file to the report_intrastat_product/service ''' '''object''' - self.ensure_one() import base64 - filename = '%s_%s.xml' % (self.year_month, declaration_name) - attach = self.with_context( - default_res_id=self.id, - default_res_model=self._name).env['ir.attachment'].create({ - 'name': filename, - 'datas': base64.encodestring(xml_string), - 'datas_fname': filename}) - return attach.id + assert len(ids) == 1, "Only one ID accepted" + filename = '%s_%s.xml' % ( + datetime.strftime(start_date_datetime, '%Y-%m'), + declaration_name) + if not context: + context = {} + context.update({ + 'default_res_id': ids[0], + 'default_res_model': object._name + }) + attach_id = self.pool['ir.attachment'].create( + cr, uid, { + 'name': filename, + 'datas': base64.encodestring(xml_string), + 'datas_fname': filename}, + context=context) + return attach_id - @api.model - def _open_attach_view(self, attach_id, title='XML file'): + def _open_attach_view( + self, cr, uid, attach_id, title='XML file', context=None): '''Returns an action which opens the form view of the ''' '''corresponding attachement''' action = { 'name': title, 'view_type': 'form', - 'view_mode': 'form', + 'view_mode': 'form,tree', + 'view_id': False, 'res_model': 'ir.attachment', 'type': 'ir.actions.act_window', 'nodestroy': True, @@ -142,27 +170,30 @@ class ReportIntrastatCommon(models.AbstractModel): } return action - @api.one - def send_reminder_email(self, mail_template_xmlid): - mail_template = self.env.ref(mail_template_xmlid) - if self.company_id.intrastat_remind_user_ids: + def partner_on_change(self, cr, uid, ids, partner_id=False, context=None): + result = {} + result['value'] = {} + if partner_id: + company = self.pool['res.partner'].read( + cr, uid, partner_id, ['vat'], context=context) + result['value']['partner_vat'] = company['vat'] + return result + + def send_reminder_email( + self, cr, uid, company, module_name, template_xmlid, + intrastat_id, context=None): + template_model, template_id =\ + self.pool['ir.model.data'].get_object_reference( + cr, uid, module_name, template_xmlid) + assert template_model == 'email.template', 'Wrong model' + if company.intrastat_remind_user_ids: self.pool['email.template'].send_mail( - self._cr, self._uid, mail_template.id, self.id, - context=self._context) + cr, uid, template_id, intrastat_id, context=context) logger.info( 'Intrastat Reminder email has been sent (XMLID: %s).' - % mail_template_xmlid) + % template_xmlid) else: logger.warning( 'The list of users receiving the Intrastat Reminder is empty ' - 'on company %s' % self.company_id.name) + 'on company %s' % company.name) return True - - @api.multi - def unlink(self): - for intrastat in self: - if intrastat.state == 'done': - raise Warning( - _('Cannot delete the declaration %s ' - 'because it is in Done state') % self.year_month) - return super(ReportIntrastatCommon, self).unlink() From f869b0c267afadb43712361b5e0d591769856119 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 7 Feb 2015 11:36:42 +0100 Subject: [PATCH 07/39] Continue the port to the new API Access for intrastat report to accounting user and not only accounting manager. --- intrastat_base/__openerp__.py | 3 +- intrastat_base/intrastat_common.py | 195 ++++++++++++----------------- 2 files changed, 81 insertions(+), 117 deletions(-) diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py index 179cb4a..e795155 100644 --- a/intrastat_base/__openerp__.py +++ b/intrastat_base/__openerp__.py @@ -2,7 +2,7 @@ ############################################################################## # # Report intrastat base module for Odoo -# Copyright (C) 2011-2014 Akretion (http://www.akretion.com) +# Copyright (C) 2011-2015 Akretion (http://www.akretion.com) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,7 +20,6 @@ # ############################################################################## - { 'name': 'Intrastat Reporting Base', 'version': '1.1', diff --git a/intrastat_base/intrastat_common.py b/intrastat_base/intrastat_common.py index 47c10ac..b6d8b2f 100644 --- a/intrastat_base/intrastat_common.py +++ b/intrastat_base/intrastat_common.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for OpenERP -# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/). +# Report intrastat base module for Odoo +# Copyright (C) 2010-2014 Akretion (http://www.akretion.com/). # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,9 +20,8 @@ # ############################################################################## -from openerp.osv import orm -from openerp.tools.translate import _ -from openerp import tools +from openerp import models, fields, api, tools, _ +from openerp.exceptions import Warning, ValidationError from datetime import datetime from dateutil.relativedelta import relativedelta import logging @@ -30,81 +29,61 @@ import logging logger = logging.getLogger(__name__) -class report_intrastat_common(orm.TransientModel): +class ReportIntrastatCommon(models.AbstractModel): _name = "report.intrastat.common" _description = "Common functions for intrastat reports for products " "and services" - def _compute_numbers(self, cr, uid, ids, object, context=None): - result = {} - for intrastat in object.browse(cr, uid, ids, context=context): - total_amount = 0.0 - num_lines = 0 - for line in intrastat.intrastat_line_ids: - total_amount += line.amount_company_currency - num_lines += 1 - result[intrastat.id] = { - 'num_lines': num_lines, - 'total_amount': total_amount, - } - return result + @api.one + @api.depends( + 'intrastat_line_ids', 'intrastat_line_ids.amount_company_currency') + def _compute_numbers(self): + total_amount = 0.0 + num_lines = 0 + for line in self.intrastat_line_ids: + total_amount += line.amount_company_currency + num_lines += 1 + self.num_lines = num_lines + self.total_amount = total_amount - def _compute_dates(self, cr, uid, ids, object, context=None): - result = {} - for intrastat in object.browse(cr, uid, ids, context=context): - start_date_datetime = datetime.strptime( - intrastat.start_date, '%Y-%m-%d') - end_date_str = datetime.strftime( - start_date_datetime + relativedelta(day=31), '%Y-%m-%d') - result[intrastat.id] = { - 'end_date': end_date_str, - 'year_month': start_date_datetime.strftime('%Y-%m'), - } - return result + @api.one + @api.depends('start_date') + def _compute_dates(self): + start_date_dt = fields.Date.from_string(self.start_date) + self.end_date = fields.Date.to_string( + start_date_dt + relativedelta(day=31)) + self.year_month = start_date_dt.strftime('%Y-%m') - def _check_start_date(self, cr, uid, ids, object, context=None): + @api.one + def _check_start_date(self): '''Check that the start date is the first day of the month''' - for date_to_check in object.read( - cr, uid, ids, ['start_date'], context=context): - datetime_to_check = datetime.strptime( - date_to_check['start_date'], '%Y-%m-%d') - if datetime_to_check.day != 1: - return False - return True + datetime_to_check = fields.Date.from_string(self.start_date) + if datetime_to_check.day != 1: + raise ValidationError( + _('The start date must be the first day of the month')) - def check_generate_lines(self, cr, uid, intrastat, context=None): - """Check wether all requirements are met for generating lines.""" - if not intrastat.company_id: - # Should not be possible, but just in case: - raise orm.except_orm( - _('Error :'), - _("Company not yet set on intrastat report.") - ) - company_obj = intrastat.company_id # Simplify references - if not company_obj.country_id: - raise orm.except_orm( - _('Error :'), + @api.one + def _check_generate_lines(self): + if not self.company_id.country_id: + raise Warning( _("The country is not set on the company '%s'.") - % company_obj.name - ) - if not company_obj.currency_id.name == 'EUR': - raise orm.except_orm( - _('Error :'), + % self.company_id.name) + if self.currency_id.name != 'EUR': + raise Warning( _("The company currency must be 'EUR', but is currently '%s'.") - % company_obj.currency_id.name - ) + % self.currency_id.name) return True - def _check_generate_xml(self, cr, uid, intrastat, context=None): - if not intrastat.company_id.partner_id.vat: - raise orm.except_orm( - _('Error :'), + @api.one + def _check_generate_xml(self): + if not self.company_id.partner_id.vat: + raise Warning( _("The VAT number is not set for the partner '%s'.") - % intrastat.company_id.partner_id.name) + % self.company_id.partner_id.name) return True - def _check_xml_schema( - self, cr, uid, xml_root, xml_string, xsd_file, context=None): + @api.model + def _check_xml_schema(self, xml_root, xml_string, xsd_file): '''Validate the XML file against the XSD''' from lxml import etree xsd_etree_obj = etree.parse( @@ -114,13 +93,12 @@ class report_intrastat_common(orm.TransientModel): official_schema.assertValid(xml_root) except Exception, e: # if the validation of the XSD fails, we arrive here - _logger = logging.getLogger(__name__) - _logger.warning( + logger = logging.getLogger(__name__) + logger.warning( "The XML file is invalid against the XML Schema Definition") - _logger.warning(xml_string) - _logger.warning(e) - raise orm.except_orm( - _('Error :'), + logger.warning(xml_string) + logger.warning(e) + raise Warning( _("The generated XML file is not valid against the official " "XML Schema Definition. The generated XML file and the " "full error have been written in the server logs. " @@ -129,39 +107,29 @@ class report_intrastat_common(orm.TransientModel): % str(e)) return True - def _attach_xml_file( - self, cr, uid, ids, object, xml_string, start_date_datetime, - declaration_name, context=None): + @api.multi + def _attach_xml_file(self, xml_string, declaration_name): '''Attach the XML file to the report_intrastat_product/service ''' '''object''' + self.ensure_one() import base64 - assert len(ids) == 1, "Only one ID accepted" - filename = '%s_%s.xml' % ( - datetime.strftime(start_date_datetime, '%Y-%m'), - declaration_name) - if not context: - context = {} - context.update({ - 'default_res_id': ids[0], - 'default_res_model': object._name - }) - attach_id = self.pool['ir.attachment'].create( - cr, uid, { - 'name': filename, - 'datas': base64.encodestring(xml_string), - 'datas_fname': filename}, - context=context) - return attach_id + filename = '%s_%s.xml' % (self.year_month, declaration_name) + attach = self.with_context( + default_res_id=self.id, + default_res_model=self._name).env['ir.attachment'].create({ + 'name': filename, + 'datas': base64.encodestring(xml_string), + 'datas_fname': filename}) + return attach.id - def _open_attach_view( - self, cr, uid, attach_id, title='XML file', context=None): + @api.model + def _open_attach_view(self, attach_id, title='XML file'): '''Returns an action which opens the form view of the ''' '''corresponding attachement''' action = { 'name': title, 'view_type': 'form', - 'view_mode': 'form,tree', - 'view_id': False, + 'view_mode': 'form', 'res_model': 'ir.attachment', 'type': 'ir.actions.act_window', 'nodestroy': True, @@ -170,30 +138,27 @@ class report_intrastat_common(orm.TransientModel): } return action - def partner_on_change(self, cr, uid, ids, partner_id=False, context=None): - result = {} - result['value'] = {} - if partner_id: - company = self.pool['res.partner'].read( - cr, uid, partner_id, ['vat'], context=context) - result['value']['partner_vat'] = company['vat'] - return result - - def send_reminder_email( - self, cr, uid, company, module_name, template_xmlid, - intrastat_id, context=None): - template_model, template_id =\ - self.pool['ir.model.data'].get_object_reference( - cr, uid, module_name, template_xmlid) - assert template_model == 'email.template', 'Wrong model' - if company.intrastat_remind_user_ids: + @api.one + def send_reminder_email(self, mail_template_xmlid): + mail_template = self.env.ref(mail_template_xmlid) + if self.company_id.intrastat_remind_user_ids: self.pool['email.template'].send_mail( - cr, uid, template_id, intrastat_id, context=context) + self._cr, self._uid, mail_template.id, self.id, + context=self._context) logger.info( 'Intrastat Reminder email has been sent (XMLID: %s).' - % template_xmlid) + % mail_template_xmlid) else: logger.warning( 'The list of users receiving the Intrastat Reminder is empty ' - 'on company %s' % company.name) + 'on company %s' % self.company_id.name) return True + + @api.multi + def unlink(self): + for intrastat in self: + if intrastat.state == 'done': + raise Warning( + _('Cannot delete the declaration %s ' + 'because it is in Done state') % self.year_month) + return super(ReportIntrastatCommon, self).unlink() From 27abedf5b9f3d45f1ce5cee7c31ff5ebd8923287 Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Fri, 13 Feb 2015 11:24:14 +0100 Subject: [PATCH 08/39] Revert rename of _check_generate_lines to version withouth underscore. In pending merge request from Alexis, _check_generate_lines will no longer be called from outside the class, so no longer any need to change private function name convention to public name convention. This will also make it easier to merge all changes. --- intrastat_base/intrastat_common.py | 195 +++++++++++++++++------------ 1 file changed, 115 insertions(+), 80 deletions(-) diff --git a/intrastat_base/intrastat_common.py b/intrastat_base/intrastat_common.py index b6d8b2f..3db1764 100644 --- a/intrastat_base/intrastat_common.py +++ b/intrastat_base/intrastat_common.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for Odoo -# Copyright (C) 2010-2014 Akretion (http://www.akretion.com/). +# Report intrastat base module for OpenERP +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/). # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,8 +20,9 @@ # ############################################################################## -from openerp import models, fields, api, tools, _ -from openerp.exceptions import Warning, ValidationError +from openerp.osv import orm +from openerp.tools.translate import _ +from openerp import tools from datetime import datetime from dateutil.relativedelta import relativedelta import logging @@ -29,61 +30,81 @@ import logging logger = logging.getLogger(__name__) -class ReportIntrastatCommon(models.AbstractModel): +class report_intrastat_common(orm.TransientModel): _name = "report.intrastat.common" _description = "Common functions for intrastat reports for products " "and services" - @api.one - @api.depends( - 'intrastat_line_ids', 'intrastat_line_ids.amount_company_currency') - def _compute_numbers(self): - total_amount = 0.0 - num_lines = 0 - for line in self.intrastat_line_ids: - total_amount += line.amount_company_currency - num_lines += 1 - self.num_lines = num_lines - self.total_amount = total_amount + def _compute_numbers(self, cr, uid, ids, object, context=None): + result = {} + for intrastat in object.browse(cr, uid, ids, context=context): + total_amount = 0.0 + num_lines = 0 + for line in intrastat.intrastat_line_ids: + total_amount += line.amount_company_currency + num_lines += 1 + result[intrastat.id] = { + 'num_lines': num_lines, + 'total_amount': total_amount, + } + return result - @api.one - @api.depends('start_date') - def _compute_dates(self): - start_date_dt = fields.Date.from_string(self.start_date) - self.end_date = fields.Date.to_string( - start_date_dt + relativedelta(day=31)) - self.year_month = start_date_dt.strftime('%Y-%m') + def _compute_dates(self, cr, uid, ids, object, context=None): + result = {} + for intrastat in object.browse(cr, uid, ids, context=context): + start_date_datetime = datetime.strptime( + intrastat.start_date, '%Y-%m-%d') + end_date_str = datetime.strftime( + start_date_datetime + relativedelta(day=31), '%Y-%m-%d') + result[intrastat.id] = { + 'end_date': end_date_str, + 'year_month': start_date_datetime.strftime('%Y-%m'), + } + return result - @api.one - def _check_start_date(self): + def _check_start_date(self, cr, uid, ids, object, context=None): '''Check that the start date is the first day of the month''' - datetime_to_check = fields.Date.from_string(self.start_date) - if datetime_to_check.day != 1: - raise ValidationError( - _('The start date must be the first day of the month')) + for date_to_check in object.read( + cr, uid, ids, ['start_date'], context=context): + datetime_to_check = datetime.strptime( + date_to_check['start_date'], '%Y-%m-%d') + if datetime_to_check.day != 1: + return False + return True - @api.one - def _check_generate_lines(self): - if not self.company_id.country_id: - raise Warning( + def _check_generate_lines(self, cr, uid, intrastat, context=None): + """Check wether all requirements are met for generating lines.""" + if not intrastat.company_id: + # Should not be possible, but just in case: + raise orm.except_orm( + _('Error :'), + _("Company not yet set on intrastat report.") + ) + company_obj = intrastat.company_id # Simplify references + if not company_obj.country_id: + raise orm.except_orm( + _('Error :'), _("The country is not set on the company '%s'.") - % self.company_id.name) - if self.currency_id.name != 'EUR': - raise Warning( + % company_obj.name + ) + if not company_obj.currency_id.name == 'EUR': + raise orm.except_orm( + _('Error :'), _("The company currency must be 'EUR', but is currently '%s'.") - % self.currency_id.name) + % company_obj.currency_id.name + ) return True - @api.one - def _check_generate_xml(self): - if not self.company_id.partner_id.vat: - raise Warning( + def _check_generate_xml(self, cr, uid, intrastat, context=None): + if not intrastat.company_id.partner_id.vat: + raise orm.except_orm( + _('Error :'), _("The VAT number is not set for the partner '%s'.") - % self.company_id.partner_id.name) + % intrastat.company_id.partner_id.name) return True - @api.model - def _check_xml_schema(self, xml_root, xml_string, xsd_file): + def _check_xml_schema( + self, cr, uid, xml_root, xml_string, xsd_file, context=None): '''Validate the XML file against the XSD''' from lxml import etree xsd_etree_obj = etree.parse( @@ -93,12 +114,13 @@ class ReportIntrastatCommon(models.AbstractModel): official_schema.assertValid(xml_root) except Exception, e: # if the validation of the XSD fails, we arrive here - logger = logging.getLogger(__name__) - logger.warning( + _logger = logging.getLogger(__name__) + _logger.warning( "The XML file is invalid against the XML Schema Definition") - logger.warning(xml_string) - logger.warning(e) - raise Warning( + _logger.warning(xml_string) + _logger.warning(e) + raise orm.except_orm( + _('Error :'), _("The generated XML file is not valid against the official " "XML Schema Definition. The generated XML file and the " "full error have been written in the server logs. " @@ -107,29 +129,39 @@ class ReportIntrastatCommon(models.AbstractModel): % str(e)) return True - @api.multi - def _attach_xml_file(self, xml_string, declaration_name): + def _attach_xml_file( + self, cr, uid, ids, object, xml_string, start_date_datetime, + declaration_name, context=None): '''Attach the XML file to the report_intrastat_product/service ''' '''object''' - self.ensure_one() import base64 - filename = '%s_%s.xml' % (self.year_month, declaration_name) - attach = self.with_context( - default_res_id=self.id, - default_res_model=self._name).env['ir.attachment'].create({ - 'name': filename, - 'datas': base64.encodestring(xml_string), - 'datas_fname': filename}) - return attach.id + assert len(ids) == 1, "Only one ID accepted" + filename = '%s_%s.xml' % ( + datetime.strftime(start_date_datetime, '%Y-%m'), + declaration_name) + if not context: + context = {} + context.update({ + 'default_res_id': ids[0], + 'default_res_model': object._name + }) + attach_id = self.pool['ir.attachment'].create( + cr, uid, { + 'name': filename, + 'datas': base64.encodestring(xml_string), + 'datas_fname': filename}, + context=context) + return attach_id - @api.model - def _open_attach_view(self, attach_id, title='XML file'): + def _open_attach_view( + self, cr, uid, attach_id, title='XML file', context=None): '''Returns an action which opens the form view of the ''' '''corresponding attachement''' action = { 'name': title, 'view_type': 'form', - 'view_mode': 'form', + 'view_mode': 'form,tree', + 'view_id': False, 'res_model': 'ir.attachment', 'type': 'ir.actions.act_window', 'nodestroy': True, @@ -138,27 +170,30 @@ class ReportIntrastatCommon(models.AbstractModel): } return action - @api.one - def send_reminder_email(self, mail_template_xmlid): - mail_template = self.env.ref(mail_template_xmlid) - if self.company_id.intrastat_remind_user_ids: + def partner_on_change(self, cr, uid, ids, partner_id=False, context=None): + result = {} + result['value'] = {} + if partner_id: + company = self.pool['res.partner'].read( + cr, uid, partner_id, ['vat'], context=context) + result['value']['partner_vat'] = company['vat'] + return result + + def send_reminder_email( + self, cr, uid, company, module_name, template_xmlid, + intrastat_id, context=None): + template_model, template_id =\ + self.pool['ir.model.data'].get_object_reference( + cr, uid, module_name, template_xmlid) + assert template_model == 'email.template', 'Wrong model' + if company.intrastat_remind_user_ids: self.pool['email.template'].send_mail( - self._cr, self._uid, mail_template.id, self.id, - context=self._context) + cr, uid, template_id, intrastat_id, context=context) logger.info( 'Intrastat Reminder email has been sent (XMLID: %s).' - % mail_template_xmlid) + % template_xmlid) else: logger.warning( 'The list of users receiving the Intrastat Reminder is empty ' - 'on company %s' % self.company_id.name) + 'on company %s' % company.name) return True - - @api.multi - def unlink(self): - for intrastat in self: - if intrastat.state == 'done': - raise Warning( - _('Cannot delete the declaration %s ' - 'because it is in Done state') % self.year_month) - return super(ReportIntrastatCommon, self).unlink() From 6f94b5197ace2b2445c72d5572a8c7b79ac908f5 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 14 Apr 2015 22:33:32 +0200 Subject: [PATCH 09/39] [IMP] intrasta_base: Several imps: * Move description from __openerp__.py to README.rst Add conflict key in __openerp__.py Simplify code that create attachment Thanks to Luc de Meyer (Noviat) for his help on this. * Update README.rst and translation files * Simplify @depends, as suggested by Yannick * Better use of the new API for send_mail(), as suggested by Yannick (and tested be me) * Large code re-engineering following the Akretion-Noviat code sprint on intrastat This code has been written both by Luc de Meyer and myself. * Add first draft of code to generate decl lines --- intrastat_base/README.rst | 44 +++++ intrastat_base/__openerp__.py | 20 +-- intrastat_base/company_view.xml | 2 +- intrastat_base/country.py | 2 +- intrastat_base/i18n/fr_FR.po | 99 ++++++------ intrastat_base/i18n/intrastat_base.pot | 95 +++++------ intrastat_base/intrastat_common.py | 216 +++++++++++-------------- intrastat_base/intrastat_menu.xml | 16 -- intrastat_base/intrastat_view.xml | 36 +++++ intrastat_base/product.py | 2 +- intrastat_base/tax.py | 2 +- 11 files changed, 273 insertions(+), 261 deletions(-) create mode 100644 intrastat_base/README.rst delete mode 100644 intrastat_base/intrastat_menu.xml create mode 100644 intrastat_base/intrastat_view.xml diff --git a/intrastat_base/README.rst b/intrastat_base/README.rst new file mode 100644 index 0000000..a941d1d --- /dev/null +++ b/intrastat_base/README.rst @@ -0,0 +1,44 @@ +Intrastat Base Module +===================== + +This module contains common functions for the Intrastat reporting and +should be used in combination with country-specific reporting modules +such as: + +- *l10n_fr_intrastat_service*: + the module for the *Déclaration Européenne des Services* (DES) for France +- *l10n_fr_intrastat_product*: + the module for the *Déclaration d'Echange de Biens* (DEB) for France +- *l10n_be_intrastat_product*: + the module for the Intrastat Declaration for Belgium. + +These country-specific modules can be found in the OCA localization for those countries. + +Installation +============ + +WARNING: +This module conflicts with the module *report_intrastat* from the official addons. +If you have already installed the module *report_intrastat*, +you should uninstall it first before installing this module. + +Credits +======= + +Contributors +------------ + +* Alexis de Lattre, Akretion + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py index e795155..ea5483f 100644 --- a/intrastat_base/__openerp__.py +++ b/intrastat_base/__openerp__.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for Odoo +# Intrastat base module for Odoo # Copyright (C) 2011-2015 Akretion (http://www.akretion.com) # @author Alexis de Lattre # @@ -23,23 +23,13 @@ { 'name': 'Intrastat Reporting Base', 'version': '1.1', - 'category': 'Localisation/Report Intrastat', + 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat reporting', - 'description': """This module contains the common functions for 2 other modules : -- l10n_fr_intrastat_service : the module for the "Déclaration Européenne des Services" (DES) -- l10n_fr_intrastat_product : the module for the "Déclaration d'Echange de Biens" (DEB) -This module is not usefull if it's not used together with one of those 2 modules or other country-specific intrastat modules. - -This module doesn't have any France-specific stuff. So it can be used as a basis for other intrastat modules for other EU countries. - -WARNING : this module conflicts with the module "report_intrastat" from the addons. If you have already installed the module "report_intrastat", you should uninstall it first before installing this module. - -Please contact Alexis de Lattre from Akretion for any help or question about this module. - """, - 'author': 'Akretion', + 'author': 'Akretion,Odoo Community Association (OCA)', 'website': 'http://www.akretion.com', 'depends': ['base_vat'], + 'conflicts': ['report_intrastat'], 'data': [ 'country_data.xml', 'product_view.xml', @@ -47,7 +37,7 @@ Please contact Alexis de Lattre from Akretion for 'country_view.xml', 'tax_view.xml', 'company_view.xml', - 'intrastat_menu.xml', + 'intrastat_view.xml', ], 'demo': ['intrastat_demo.xml'], 'installable': True, diff --git a/intrastat_base/company_view.xml b/intrastat_base/company_view.xml index 87933f4..1df7aed 100644 --- a/intrastat_base/company_view.xml +++ b/intrastat_base/company_view.xml @@ -16,7 +16,7 @@ - + diff --git a/intrastat_base/country.py b/intrastat_base/country.py index 7f03e5d..7a34e77 100644 --- a/intrastat_base/country.py +++ b/intrastat_base/country.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for Odoo +# Intrastat base module for Odoo # Copyright (C) 2011-2014 Akretion (http://www.akretion.com). # @author Alexis de Lattre # diff --git a/intrastat_base/i18n/fr_FR.po b/intrastat_base/i18n/fr_FR.po index de7e5db..1b3d759 100644 --- a/intrastat_base/i18n/fr_FR.po +++ b/intrastat_base/i18n/fr_FR.po @@ -1,14 +1,14 @@ -# Translation of OpenERP Server. +# Translation of Odoo Server. # This file contains the translation of the following modules: # * intrastat_base # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" +"Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-04-14 14:18+0000\n" -"PO-Revision-Date: 2014-04-14 14:18+0000\n" -"Last-Translator: Alexis de Lattre \n" +"POT-Creation-Date: 2015-05-27 18:43+0000\n" +"PO-Revision-Date: 2015-05-27 18:43+0000\n" +"Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -21,47 +21,43 @@ msgid "Activate this option for shipping costs, packaging costs and all services msgstr "Activez cette option pour les frais de port, les frais d'emballage et tous les services liés à la vente de produits physiques. Cette option est utilisée pour la DEB et la DES." #. module: intrastat_base -#: view:res.company:0 +#: code:addons/intrastat_base/intrastat_common.py:165 +#, python-format +msgid "Cannot delete the declaration %s because it is in Done state" +msgstr "Impossible de supprimer la déclaration %s car elle est à l'état déclaré" + +#. module: intrastat_base +#: view:res.company:intrastat_base.view_company_form msgid "Common Intrastat Settings" msgstr "Paramètres communs DEB et DES" #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_report_intrastat_common -msgid "Common functions for intrastat reports for products and services" -msgstr "Fonctions communes pour la DEB et la DES" +msgid "Common functions for intrastat reports for products " +msgstr "" #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_res_company msgid "Companies" msgstr "Sociétés" +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:68 +#, python-format +msgid "Company not yet set on intrastat report." +msgstr "Société non configurée sur le rapport intrastat." + #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_res_country msgid "Country" msgstr "Pays" #. module: intrastat_base -#: view:res.country:0 +#: view:res.country:intrastat_base.view_country_search #: field:res.country,intrastat:0 msgid "EU Country" msgstr "Pays UE" -#. module: intrastat_base -#: code:addons/intrastat_base/company.py:58 -#: code:addons/intrastat_base/intrastat_common.py:77 -#: code:addons/intrastat_base/intrastat_common.py:82 -#: code:addons/intrastat_base/intrastat_common.py:90 -#: code:addons/intrastat_base/intrastat_common.py:110 -#: code:addons/intrastat_base/product.py:51 -#, python-format -msgid "Error :" -msgstr "Erreur :" - -#. module: intrastat_base -#: constraint:product.template:0 -msgid "Error msg is in raise" -msgstr "Error msg is in raise" - #. module: intrastat_base #: field:product.template,exclude_from_intrastat:0 msgid "Exclude from Intrastat reports" @@ -72,6 +68,11 @@ msgstr "Exclure de la DEB et de la DES" msgid "Exclude invoice line from intrastat if this tax is present" msgstr "Exclue la ligne de facture de la DEB/DES si cette taxe est présente" +#. module: intrastat_base +#: field:report.intrastat.common,id:0 +msgid "ID" +msgstr "ID" + #. module: intrastat_base #: help:product.template,exclude_from_intrastat:0 msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason." @@ -83,21 +84,20 @@ msgid "If this tax is present on an invoice line, this invoice line will be skip msgstr "Si cette taxe est présente sur une ligne de facture, cette ligne de facture ne sera pas prise en compte lors de la génération de la DEB et de la DES depuis les factures." #. module: intrastat_base -#: view:product.product:0 -#: view:product.template:0 +#: view:product.template:intrastat_base.product_template_form_view msgid "Intrastat Properties" msgstr "Propriétés DEB/DES" -#. module: intrastat_base -#: view:res.company:0 -msgid "Intrastat Settings" -msgstr "Configuration DEB/DES" - #. module: intrastat_base #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root msgid "Intrastat Reporting" msgstr "DEB et DES" +#. module: intrastat_base +#: view:res.company:intrastat_base.view_company_form +msgid "Intrastat Settings" +msgstr "Configuration DEB/DES" + #. module: intrastat_base #: field:product.template,is_accessory_cost:0 msgid "Is accessory cost" @@ -109,28 +109,18 @@ msgid "List of OpenERP users who will receive a notification to remind them abou msgstr "Liste d'utilisateurs OpenERP qui recevront le rappel pour la DEB et/ou la DES." #. module: intrastat_base -#: field:res.company,intrastat_email_list:0 -msgid "List of emails of Users Receiving the Intrastat Reminder" -msgstr "Liste des emails d'utilisateurs qui recevront le rappel pour la DEB et/ou la DES" - -#. module: intrastat_base -#: code:addons/intrastat_base/company.py:59 +#: code:addons/intrastat_base/company.py:55 #, python-format msgid "Missing e-mail address on user '%s'." msgstr "Adresse e-mail manquante sur l'utilisateur '%s'." -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_res_partner -msgid "Partner" -msgstr "Partenaire" - #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_product_template msgid "Product Template" msgstr "Modèle d'article" #. module: intrastat_base -#: view:res.country:0 +#: view:res.country:intrastat_base.view_country_search msgid "Search Countries" msgstr "Recherche des pays" @@ -150,42 +140,43 @@ msgid "Tax" msgstr "Taxes" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:91 +#: code:addons/intrastat_base/intrastat_common.py:84 #, python-format msgid "The VAT number is not set for the partner '%s'." msgstr "Le numéro de TVA n'est pas renseigné pour le partenaire '%s'." #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:83 +#: code:addons/intrastat_base/intrastat_common.py:76 #, python-format msgid "The company currency must be 'EUR', but is currently '%s'." msgstr "La monnaie de la société doit être 'EUR', mais est actuellement '%s'." #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:78 +#: code:addons/intrastat_base/intrastat_common.py:72 #, python-format msgid "The country is not set on the company '%s'." msgstr "Le pays n'est pas renseigné sur la société '%s'." #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:111 +#: code:addons/intrastat_base/intrastat_common.py:105 #, python-format msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." msgstr "La validation du fichier XML avec le schéma XML officiel a échoué. Le fichier XML généré et le détail de l'erreur ont été écrits dans les logs du serveur. Voici le message d'erreur, qui peut vous donner une idée de la cause du problème : %s." #. module: intrastat_base -#: code:addons/intrastat_base/product.py:56 +#: code:addons/intrastat_base/product.py:51 #, python-format msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" msgstr "L'option 'Frais accessoires' ne doit être activée que sur les produits de type 'Service'. Vous avez activé cette option sur le produit '%s' qui est de type '%s'" +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:62 +#, python-format +msgid "The start date must be the first day of the month" +msgstr "La date de début doit être le premier jour du mois" + #. module: intrastat_base #: field:res.company,intrastat_remind_user_ids:0 msgid "Users Receiving the Intrastat Reminder" msgstr "Utilisateurs qui reçoivent le rappel DEB/DES" -#. module: intrastat_base -#: constraint:res.company:0 -msgid "error msg in raise" -msgstr "error msg in raise" - diff --git a/intrastat_base/i18n/intrastat_base.pot b/intrastat_base/i18n/intrastat_base.pot index d184def..fdc6996 100644 --- a/intrastat_base/i18n/intrastat_base.pot +++ b/intrastat_base/i18n/intrastat_base.pot @@ -1,13 +1,13 @@ -# Translation of OpenERP Server. +# Translation of Odoo Server. # This file contains the translation of the following modules: # * intrastat_base # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" +"Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-04-14 14:18+0000\n" -"PO-Revision-Date: 2014-04-14 14:18+0000\n" +"POT-Creation-Date: 2015-05-27 18:43+0000\n" +"PO-Revision-Date: 2015-05-27 18:43+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,13 +21,19 @@ msgid "Activate this option for shipping costs, packaging costs and all services msgstr "" #. module: intrastat_base -#: view:res.company:0 +#: code:addons/intrastat_base/intrastat_common.py:165 +#, python-format +msgid "Cannot delete the declaration %s because it is in Done state" +msgstr "" + +#. module: intrastat_base +#: view:res.company:intrastat_base.view_company_form msgid "Common Intrastat Settings" msgstr "" #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_report_intrastat_common -msgid "Common functions for intrastat reports for products and services" +msgid "Common functions for intrastat reports for products " msgstr "" #. module: intrastat_base @@ -35,33 +41,23 @@ msgstr "" msgid "Companies" msgstr "" +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:68 +#, python-format +msgid "Company not yet set on intrastat report." +msgstr "" + #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_res_country msgid "Country" msgstr "" #. module: intrastat_base -#: view:res.country:0 +#: view:res.country:intrastat_base.view_country_search #: field:res.country,intrastat:0 msgid "EU Country" msgstr "" -#. module: intrastat_base -#: code:addons/intrastat_base/company.py:58 -#: code:addons/intrastat_base/intrastat_common.py:77 -#: code:addons/intrastat_base/intrastat_common.py:82 -#: code:addons/intrastat_base/intrastat_common.py:90 -#: code:addons/intrastat_base/intrastat_common.py:110 -#: code:addons/intrastat_base/product.py:51 -#, python-format -msgid "Error :" -msgstr "" - -#. module: intrastat_base -#: constraint:product.template:0 -msgid "Error msg is in raise" -msgstr "" - #. module: intrastat_base #: field:product.template,exclude_from_intrastat:0 msgid "Exclude from Intrastat reports" @@ -72,6 +68,11 @@ msgstr "" msgid "Exclude invoice line from intrastat if this tax is present" msgstr "" +#. module: intrastat_base +#: field:report.intrastat.common,id:0 +msgid "ID" +msgstr "" + #. module: intrastat_base #: help:product.template,exclude_from_intrastat:0 msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason." @@ -83,21 +84,20 @@ msgid "If this tax is present on an invoice line, this invoice line will be skip msgstr "" #. module: intrastat_base -#: view:product.product:0 -#: view:product.template:0 +#: view:product.template:intrastat_base.product_template_form_view msgid "Intrastat Properties" msgstr "" -#. module: intrastat_base -#: view:res.company:0 -msgid "Intrastat Settings" -msgstr "" - #. module: intrastat_base #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root msgid "Intrastat Reporting" msgstr "" +#. module: intrastat_base +#: view:res.company:intrastat_base.view_company_form +msgid "Intrastat Settings" +msgstr "" + #. module: intrastat_base #: field:product.template,is_accessory_cost:0 msgid "Is accessory cost" @@ -109,28 +109,18 @@ msgid "List of OpenERP users who will receive a notification to remind them abou msgstr "" #. module: intrastat_base -#: field:res.company,intrastat_email_list:0 -msgid "List of emails of Users Receiving the Intrastat Reminder" -msgstr "" - -#. module: intrastat_base -#: code:addons/intrastat_base/company.py:59 +#: code:addons/intrastat_base/company.py:55 #, python-format msgid "Missing e-mail address on user '%s'." msgstr "" -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_res_partner -msgid "Partner" -msgstr "" - #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_product_template msgid "Product Template" msgstr "" #. module: intrastat_base -#: view:res.country:0 +#: view:res.country:intrastat_base.view_country_search msgid "Search Countries" msgstr "" @@ -150,42 +140,43 @@ msgid "Tax" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:91 +#: code:addons/intrastat_base/intrastat_common.py:84 #, python-format msgid "The VAT number is not set for the partner '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:83 +#: code:addons/intrastat_base/intrastat_common.py:76 #, python-format msgid "The company currency must be 'EUR', but is currently '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:78 +#: code:addons/intrastat_base/intrastat_common.py:72 #, python-format msgid "The country is not set on the company '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:111 +#: code:addons/intrastat_base/intrastat_common.py:105 #, python-format msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/product.py:56 +#: code:addons/intrastat_base/product.py:51 #, python-format msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" msgstr "" +#. module: intrastat_base +#: code:addons/intrastat_base/intrastat_common.py:62 +#, python-format +msgid "The start date must be the first day of the month" +msgstr "" + #. module: intrastat_base #: field:res.company,intrastat_remind_user_ids:0 msgid "Users Receiving the Intrastat Reminder" msgstr "" -#. module: intrastat_base -#: constraint:res.company:0 -msgid "error msg in raise" -msgstr "" - diff --git a/intrastat_base/intrastat_common.py b/intrastat_base/intrastat_common.py index 3db1764..a18ea07 100644 --- a/intrastat_base/intrastat_common.py +++ b/intrastat_base/intrastat_common.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for OpenERP -# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/). +# Intrastat base module for Odoo +# Copyright (C) 2010-2014 Akretion (http://www.akretion.com/). # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,91 +20,72 @@ # ############################################################################## -from openerp.osv import orm -from openerp.tools.translate import _ -from openerp import tools -from datetime import datetime +from openerp import models, fields, api, tools, _ +from openerp.exceptions import Warning, ValidationError from dateutil.relativedelta import relativedelta import logging logger = logging.getLogger(__name__) -class report_intrastat_common(orm.TransientModel): - _name = "report.intrastat.common" +class IntrastatCommon(models.AbstractModel): + _name = "intrastat.common" _description = "Common functions for intrastat reports for products " "and services" - def _compute_numbers(self, cr, uid, ids, object, context=None): - result = {} - for intrastat in object.browse(cr, uid, ids, context=context): - total_amount = 0.0 - num_lines = 0 - for line in intrastat.intrastat_line_ids: - total_amount += line.amount_company_currency - num_lines += 1 - result[intrastat.id] = { - 'num_lines': num_lines, - 'total_amount': total_amount, - } - return result + @api.one + @api.depends('declaration_line_ids.amount_company_currency') + def _compute_numbers(self): + total_amount = 0.0 + num_lines = 0 + for line in self.declaration_line_ids: + total_amount += line.amount_company_currency + num_lines += 1 + self.num_decl_lines = num_lines + self.total_amount = total_amount - def _compute_dates(self, cr, uid, ids, object, context=None): - result = {} - for intrastat in object.browse(cr, uid, ids, context=context): - start_date_datetime = datetime.strptime( - intrastat.start_date, '%Y-%m-%d') - end_date_str = datetime.strftime( - start_date_datetime + relativedelta(day=31), '%Y-%m-%d') - result[intrastat.id] = { - 'end_date': end_date_str, - 'year_month': start_date_datetime.strftime('%Y-%m'), - } - return result + @api.one + @api.depends('start_date') + def _compute_dates(self): + start_date_dt = fields.Date.from_string(self.start_date) + self.end_date = fields.Date.to_string( + start_date_dt + relativedelta(day=31)) + self.year_month = start_date_dt.strftime('%Y-%m') - def _check_start_date(self, cr, uid, ids, object, context=None): + @api.one + def _check_start_date(self): '''Check that the start date is the first day of the month''' - for date_to_check in object.read( - cr, uid, ids, ['start_date'], context=context): - datetime_to_check = datetime.strptime( - date_to_check['start_date'], '%Y-%m-%d') - if datetime_to_check.day != 1: - return False - return True + datetime_to_check = fields.Date.from_string(self.start_date) + if datetime_to_check.day != 1: + raise ValidationError( + _('The start date must be the first day of the month')) - def _check_generate_lines(self, cr, uid, intrastat, context=None): + @api.one + def _check_generate_lines(self): """Check wether all requirements are met for generating lines.""" - if not intrastat.company_id: - # Should not be possible, but just in case: - raise orm.except_orm( - _('Error :'), - _("Company not yet set on intrastat report.") - ) - company_obj = intrastat.company_id # Simplify references + if not self.company_id: + raise Warning(_("Company not yet set on intrastat report.")) + company_obj = self.company_id if not company_obj.country_id: - raise orm.except_orm( - _('Error :'), + raise Warning( _("The country is not set on the company '%s'.") - % company_obj.name - ) - if not company_obj.currency_id.name == 'EUR': - raise orm.except_orm( - _('Error :'), + % company_obj.name) + if company_obj.currency_id.name != 'EUR': + raise Warning( _("The company currency must be 'EUR', but is currently '%s'.") - % company_obj.currency_id.name - ) + % company_obj.currency_id.name) return True - def _check_generate_xml(self, cr, uid, intrastat, context=None): - if not intrastat.company_id.partner_id.vat: - raise orm.except_orm( - _('Error :'), + @api.one + def _check_generate_xml(self): + if not self.company_id.partner_id.vat: + raise Warning( _("The VAT number is not set for the partner '%s'.") - % intrastat.company_id.partner_id.name) + % self.company_id.partner_id.name) return True - def _check_xml_schema( - self, cr, uid, xml_root, xml_string, xsd_file, context=None): + @api.model + def _check_xml_schema(self, xml_root, xml_string, xsd_file): '''Validate the XML file against the XSD''' from lxml import etree xsd_etree_obj = etree.parse( @@ -114,13 +95,12 @@ class report_intrastat_common(orm.TransientModel): official_schema.assertValid(xml_root) except Exception, e: # if the validation of the XSD fails, we arrive here - _logger = logging.getLogger(__name__) - _logger.warning( + logger = logging.getLogger(__name__) + logger.warning( "The XML file is invalid against the XML Schema Definition") - _logger.warning(xml_string) - _logger.warning(e) - raise orm.except_orm( - _('Error :'), + logger.warning(xml_string) + logger.warning(e) + raise Warning( _("The generated XML file is not valid against the official " "XML Schema Definition. The generated XML file and the " "full error have been written in the server logs. " @@ -129,39 +109,29 @@ class report_intrastat_common(orm.TransientModel): % str(e)) return True - def _attach_xml_file( - self, cr, uid, ids, object, xml_string, start_date_datetime, - declaration_name, context=None): - '''Attach the XML file to the report_intrastat_product/service ''' - '''object''' + @api.multi + def _attach_xml_file(self, xml_string, declaration_name): + '''Attach the XML file to the report_intrastat_product/service + object''' + self.ensure_one() import base64 - assert len(ids) == 1, "Only one ID accepted" - filename = '%s_%s.xml' % ( - datetime.strftime(start_date_datetime, '%Y-%m'), - declaration_name) - if not context: - context = {} - context.update({ - 'default_res_id': ids[0], - 'default_res_model': object._name - }) - attach_id = self.pool['ir.attachment'].create( - cr, uid, { - 'name': filename, - 'datas': base64.encodestring(xml_string), - 'datas_fname': filename}, - context=context) - return attach_id + filename = '%s_%s.xml' % (self.year_month, declaration_name) + attach = self.env['ir.attachment'].create({ + 'name': filename, + 'res_id': self.id, + 'res_model': self._name, + 'datas': base64.encodestring(xml_string), + 'datas_fname': filename}) + return attach.id - def _open_attach_view( - self, cr, uid, attach_id, title='XML file', context=None): - '''Returns an action which opens the form view of the ''' - '''corresponding attachement''' + @api.model + def _open_attach_view(self, attach_id, title='XML file'): + '''Returns an action which opens the form view of the + corresponding attachement''' action = { 'name': title, 'view_type': 'form', - 'view_mode': 'form,tree', - 'view_id': False, + 'view_mode': 'form', 'res_model': 'ir.attachment', 'type': 'ir.actions.act_window', 'nodestroy': True, @@ -170,30 +140,36 @@ class report_intrastat_common(orm.TransientModel): } return action - def partner_on_change(self, cr, uid, ids, partner_id=False, context=None): - result = {} - result['value'] = {} - if partner_id: - company = self.pool['res.partner'].read( - cr, uid, partner_id, ['vat'], context=context) - result['value']['partner_vat'] = company['vat'] - return result - - def send_reminder_email( - self, cr, uid, company, module_name, template_xmlid, - intrastat_id, context=None): - template_model, template_id =\ - self.pool['ir.model.data'].get_object_reference( - cr, uid, module_name, template_xmlid) - assert template_model == 'email.template', 'Wrong model' - if company.intrastat_remind_user_ids: - self.pool['email.template'].send_mail( - cr, uid, template_id, intrastat_id, context=context) + @api.one + def send_reminder_email(self, mail_template_xmlid): + mail_template = self.env.ref(mail_template_xmlid) + if self.company_id.intrastat_remind_user_ids: + mail_template.send_mail(self.id) logger.info( 'Intrastat Reminder email has been sent (XMLID: %s).' - % template_xmlid) + % mail_template_xmlid) else: logger.warning( 'The list of users receiving the Intrastat Reminder is empty ' - 'on company %s' % company.name) + 'on company %s' % self.company_id.name) return True + + @api.multi + def unlink(self): + for intrastat in self: + if intrastat.state == 'done': + raise Warning( + _('Cannot delete the declaration %s ' + 'because it is in Done state') % self.year_month) + return super(IntrastatCommon, self).unlink() + + +class IntrastatResultView(models.TransientModel): + """ + Transient Model to display Intrastat Report results + """ + _name = 'intrastat.result.view' + + note = fields.Text( + string='Notes', readonly=True, + default=lambda self: self._context.get('note')) diff --git a/intrastat_base/intrastat_menu.xml b/intrastat_base/intrastat_menu.xml deleted file mode 100644 index 85303c1..0000000 --- a/intrastat_base/intrastat_menu.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/intrastat_base/intrastat_view.xml b/intrastat_base/intrastat_view.xml new file mode 100644 index 0000000..4d9c22a --- /dev/null +++ b/intrastat_base/intrastat_view.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + intrastat.result_view_form + intrastat.result.view + +
+ + + +
+
+
+
+
+ +
+
diff --git a/intrastat_base/product.py b/intrastat_base/product.py index ca1652e..5373cb3 100644 --- a/intrastat_base/product.py +++ b/intrastat_base/product.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for OpenERP +# Intrastat base module for Odoo # Copyright (C) 2010-2014 Akretion (http://www.akretion.com/) # @author Alexis de Lattre # diff --git a/intrastat_base/tax.py b/intrastat_base/tax.py index 2b98678..197e51d 100644 --- a/intrastat_base/tax.py +++ b/intrastat_base/tax.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Report intrastat base module for Odoo +# Intrastat base module for Odoo # Copyright (C) 2011-2014 Akretion (http://www.akretion.com). # @author Alexis de Lattre # From c3569b22369e348e93547e732a0e3a5a780eeb24 Mon Sep 17 00:00:00 2001 From: luc-demeyer Date: Tue, 20 Oct 2015 20:26:19 +0200 Subject: [PATCH 10/39] [REF] intrastat_base: major update intrastat V3 --- intrastat_base/README.rst | 37 +++++++++++++++++-- intrastat_base/__init__.py | 6 +-- intrastat_base/__openerp__.py | 20 +++++----- intrastat_base/{ => data}/country_data.xml | 0 intrastat_base/{ => demo}/intrastat_demo.xml | 0 intrastat_base/models/__init__.py | 27 ++++++++++++++ .../{tax.py => models/account_tax.py} | 0 .../{ => models}/intrastat_common.py | 27 +++++++++++++- .../product_template.py} | 0 .../{company.py => models/res_company.py} | 20 +++++----- .../{country.py => models/res_country.py} | 0 .../{tax_view.xml => views/account_tax.xml} | 0 .../intrastat.xml} | 2 +- .../product_template.xml} | 0 .../res_company.xml} | 0 .../res_country.xml} | 2 +- .../res_partner.xml} | 0 17 files changed, 110 insertions(+), 31 deletions(-) rename intrastat_base/{ => data}/country_data.xml (100%) rename intrastat_base/{ => demo}/intrastat_demo.xml (100%) create mode 100644 intrastat_base/models/__init__.py rename intrastat_base/{tax.py => models/account_tax.py} (100%) rename intrastat_base/{ => models}/intrastat_common.py (90%) rename intrastat_base/{product.py => models/product_template.py} (100%) rename intrastat_base/{company.py => models/res_company.py} (100%) rename intrastat_base/{country.py => models/res_country.py} (100%) rename intrastat_base/{tax_view.xml => views/account_tax.xml} (100%) rename intrastat_base/{intrastat_view.xml => views/intrastat.xml} (94%) rename intrastat_base/{product_view.xml => views/product_template.xml} (100%) rename intrastat_base/{company_view.xml => views/res_company.xml} (100%) rename intrastat_base/{country_view.xml => views/res_country.xml} (96%) rename intrastat_base/{partner_view.xml => views/res_partner.xml} (100%) diff --git a/intrastat_base/README.rst b/intrastat_base/README.rst index a941d1d..1a5cc85 100644 --- a/intrastat_base/README.rst +++ b/intrastat_base/README.rst @@ -1,3 +1,9 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + + +===================== Intrastat Base Module ===================== @@ -12,16 +18,39 @@ such as: - *l10n_be_intrastat_product*: the module for the Intrastat Declaration for Belgium. -These country-specific modules can be found in the OCA localization for those countries. Installation ============ WARNING: + This module conflicts with the module *report_intrastat* from the official addons. If you have already installed the module *report_intrastat*, you should uninstall it first before installing this module. +Usage +===== + +To create H.S. codes, go to the menu *Sales > Configuration > Product Categories and Attributes > H.S. Codes*. + +Then you will be able to set the H.S. code on an product (under the *Information* tab) or on a product category. On the product form, you will also be able to set the *Country of Origin* of a product (for example, if the product is *made in China*, select *China* as *Country of Origin*). + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/91/8.0 + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here `_. + + Credits ======= @@ -29,16 +58,18 @@ Contributors ------------ * Alexis de Lattre, Akretion +* Luc De Meyer, Noviat Maintainer ---------- - .. image:: http://odoo-community.org/logo.png :alt: Odoo Community Association :target: http://odoo-community.org This module is maintained by the OCA. -OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. To contribute to this module, please visit http://odoo-community.org. diff --git a/intrastat_base/__init__.py b/intrastat_base/__init__.py index 21b2067..cd5b2df 100644 --- a/intrastat_base/__init__.py +++ b/intrastat_base/__init__.py @@ -20,8 +20,4 @@ # ############################################################################## -from . import country -from . import product -from . import tax -from . import company -from . import intrastat_common +from . import models diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py index ea5483f..f50f146 100644 --- a/intrastat_base/__openerp__.py +++ b/intrastat_base/__openerp__.py @@ -22,7 +22,7 @@ { 'name': 'Intrastat Reporting Base', - 'version': '1.1', + 'version': '1.2', 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat reporting', @@ -31,14 +31,16 @@ 'depends': ['base_vat'], 'conflicts': ['report_intrastat'], 'data': [ - 'country_data.xml', - 'product_view.xml', - 'partner_view.xml', - 'country_view.xml', - 'tax_view.xml', - 'company_view.xml', - 'intrastat_view.xml', + 'data/country_data.xml', + 'views/product_template.xml', + 'views/res_partner.xml', + 'views/res_country.xml', + 'views/account_tax.xml', + 'views/res_company.xml', + 'views/intrastat.xml', + ], + 'demo': [ + 'demo/intrastat_demo.xml', ], - 'demo': ['intrastat_demo.xml'], 'installable': True, } diff --git a/intrastat_base/country_data.xml b/intrastat_base/data/country_data.xml similarity index 100% rename from intrastat_base/country_data.xml rename to intrastat_base/data/country_data.xml diff --git a/intrastat_base/intrastat_demo.xml b/intrastat_base/demo/intrastat_demo.xml similarity index 100% rename from intrastat_base/intrastat_demo.xml rename to intrastat_base/demo/intrastat_demo.xml diff --git a/intrastat_base/models/__init__.py b/intrastat_base/models/__init__.py new file mode 100644 index 0000000..18530f9 --- /dev/null +++ b/intrastat_base/models/__init__.py @@ -0,0 +1,27 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Report intrastat base module for Odoo +# Copyright (C) 2011-2014 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 . import res_country +from . import product_template +from . import account_tax +from . import res_company +from . import intrastat_common diff --git a/intrastat_base/tax.py b/intrastat_base/models/account_tax.py similarity index 100% rename from intrastat_base/tax.py rename to intrastat_base/models/account_tax.py diff --git a/intrastat_base/intrastat_common.py b/intrastat_base/models/intrastat_common.py similarity index 90% rename from intrastat_base/intrastat_common.py rename to intrastat_base/models/intrastat_common.py index a18ea07..ae892c0 100644 --- a/intrastat_base/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -85,14 +85,16 @@ class IntrastatCommon(models.AbstractModel): return True @api.model - def _check_xml_schema(self, xml_root, xml_string, xsd_file): + def _check_xml_schema(self, xml_string, xsd_file): '''Validate the XML file against the XSD''' from lxml import etree + from StringIO import StringIO xsd_etree_obj = etree.parse( tools.file_open(xsd_file)) official_schema = etree.XMLSchema(xsd_etree_obj) try: - official_schema.assertValid(xml_root) + t = etree.parse(StringIO(xml_string)) + official_schema.assertValid(t) except Exception, e: # if the validation of the XSD fails, we arrive here logger = logging.getLogger(__name__) @@ -124,6 +126,13 @@ class IntrastatCommon(models.AbstractModel): 'datas_fname': filename}) return attach.id + @api.multi + def _unlink_attachments(self): + atts = self.env['ir.attachment'].search( + [('res_model', '=', self._name), + ('res_id', '=', self.id)]) + atts.unlink() + @api.model def _open_attach_view(self, attach_id, title='XML file'): '''Returns an action which opens the form view of the @@ -140,6 +149,20 @@ class IntrastatCommon(models.AbstractModel): } return action + @api.multi + def _generate_xml(self): + """ + Inherit this method in the localization module + to generate the INTRASTAT Declaration XML file + + Returns: + string with XML data + + Call the _check_xml_schema() method + before returning the XML string. + """ + return False + @api.one def send_reminder_email(self, mail_template_xmlid): mail_template = self.env.ref(mail_template_xmlid) diff --git a/intrastat_base/product.py b/intrastat_base/models/product_template.py similarity index 100% rename from intrastat_base/product.py rename to intrastat_base/models/product_template.py diff --git a/intrastat_base/company.py b/intrastat_base/models/res_company.py similarity index 100% rename from intrastat_base/company.py rename to intrastat_base/models/res_company.py index 9fea8e4..2206c76 100644 --- a/intrastat_base/company.py +++ b/intrastat_base/models/res_company.py @@ -27,16 +27,6 @@ from openerp.exceptions import ValidationError class ResCompany(models.Model): _inherit = "res.company" - @api.one - @api.depends( - 'intrastat_remind_user_ids', 'intrastat_remind_user_ids.email') - def _compute_intrastat_email_list(self): - emails = [] - for user in self.intrastat_remind_user_ids: - if user.email: - emails.append(user.email) - self.intrastat_email_list = ','.join(emails) - intrastat_remind_user_ids = fields.Many2many( 'res.users', column1='company_id', column2='user_id', string="Users Receiving the Intrastat Reminder", @@ -46,6 +36,16 @@ class ResCompany(models.Model): compute='_compute_intrastat_email_list', string='List of emails of Users Receiving the Intrastat Reminder') + @api.one + @api.depends( + 'intrastat_remind_user_ids', 'intrastat_remind_user_ids.email') + def _compute_intrastat_email_list(self): + emails = [] + for user in self.intrastat_remind_user_ids: + if user.email: + emails.append(user.email) + self.intrastat_email_list = ','.join(emails) + @api.one @api.constrains('intrastat_remind_user_ids') def _check_intrastat_remind_users(self): diff --git a/intrastat_base/country.py b/intrastat_base/models/res_country.py similarity index 100% rename from intrastat_base/country.py rename to intrastat_base/models/res_country.py diff --git a/intrastat_base/tax_view.xml b/intrastat_base/views/account_tax.xml similarity index 100% rename from intrastat_base/tax_view.xml rename to intrastat_base/views/account_tax.xml diff --git a/intrastat_base/intrastat_view.xml b/intrastat_base/views/intrastat.xml similarity index 94% rename from intrastat_base/intrastat_view.xml rename to intrastat_base/views/intrastat.xml index 4d9c22a..7b4cdf7 100644 --- a/intrastat_base/intrastat_view.xml +++ b/intrastat_base/views/intrastat.xml @@ -17,7 +17,7 @@ parent="account.menu_finance_configuration" sequence="50"/> - + intrastat.result_view_form intrastat.result.view diff --git a/intrastat_base/product_view.xml b/intrastat_base/views/product_template.xml similarity index 100% rename from intrastat_base/product_view.xml rename to intrastat_base/views/product_template.xml diff --git a/intrastat_base/company_view.xml b/intrastat_base/views/res_company.xml similarity index 100% rename from intrastat_base/company_view.xml rename to intrastat_base/views/res_company.xml diff --git a/intrastat_base/country_view.xml b/intrastat_base/views/res_country.xml similarity index 96% rename from intrastat_base/country_view.xml rename to intrastat_base/views/res_country.xml index d887a22..ac0f6f6 100644 --- a/intrastat_base/country_view.xml +++ b/intrastat_base/views/res_country.xml @@ -32,7 +32,7 @@ - + intrastat.base.country.search res.country diff --git a/intrastat_base/partner_view.xml b/intrastat_base/views/res_partner.xml similarity index 100% rename from intrastat_base/partner_view.xml rename to intrastat_base/views/res_partner.xml From 59a3934f59e9d71b693b75b717dec093b85cab8b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 10 Nov 2015 21:36:50 +0100 Subject: [PATCH 11/39] [IMP] intrastat_base: A lot of imps: * Add product_origin_country_id on declaration/computation lines Copy incoterms and destination country from SO to invoice when invoicing from SO We need weight even when supplementary units is used Small cleanups and enhancements * Add support for accessory costs Add default values for intrastat transaction on company Code cleanup * If rounded weight is 0, put 1 Take into account the taxes for B2C Small code cleanup * Remove field exclude_from_intrastat Re-organise view of intrastat.product.declaration * Add option intrastat_accessory_costs on company Set more fields as invisible (localisation should put them visible if they need it) Fix handling of suppl. units when hs_code is empty on invoice line (but set on product) Small usability enhancements * Warning -> UserError * Inspired by the PR https://github.com/akretion/account-financial-reporting/pull/8 of Luc de Meyer * total_amount is a sum of integers, so it should be an integer Add transport mode in computation tree view * Demo VAT number should be on EU customers --- intrastat_base/__openerp__.py | 2 +- intrastat_base/demo/intrastat_demo.xml | 2 +- intrastat_base/models/__init__.py | 22 +------------- intrastat_base/models/account_tax.py | 2 +- intrastat_base/models/intrastat_common.py | 35 ++++++----------------- intrastat_base/models/product_template.py | 8 +----- intrastat_base/models/res_company.py | 2 +- intrastat_base/models/res_country.py | 2 +- intrastat_base/views/account_tax.xml | 5 ++-- intrastat_base/views/intrastat.xml | 2 +- intrastat_base/views/product_template.xml | 4 +-- 11 files changed, 22 insertions(+), 64 deletions(-) diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py index f50f146..a9e92b0 100644 --- a/intrastat_base/__openerp__.py +++ b/intrastat_base/__openerp__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Intrastat base module for Odoo diff --git a/intrastat_base/demo/intrastat_demo.xml b/intrastat_base/demo/intrastat_demo.xml index 953d92b..422afa8 100644 --- a/intrastat_base/demo/intrastat_demo.xml +++ b/intrastat_base/demo/intrastat_demo.xml @@ -18,7 +18,7 @@ True - + BE0443167858 True diff --git a/intrastat_base/models/__init__.py b/intrastat_base/models/__init__.py index 18530f9..a571f6a 100644 --- a/intrastat_base/models/__init__.py +++ b/intrastat_base/models/__init__.py @@ -1,24 +1,4 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Report intrastat base module for Odoo -# Copyright (C) 2011-2014 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 . -# -############################################################################## +# -*- coding: utf-8 -*- from . import res_country from . import product_template diff --git a/intrastat_base/models/account_tax.py b/intrastat_base/models/account_tax.py index 197e51d..e11db59 100644 --- a/intrastat_base/models/account_tax.py +++ b/intrastat_base/models/account_tax.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Intrastat base module for Odoo diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index ae892c0..3d44b7c 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Intrastat base module for Odoo @@ -21,8 +21,7 @@ ############################################################################## from openerp import models, fields, api, tools, _ -from openerp.exceptions import Warning, ValidationError -from dateutil.relativedelta import relativedelta +from openerp.exceptions import Warning as UserError import logging logger = logging.getLogger(__name__) @@ -36,7 +35,7 @@ class IntrastatCommon(models.AbstractModel): @api.one @api.depends('declaration_line_ids.amount_company_currency') def _compute_numbers(self): - total_amount = 0.0 + total_amount = 0 # it is an integer num_lines = 0 for line in self.declaration_line_ids: total_amount += line.amount_company_currency @@ -44,34 +43,18 @@ class IntrastatCommon(models.AbstractModel): self.num_decl_lines = num_lines self.total_amount = total_amount - @api.one - @api.depends('start_date') - def _compute_dates(self): - start_date_dt = fields.Date.from_string(self.start_date) - self.end_date = fields.Date.to_string( - start_date_dt + relativedelta(day=31)) - self.year_month = start_date_dt.strftime('%Y-%m') - - @api.one - def _check_start_date(self): - '''Check that the start date is the first day of the month''' - datetime_to_check = fields.Date.from_string(self.start_date) - if datetime_to_check.day != 1: - raise ValidationError( - _('The start date must be the first day of the month')) - @api.one def _check_generate_lines(self): """Check wether all requirements are met for generating lines.""" if not self.company_id: - raise Warning(_("Company not yet set on intrastat report.")) + raise UserError(_("Company not yet set on intrastat report.")) company_obj = self.company_id if not company_obj.country_id: - raise Warning( + raise UserError( _("The country is not set on the company '%s'.") % company_obj.name) if company_obj.currency_id.name != 'EUR': - raise Warning( + raise UserError( _("The company currency must be 'EUR', but is currently '%s'.") % company_obj.currency_id.name) return True @@ -79,7 +62,7 @@ class IntrastatCommon(models.AbstractModel): @api.one def _check_generate_xml(self): if not self.company_id.partner_id.vat: - raise Warning( + raise UserError( _("The VAT number is not set for the partner '%s'.") % self.company_id.partner_id.name) return True @@ -102,7 +85,7 @@ class IntrastatCommon(models.AbstractModel): "The XML file is invalid against the XML Schema Definition") logger.warning(xml_string) logger.warning(e) - raise Warning( + raise UserError( _("The generated XML file is not valid against the official " "XML Schema Definition. The generated XML file and the " "full error have been written in the server logs. " @@ -181,7 +164,7 @@ class IntrastatCommon(models.AbstractModel): def unlink(self): for intrastat in self: if intrastat.state == 'done': - raise Warning( + raise UserError( _('Cannot delete the declaration %s ' 'because it is in Done state') % self.year_month) return super(IntrastatCommon, self).unlink() diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index 5373cb3..30132bc 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Intrastat base module for Odoo @@ -27,12 +27,6 @@ from openerp.exceptions import ValidationError class ProductTemplate(models.Model): _inherit = "product.template" - exclude_from_intrastat = fields.Boolean( - string='Exclude from Intrastat reports', - help="If set to True, the product or service will not be " - "taken into account for Intrastat Product or Service reports. " - "So you should leave this field to False unless you have a " - "very good reason.") is_accessory_cost = fields.Boolean( string='Is accessory cost', help="Activate this option for shipping costs, packaging " diff --git a/intrastat_base/models/res_company.py b/intrastat_base/models/res_company.py index 2206c76..1175d76 100644 --- a/intrastat_base/models/res_company.py +++ b/intrastat_base/models/res_company.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Intrastat base module for Odoo diff --git a/intrastat_base/models/res_country.py b/intrastat_base/models/res_country.py index 7a34e77..8703f10 100644 --- a/intrastat_base/models/res_country.py +++ b/intrastat_base/models/res_country.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Intrastat base module for Odoo diff --git a/intrastat_base/views/account_tax.xml b/intrastat_base/views/account_tax.xml index 5defe29..1e91bb5 100644 --- a/intrastat_base/views/account_tax.xml +++ b/intrastat_base/views/account_tax.xml @@ -1,7 +1,7 @@ @@ -16,7 +16,8 @@ - + + diff --git a/intrastat_base/views/intrastat.xml b/intrastat_base/views/intrastat.xml index 7b4cdf7..73762d0 100644 --- a/intrastat_base/views/intrastat.xml +++ b/intrastat_base/views/intrastat.xml @@ -11,7 +11,7 @@ diff --git a/intrastat_base/views/product_template.xml b/intrastat_base/views/product_template.xml index dc61ca5..1f4f73f 100644 --- a/intrastat_base/views/product_template.xml +++ b/intrastat_base/views/product_template.xml @@ -16,9 +16,9 @@ - + attrs="{'invisible': [('type', '!=', 'service')]}" + invisible="1"/> From 863da64b04caad17287c5bc616957e6d0c87873a Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 30 May 2016 13:02:55 +0200 Subject: [PATCH 12/39] [FIX] intrastat_base: this week's ci errors + wrong variable name --- intrastat_base/__openerp__.py | 2 +- intrastat_base/models/intrastat_common.py | 75 ++++++++++++----------- intrastat_base/models/product_template.py | 17 ++--- intrastat_base/models/res_company.py | 26 ++++---- 4 files changed, 64 insertions(+), 56 deletions(-) diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py index a9e92b0..594ff8a 100644 --- a/intrastat_base/__openerp__.py +++ b/intrastat_base/__openerp__.py @@ -22,7 +22,7 @@ { 'name': 'Intrastat Reporting Base', - 'version': '1.2', + 'version': '8.0.1.2.0', 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat reporting', diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index 3d44b7c..ff49c96 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -32,39 +32,43 @@ class IntrastatCommon(models.AbstractModel): _description = "Common functions for intrastat reports for products " "and services" - @api.one + @api.multi @api.depends('declaration_line_ids.amount_company_currency') def _compute_numbers(self): - total_amount = 0 # it is an integer - num_lines = 0 - for line in self.declaration_line_ids: - total_amount += line.amount_company_currency - num_lines += 1 - self.num_decl_lines = num_lines - self.total_amount = total_amount + for this in self: + total_amount = 0 # it is an integer + num_lines = 0 + for line in this.declaration_line_ids: + total_amount += line.amount_company_currency + num_lines += 1 + this.num_decl_lines = num_lines + this.total_amount = total_amount - @api.one + @api.multi def _check_generate_lines(self): """Check wether all requirements are met for generating lines.""" - if not self.company_id: - raise UserError(_("Company not yet set on intrastat report.")) - company_obj = self.company_id - if not company_obj.country_id: - raise UserError( - _("The country is not set on the company '%s'.") - % company_obj.name) - if company_obj.currency_id.name != 'EUR': - raise UserError( - _("The company currency must be 'EUR', but is currently '%s'.") - % company_obj.currency_id.name) + for this in self: + if not this.company_id: + raise UserError(_("Company not yet set on intrastat report.")) + company = this.company_id + if not company.country_id: + raise UserError( + _("The country is not set on the company '%s'.") + % company.name) + if company.currency_id.name != 'EUR': + raise UserError( + _("The company currency must be 'EUR', but is currently " + "'%s'.") + % company.currency_id.name) return True - @api.one + @api.multi def _check_generate_xml(self): - if not self.company_id.partner_id.vat: - raise UserError( - _("The VAT number is not set for the partner '%s'.") - % self.company_id.partner_id.name) + for this in self: + if not this.company_id.partner_id.vat: + raise UserError( + _("The VAT number is not set for the partner '%s'.") + % this.company_id.partner_id.name) return True @api.model @@ -146,18 +150,19 @@ class IntrastatCommon(models.AbstractModel): """ return False - @api.one + @api.multi def send_reminder_email(self, mail_template_xmlid): mail_template = self.env.ref(mail_template_xmlid) - if self.company_id.intrastat_remind_user_ids: - mail_template.send_mail(self.id) - logger.info( - 'Intrastat Reminder email has been sent (XMLID: %s).' - % mail_template_xmlid) - else: - logger.warning( - 'The list of users receiving the Intrastat Reminder is empty ' - 'on company %s' % self.company_id.name) + for this in self: + if this.company_id.intrastat_remind_user_ids: + mail_template.send_mail(this.id) + logger.info( + 'Intrastat Reminder email has been sent (XMLID: %s).' + % mail_template_xmlid) + else: + logger.warning( + 'The list of users receiving the Intrastat Reminder is ' + 'empty on company %s' % this.company_id.name) return True @api.multi diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index 30132bc..07e0b2b 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -33,13 +33,14 @@ class ProductTemplate(models.Model): "costs and all services related to the sale of products. " "This option is used for Intrastat reports.") - @api.one + @api.multi @api.constrains('type', 'is_accessory_cost') def _check_accessory_cost(self): - if self.is_accessory_cost and self.type != 'service': - raise ValidationError( - _("The option 'Is accessory cost?' should only be " - "activated on 'Service' products. You have activated " - "this option for the product '%s' which is of type " - "'%s'" - % (self.name, self.type))) + for this in self: + if this.is_accessory_cost and this.type != 'service': + raise ValidationError( + _("The option 'Is accessory cost?' should only be " + "activated on 'Service' products. You have activated " + "this option for the product '%s' which is of type " + "'%s'") % + (this.name, this.type)) diff --git a/intrastat_base/models/res_company.py b/intrastat_base/models/res_company.py index 1175d76..291d846 100644 --- a/intrastat_base/models/res_company.py +++ b/intrastat_base/models/res_company.py @@ -36,21 +36,23 @@ class ResCompany(models.Model): compute='_compute_intrastat_email_list', string='List of emails of Users Receiving the Intrastat Reminder') - @api.one + @api.multi @api.depends( 'intrastat_remind_user_ids', 'intrastat_remind_user_ids.email') def _compute_intrastat_email_list(self): - emails = [] - for user in self.intrastat_remind_user_ids: - if user.email: - emails.append(user.email) - self.intrastat_email_list = ','.join(emails) + for this in self: + emails = [] + for user in this.intrastat_remind_user_ids: + if user.email: + emails.append(user.email) + this.intrastat_email_list = ','.join(emails) - @api.one + @api.multi @api.constrains('intrastat_remind_user_ids') def _check_intrastat_remind_users(self): - for user in self.intrastat_remind_user_ids: - if not user.email: - raise ValidationError( - _("Missing e-mail address on user '%s'.") - % (user.name)) + for this in self: + for user in this.intrastat_remind_user_ids: + if not user.email: + raise ValidationError( + _("Missing e-mail address on user '%s'.") % + (user.name)) From 629ccfdab2cdc6eb6469d4226e9be5a526e90a6e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 21 Jun 2016 10:41:52 +0200 Subject: [PATCH 13/39] Cleaner view inheritance (works both in v8 and v9) --- intrastat_base/views/res_company.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intrastat_base/views/res_company.xml b/intrastat_base/views/res_company.xml index 1df7aed..0565f00 100644 --- a/intrastat_base/views/res_company.xml +++ b/intrastat_base/views/res_company.xml @@ -14,8 +14,8 @@ res.company - - + + From 9e1ad00c397368c72b1675681b1c4bd78b88ec52 Mon Sep 17 00:00:00 2001 From: luc-demeyer Date: Mon, 3 Oct 2016 15:25:23 +0200 Subject: [PATCH 14/39] update intrastat_base --- intrastat_base/__init__.py | 23 +---------------------- intrastat_base/__openerp__.py | 2 +- intrastat_base/views/account_tax.xml | 3 +-- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/intrastat_base/__init__.py b/intrastat_base/__init__.py index cd5b2df..a0fdc10 100644 --- a/intrastat_base/__init__.py +++ b/intrastat_base/__init__.py @@ -1,23 +1,2 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Report intrastat base module for Odoo -# Copyright (C) 2011-2014 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 . -# -############################################################################## - +# -*- coding: utf-8 -*- from . import models diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py index 594ff8a..12a810b 100644 --- a/intrastat_base/__openerp__.py +++ b/intrastat_base/__openerp__.py @@ -22,7 +22,7 @@ { 'name': 'Intrastat Reporting Base', - 'version': '8.0.1.2.0', + 'version': '8.0.1.3.0', 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat reporting', diff --git a/intrastat_base/views/account_tax.xml b/intrastat_base/views/account_tax.xml index 1e91bb5..d38cee6 100644 --- a/intrastat_base/views/account_tax.xml +++ b/intrastat_base/views/account_tax.xml @@ -16,8 +16,7 @@ - - + From e10548ed3d0c187ef226e0551db362ab3d30269b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 4 Oct 2016 00:41:33 +0200 Subject: [PATCH 15/39] [IMP] intrastat_base: Update README.rst + rename variables + restore code lost in transition to github/OCA/intrastat --- intrastat_base/README.rst | 44 ++--- intrastat_base/i18n/fr_FR.po | 182 -------------------- intrastat_base/security/ir.model.access.csv | 2 - intrastat_base/views/res_partner.xml | 11 +- 4 files changed, 28 insertions(+), 211 deletions(-) delete mode 100644 intrastat_base/i18n/fr_FR.po delete mode 100644 intrastat_base/security/ir.model.access.csv diff --git a/intrastat_base/README.rst b/intrastat_base/README.rst index 1a5cc85..284f240 100644 --- a/intrastat_base/README.rst +++ b/intrastat_base/README.rst @@ -2,14 +2,14 @@ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 +============== +Intrastat Base +============== -===================== -Intrastat Base Module -===================== - -This module contains common functions for the Intrastat reporting and -should be used in combination with country-specific reporting modules -such as: +This module contains common functions for the intrastat reporting and +should be used in combination with the generic reporting module +*intrastat_product* and with the country-specific reporting modules such +as: - *l10n_fr_intrastat_service*: the module for the *Déclaration Européenne des Services* (DES) for France @@ -31,25 +31,28 @@ you should uninstall it first before installing this module. Usage ===== -To create H.S. codes, go to the menu *Sales > Configuration > Product Categories and Attributes > H.S. Codes*. +This module adds an intrastat property on countries and activates this property +on the 28 countries of the European Union. -Then you will be able to set the H.S. code on an product (under the *Information* tab) or on a product category. On the product form, you will also be able to set the *Country of Origin* of a product (for example, if the product is *made in China*, select *China* as *Country of Origin*). +With this module, the country field on partners becomes a required field. + +It adds an option *Exclude invoice line from intrastat if this tax is present* +on taxes. + +It adds a tab *Intrastat* on the company form view. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/91/8.0 - Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here `_. - +Bugs are tracked on `GitHub Issues +`_. In case +of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and +welcomed feedback. Credits ======= @@ -62,9 +65,10 @@ Contributors Maintainer ---------- -.. image:: http://odoo-community.org/logo.png + +.. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :target: https://odoo-community.org This module is maintained by the OCA. @@ -72,4 +76,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/intrastat_base/i18n/fr_FR.po b/intrastat_base/i18n/fr_FR.po deleted file mode 100644 index 1b3d759..0000000 --- a/intrastat_base/i18n/fr_FR.po +++ /dev/null @@ -1,182 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * intrastat_base -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-05-27 18:43+0000\n" -"PO-Revision-Date: 2015-05-27 18:43+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: intrastat_base -#: help:product.template,is_accessory_cost:0 -msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." -msgstr "Activez cette option pour les frais de port, les frais d'emballage et tous les services liés à la vente de produits physiques. Cette option est utilisée pour la DEB et la DES." - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:165 -#, python-format -msgid "Cannot delete the declaration %s because it is in Done state" -msgstr "Impossible de supprimer la déclaration %s car elle est à l'état déclaré" - -#. module: intrastat_base -#: view:res.company:intrastat_base.view_company_form -msgid "Common Intrastat Settings" -msgstr "Paramètres communs DEB et DES" - -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_report_intrastat_common -msgid "Common functions for intrastat reports for products " -msgstr "" - -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_res_company -msgid "Companies" -msgstr "Sociétés" - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:68 -#, python-format -msgid "Company not yet set on intrastat report." -msgstr "Société non configurée sur le rapport intrastat." - -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_res_country -msgid "Country" -msgstr "Pays" - -#. module: intrastat_base -#: view:res.country:intrastat_base.view_country_search -#: field:res.country,intrastat:0 -msgid "EU Country" -msgstr "Pays UE" - -#. module: intrastat_base -#: field:product.template,exclude_from_intrastat:0 -msgid "Exclude from Intrastat reports" -msgstr "Exclure de la DEB et de la DES" - -#. module: intrastat_base -#: field:account.tax,exclude_from_intrastat_if_present:0 -msgid "Exclude invoice line from intrastat if this tax is present" -msgstr "Exclue la ligne de facture de la DEB/DES si cette taxe est présente" - -#. module: intrastat_base -#: field:report.intrastat.common,id:0 -msgid "ID" -msgstr "ID" - -#. module: intrastat_base -#: help:product.template,exclude_from_intrastat:0 -msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason." -msgstr "Si l'option est activée, le produit ou service ne sera pris en compte ni pour la DEB ni pour la DES. Cette option doit donc rester désactivée sauf si vous avez une très bonne raison." - -#. module: intrastat_base -#: help:account.tax,exclude_from_intrastat_if_present:0 -msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." -msgstr "Si cette taxe est présente sur une ligne de facture, cette ligne de facture ne sera pas prise en compte lors de la génération de la DEB et de la DES depuis les factures." - -#. module: intrastat_base -#: view:product.template:intrastat_base.product_template_form_view -msgid "Intrastat Properties" -msgstr "Propriétés DEB/DES" - -#. module: intrastat_base -#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root -msgid "Intrastat Reporting" -msgstr "DEB et DES" - -#. module: intrastat_base -#: view:res.company:intrastat_base.view_company_form -msgid "Intrastat Settings" -msgstr "Configuration DEB/DES" - -#. module: intrastat_base -#: field:product.template,is_accessory_cost:0 -msgid "Is accessory cost" -msgstr "Frais accessoires" - -#. module: intrastat_base -#: help:res.company,intrastat_remind_user_ids:0 -msgid "List of OpenERP users who will receive a notification to remind them about the Intrastat declaration." -msgstr "Liste d'utilisateurs OpenERP qui recevront le rappel pour la DEB et/ou la DES." - -#. module: intrastat_base -#: code:addons/intrastat_base/company.py:55 -#, python-format -msgid "Missing e-mail address on user '%s'." -msgstr "Adresse e-mail manquante sur l'utilisateur '%s'." - -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_product_template -msgid "Product Template" -msgstr "Modèle d'article" - -#. module: intrastat_base -#: view:res.country:intrastat_base.view_country_search -msgid "Search Countries" -msgstr "Recherche des pays" - -#. module: intrastat_base -#: help:res.country,intrastat:0 -msgid "Set to True for all European Union countries." -msgstr "A cocher pour tous les pays de l'Union Européenne." - -#. module: intrastat_base -#: model:product.template,name:intrastat_base.shipping_costs_exclude_product_template -msgid "Shipping costs" -msgstr "Frais de port" - -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_account_tax -msgid "Tax" -msgstr "Taxes" - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:84 -#, python-format -msgid "The VAT number is not set for the partner '%s'." -msgstr "Le numéro de TVA n'est pas renseigné pour le partenaire '%s'." - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:76 -#, python-format -msgid "The company currency must be 'EUR', but is currently '%s'." -msgstr "La monnaie de la société doit être 'EUR', mais est actuellement '%s'." - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:72 -#, python-format -msgid "The country is not set on the company '%s'." -msgstr "Le pays n'est pas renseigné sur la société '%s'." - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:105 -#, python-format -msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." -msgstr "La validation du fichier XML avec le schéma XML officiel a échoué. Le fichier XML généré et le détail de l'erreur ont été écrits dans les logs du serveur. Voici le message d'erreur, qui peut vous donner une idée de la cause du problème : %s." - -#. module: intrastat_base -#: code:addons/intrastat_base/product.py:51 -#, python-format -msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" -msgstr "L'option 'Frais accessoires' ne doit être activée que sur les produits de type 'Service'. Vous avez activé cette option sur le produit '%s' qui est de type '%s'" - -#. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:62 -#, python-format -msgid "The start date must be the first day of the month" -msgstr "La date de début doit être le premier jour du mois" - -#. module: intrastat_base -#: field:res.company,intrastat_remind_user_ids:0 -msgid "Users Receiving the Intrastat Reminder" -msgstr "Utilisateurs qui reçoivent le rappel DEB/DES" - diff --git a/intrastat_base/security/ir.model.access.csv b/intrastat_base/security/ir.model.access.csv deleted file mode 100644 index d7a2bf1..0000000 --- a/intrastat_base/security/ir.model.access.csv +++ /dev/null @@ -1,2 +0,0 @@ -"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_report_intrastat_common","Read access on report.intrastat.common","model_report_intrastat_common","base.group_user",1,0,0,0 diff --git a/intrastat_base/views/res_partner.xml b/intrastat_base/views/res_partner.xml index 7dc9f4e..6184e8c 100644 --- a/intrastat_base/views/res_partner.xml +++ b/intrastat_base/views/res_partner.xml @@ -9,21 +9,18 @@ - + res.partner - - {'readonly': [('use_parent_address','=',True)], 'required': True} + + 1 - - {'required': True} + 1 - From 35c04a5dedbee62cca000703eaf2f9a84d0ecd61 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 11 Oct 2016 14:59:28 +0200 Subject: [PATCH 16/39] [MIG] intrastat_base: Migration to v10 * Update README.rst: switch to new intrastat project * Move Intrastat menu entry to Accounting > Report instead of Accounting > Report > PDF Reports (because intrastat reports are not in PDF !) --- intrastat_base/README.rst | 4 +- intrastat_base/__manifest__.py | 28 +++ intrastat_base/__openerp__.py | 46 ----- intrastat_base/data/country_data.xml | 175 +++++++++--------- intrastat_base/demo/intrastat_demo.xml | 40 +--- intrastat_base/models/__init__.py | 1 + .../models/account_config_settings.py | 12 ++ intrastat_base/models/account_tax.py | 24 +-- intrastat_base/models/intrastat_common.py | 26 +-- intrastat_base/models/product_template.py | 26 +-- intrastat_base/models/res_company.py | 28 +-- intrastat_base/models/res_country.py | 24 +-- .../views/account_config_settings.xml | 23 +++ intrastat_base/views/account_tax.xml | 14 +- intrastat_base/views/intrastat.xml | 15 +- intrastat_base/views/product_template.xml | 16 +- intrastat_base/views/res_company.xml | 29 --- intrastat_base/views/res_country.xml | 12 +- intrastat_base/views/res_partner.xml | 13 +- 19 files changed, 206 insertions(+), 350 deletions(-) create mode 100644 intrastat_base/__manifest__.py delete mode 100644 intrastat_base/__openerp__.py create mode 100644 intrastat_base/models/account_config_settings.py create mode 100644 intrastat_base/views/account_config_settings.xml delete mode 100644 intrastat_base/views/res_company.xml diff --git a/intrastat_base/README.rst b/intrastat_base/README.rst index 284f240..65531ec 100644 --- a/intrastat_base/README.rst +++ b/intrastat_base/README.rst @@ -43,13 +43,13 @@ It adds a tab *Intrastat* on the company form view. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/91/8.0 + :target: https://runbot.odoo-community.org/runbot/227/10.0 Bug Tracker =========== Bugs are tracked on `GitHub Issues -`_. In case +`_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback. diff --git a/intrastat_base/__manifest__.py b/intrastat_base/__manifest__.py new file mode 100644 index 0000000..c30463a --- /dev/null +++ b/intrastat_base/__manifest__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# © 2011-2016 Akretion (http://www.akretion.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Intrastat Reporting Base', + 'version': '10.0.1.0.0', + 'category': 'Intrastat', + 'license': 'AGPL-3', + 'summary': 'Base module for Intrastat reporting', + 'author': 'Akretion,Odoo Community Association (OCA)', + 'website': 'http://www.akretion.com', + 'depends': ['base_vat'], + 'conflicts': ['report_intrastat'], + 'data': [ + 'data/country_data.xml', + 'views/product_template.xml', + 'views/res_partner.xml', + 'views/res_country.xml', + 'views/account_tax.xml', + 'views/account_config_settings.xml', + 'views/intrastat.xml', + ], + 'demo': [ + 'demo/intrastat_demo.xml', + ], + 'installable': True, +} diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py deleted file mode 100644 index 12a810b..0000000 --- a/intrastat_base/__openerp__.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Intrastat base module for Odoo -# Copyright (C) 2011-2015 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': 'Intrastat Reporting Base', - 'version': '8.0.1.3.0', - 'category': 'Intrastat', - 'license': 'AGPL-3', - 'summary': 'Base module for Intrastat reporting', - 'author': 'Akretion,Odoo Community Association (OCA)', - 'website': 'http://www.akretion.com', - 'depends': ['base_vat'], - 'conflicts': ['report_intrastat'], - 'data': [ - 'data/country_data.xml', - 'views/product_template.xml', - 'views/res_partner.xml', - 'views/res_country.xml', - 'views/account_tax.xml', - 'views/res_company.xml', - 'views/intrastat.xml', - ], - 'demo': [ - 'demo/intrastat_demo.xml', - ], - 'installable': True, -} diff --git a/intrastat_base/data/country_data.xml b/intrastat_base/data/country_data.xml index c77f548..3c75a3a 100644 --- a/intrastat_base/data/country_data.xml +++ b/intrastat_base/data/country_data.xml @@ -1,90 +1,89 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/intrastat_base/demo/intrastat_demo.xml b/intrastat_base/demo/intrastat_demo.xml index 422afa8..f53d397 100644 --- a/intrastat_base/demo/intrastat_demo.xml +++ b/intrastat_base/demo/intrastat_demo.xml @@ -1,57 +1,27 @@ - - - + FR58441019213 - - BE0828696437 - True - - - - BE0443167858 - True - - BE0884025633 True - - True - - - - True - - - - True - - - - True - - Shipping costs - SHIP + SHIP service 30 True - - + diff --git a/intrastat_base/models/__init__.py b/intrastat_base/models/__init__.py index a571f6a..fa36185 100644 --- a/intrastat_base/models/__init__.py +++ b/intrastat_base/models/__init__.py @@ -4,4 +4,5 @@ from . import res_country from . import product_template from . import account_tax from . import res_company +from . import account_config_settings from . import intrastat_common diff --git a/intrastat_base/models/account_config_settings.py b/intrastat_base/models/account_config_settings.py new file mode 100644 index 0000000..78a9fca --- /dev/null +++ b/intrastat_base/models/account_config_settings.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields + + +class AccountConfigSettings(models.TransientModel): + _inherit = 'account.config.settings' + + intrastat_remind_user_ids = fields.Many2many( + related='company_id.intrastat_remind_user_ids') diff --git a/intrastat_base/models/account_tax.py b/intrastat_base/models/account_tax.py index e11db59..f9997fc 100644 --- a/intrastat_base/models/account_tax.py +++ b/intrastat_base/models/account_tax.py @@ -1,26 +1,8 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Intrastat base module for Odoo -# Copyright (C) 2011-2014 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 . -# -############################################################################## +# © 2011-2016 Akretion (http://www.akretion.com). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields +from odoo import models, fields class AccountTax(models.Model): diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index ff49c96..de3b04b 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -1,27 +1,9 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Intrastat base module for Odoo -# Copyright (C) 2010-2014 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 . -# -############################################################################## +# © 2010-2016 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api, tools, _ -from openerp.exceptions import Warning as UserError +from odoo import models, fields, api, tools, _ +from odoo.exceptions import UserError import logging logger = logging.getLogger(__name__) diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index 07e0b2b..71cb987 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -1,27 +1,9 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Intrastat base module for Odoo -# Copyright (C) 2010-2014 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 . -# -############################################################################## +# © 2010-2016 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api, _ -from openerp.exceptions import ValidationError +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError class ProductTemplate(models.Model): diff --git a/intrastat_base/models/res_company.py b/intrastat_base/models/res_company.py index 291d846..5d4a4e7 100644 --- a/intrastat_base/models/res_company.py +++ b/intrastat_base/models/res_company.py @@ -1,27 +1,9 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Intrastat base module for Odoo -# Copyright (C) 2013-2014 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 . -# -############################################################################## +# © 2013-2017 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api, _ -from openerp.exceptions import ValidationError +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError class ResCompany(models.Model): @@ -30,7 +12,7 @@ class ResCompany(models.Model): intrastat_remind_user_ids = fields.Many2many( 'res.users', column1='company_id', column2='user_id', string="Users Receiving the Intrastat Reminder", - help="List of OpenERP users who will receive a notification to " + help="List of Odoo users who will receive a notification to " "remind them about the Intrastat declaration.") intrastat_email_list = fields.Char( compute='_compute_intrastat_email_list', diff --git a/intrastat_base/models/res_country.py b/intrastat_base/models/res_country.py index 8703f10..19f34f2 100644 --- a/intrastat_base/models/res_country.py +++ b/intrastat_base/models/res_country.py @@ -1,26 +1,8 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Intrastat base module for Odoo -# Copyright (C) 2011-2014 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 . -# -############################################################################## +# © 2011-2014 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields +from odoo import models, fields class ResCountry(models.Model): diff --git a/intrastat_base/views/account_config_settings.xml b/intrastat_base/views/account_config_settings.xml new file mode 100644 index 0000000..c890c40 --- /dev/null +++ b/intrastat_base/views/account_config_settings.xml @@ -0,0 +1,23 @@ + + + + + + + intrastat.account.config.settings.form + account.config.settings + + + + + + + + + + + + diff --git a/intrastat_base/views/account_tax.xml b/intrastat_base/views/account_tax.xml index d38cee6..a1e72cd 100644 --- a/intrastat_base/views/account_tax.xml +++ b/intrastat_base/views/account_tax.xml @@ -1,13 +1,10 @@ - - - + @@ -15,11 +12,10 @@ account.tax - + - - + diff --git a/intrastat_base/views/intrastat.xml b/intrastat_base/views/intrastat.xml index 73762d0..cc5a186 100644 --- a/intrastat_base/views/intrastat.xml +++ b/intrastat_base/views/intrastat.xml @@ -1,18 +1,16 @@ - - - + + parent="account.menu_finance_reports" sequence="50"/> @@ -32,5 +30,4 @@
-
- + diff --git a/intrastat_base/views/product_template.xml b/intrastat_base/views/product_template.xml index 1f4f73f..6440407 100644 --- a/intrastat_base/views/product_template.xml +++ b/intrastat_base/views/product_template.xml @@ -1,13 +1,11 @@ - - - + + intrastat.base.product.template.form @@ -16,6 +14,8 @@ + @@ -24,5 +24,5 @@ - - + + diff --git a/intrastat_base/views/res_company.xml b/intrastat_base/views/res_company.xml deleted file mode 100644 index 0565f00..0000000 --- a/intrastat_base/views/res_company.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - intrastat.company.form - res.company - - - - - - - - - - - - - - - diff --git a/intrastat_base/views/res_country.xml b/intrastat_base/views/res_country.xml index ac0f6f6..e9dec05 100644 --- a/intrastat_base/views/res_country.xml +++ b/intrastat_base/views/res_country.xml @@ -1,12 +1,11 @@ - - - + + @@ -46,5 +45,4 @@ - - + diff --git a/intrastat_base/views/res_partner.xml b/intrastat_base/views/res_partner.xml index 6184e8c..7a9dfeb 100644 --- a/intrastat_base/views/res_partner.xml +++ b/intrastat_base/views/res_partner.xml @@ -1,13 +1,11 @@ - - - + @@ -24,5 +22,4 @@
- - + From e419e9e3a80dc2ed1e1e894972a645a88344a3b0 Mon Sep 17 00:00:00 2001 From: Kumar Aberer Date: Fri, 9 Mar 2018 16:29:05 +0100 Subject: [PATCH 17/39] [MIG] intrastat_base: Migration to 11.0 --- intrastat_base/README.rst | 1 + intrastat_base/__manifest__.py | 9 +++--- intrastat_base/models/__init__.py | 2 +- intrastat_base/models/intrastat_common.py | 6 ++-- ...fig_settings.py => res_config_settings.py} | 5 ++-- .../views/account_config_settings.xml | 23 -------------- intrastat_base/views/res_config_settings.xml | 30 +++++++++++++++++++ 7 files changed, 43 insertions(+), 33 deletions(-) rename intrastat_base/models/{account_config_settings.py => res_config_settings.py} (65%) delete mode 100644 intrastat_base/views/account_config_settings.xml create mode 100644 intrastat_base/views/res_config_settings.xml diff --git a/intrastat_base/README.rst b/intrastat_base/README.rst index 65531ec..09a4328 100644 --- a/intrastat_base/README.rst +++ b/intrastat_base/README.rst @@ -62,6 +62,7 @@ Contributors * Alexis de Lattre, Akretion * Luc De Meyer, Noviat +* Kumar Aberer, brain-tec AG Maintainer ---------- diff --git a/intrastat_base/__manifest__.py b/intrastat_base/__manifest__.py index c30463a..ba5a0f1 100644 --- a/intrastat_base/__manifest__.py +++ b/intrastat_base/__manifest__.py @@ -1,16 +1,17 @@ # -*- coding: utf-8 -*- # © 2011-2016 Akretion (http://www.akretion.com) +# © 2018 brain-tec AG (Kumar Aberer ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Intrastat Reporting Base', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat reporting', - 'author': 'Akretion,Odoo Community Association (OCA)', + 'author': 'Akretion,Odoo Community Association (OCA), brain-tec AG', 'website': 'http://www.akretion.com', - 'depends': ['base_vat'], + 'depends': ['base_vat', 'account'], 'conflicts': ['report_intrastat'], 'data': [ 'data/country_data.xml', @@ -18,7 +19,7 @@ 'views/res_partner.xml', 'views/res_country.xml', 'views/account_tax.xml', - 'views/account_config_settings.xml', + 'views/res_config_settings.xml', 'views/intrastat.xml', ], 'demo': [ diff --git a/intrastat_base/models/__init__.py b/intrastat_base/models/__init__.py index fa36185..b659505 100644 --- a/intrastat_base/models/__init__.py +++ b/intrastat_base/models/__init__.py @@ -4,5 +4,5 @@ from . import res_country from . import product_template from . import account_tax from . import res_company -from . import account_config_settings +from . import res_config_settings from . import intrastat_common diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index de3b04b..9508d80 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -57,14 +57,14 @@ class IntrastatCommon(models.AbstractModel): def _check_xml_schema(self, xml_string, xsd_file): '''Validate the XML file against the XSD''' from lxml import etree - from StringIO import StringIO + from io import StringIO xsd_etree_obj = etree.parse( tools.file_open(xsd_file)) official_schema = etree.XMLSchema(xsd_etree_obj) try: t = etree.parse(StringIO(xml_string)) official_schema.assertValid(t) - except Exception, e: + except Exception as e: # if the validation of the XSD fails, we arrive here logger = logging.getLogger(__name__) logger.warning( @@ -115,7 +115,7 @@ class IntrastatCommon(models.AbstractModel): 'nodestroy': True, 'target': 'current', 'res_id': attach_id, - } + } return action @api.multi diff --git a/intrastat_base/models/account_config_settings.py b/intrastat_base/models/res_config_settings.py similarity index 65% rename from intrastat_base/models/account_config_settings.py rename to intrastat_base/models/res_config_settings.py index 78a9fca..3457b8a 100644 --- a/intrastat_base/models/account_config_settings.py +++ b/intrastat_base/models/res_config_settings.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- # © 2017 Akretion (Alexis de Lattre ) +# © 2018 brain-tec AG (Kumar Aberer ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import models, fields -class AccountConfigSettings(models.TransientModel): - _inherit = 'account.config.settings' +class ResConfigSettings(models.TransientModel): + _inherit = 'res.config.settings' intrastat_remind_user_ids = fields.Many2many( related='company_id.intrastat_remind_user_ids') diff --git a/intrastat_base/views/account_config_settings.xml b/intrastat_base/views/account_config_settings.xml deleted file mode 100644 index c890c40..0000000 --- a/intrastat_base/views/account_config_settings.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - intrastat.account.config.settings.form - account.config.settings - - - - - - - - - - - - diff --git a/intrastat_base/views/res_config_settings.xml b/intrastat_base/views/res_config_settings.xml new file mode 100644 index 0000000..cb9fd76 --- /dev/null +++ b/intrastat_base/views/res_config_settings.xml @@ -0,0 +1,30 @@ + + + + + + + intrastat.res.config.settings.form + res.config.settings + + + +

Intrastat

+
+
+
+
+
+
+
+
+
+ + +
From 5f9f95c17d77d0ef30885e11ba27a4a696243c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Fri, 27 Jul 2018 22:45:04 -0300 Subject: [PATCH 18/39] [IMP] *: removed utf-8 headers, changed icon and site * company model test, country model test as in v8 * png logo instead of svg, removed Python 2 utf-8 headers [UPD] squashed administrative commits --- intrastat_base/README.rst | 4 +- intrastat_base/__init__.py | 1 - intrastat_base/__manifest__.py | 5 +- intrastat_base/i18n/intrastat_base.pot | 148 ++++++++++++------- intrastat_base/models/__init__.py | 2 - intrastat_base/models/account_tax.py | 1 - intrastat_base/models/intrastat_common.py | 1 - intrastat_base/models/product_template.py | 1 - intrastat_base/models/res_company.py | 1 - intrastat_base/models/res_config_settings.py | 1 - intrastat_base/models/res_country.py | 1 - intrastat_base/tests/__init__.py | 1 + intrastat_base/tests/test_all.py | 22 +++ 13 files changed, 122 insertions(+), 67 deletions(-) create mode 100644 intrastat_base/tests/__init__.py create mode 100644 intrastat_base/tests/test_all.py diff --git a/intrastat_base/README.rst b/intrastat_base/README.rst index 09a4328..2dece29 100644 --- a/intrastat_base/README.rst +++ b/intrastat_base/README.rst @@ -1,4 +1,4 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 @@ -43,7 +43,7 @@ It adds a tab *Intrastat* on the company form view. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/227/10.0 + :target: https://runbot.odoo-community.org/runbot/227/11.0 Bug Tracker =========== diff --git a/intrastat_base/__init__.py b/intrastat_base/__init__.py index a0fdc10..0650744 100644 --- a/intrastat_base/__init__.py +++ b/intrastat_base/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import models diff --git a/intrastat_base/__manifest__.py b/intrastat_base/__manifest__.py index ba5a0f1..d584ab2 100644 --- a/intrastat_base/__manifest__.py +++ b/intrastat_base/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2011-2016 Akretion (http://www.akretion.com) # © 2018 brain-tec AG (Kumar Aberer ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -9,8 +8,8 @@ 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat reporting', - 'author': 'Akretion,Odoo Community Association (OCA), brain-tec AG', - 'website': 'http://www.akretion.com', + 'author': 'Akretion,Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/intrastat', 'depends': ['base_vat', 'account'], 'conflicts': ['report_intrastat'], 'data': [ diff --git a/intrastat_base/i18n/intrastat_base.pot b/intrastat_base/i18n/intrastat_base.pot index fdc6996..e9e9889 100644 --- a/intrastat_base/i18n/intrastat_base.pot +++ b/intrastat_base/i18n/intrastat_base.pot @@ -4,10 +4,8 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-05-27 18:43+0000\n" -"PO-Revision-Date: 2015-05-27 18:43+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,23 +14,19 @@ msgstr "" "Plural-Forms: \n" #. module: intrastat_base -#: help:product.template,is_accessory_cost:0 +#: model:ir.model.fields,help:intrastat_base.field_product_product_is_accessory_cost +#: model:ir.model.fields,help:intrastat_base.field_product_template_is_accessory_cost msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:165 +#: code:addons/intrastat_base/models/intrastat_common.py:154 #, python-format msgid "Cannot delete the declaration %s because it is in Done state" msgstr "" #. module: intrastat_base -#: view:res.company:intrastat_base.view_company_form -msgid "Common Intrastat Settings" -msgstr "" - -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_report_intrastat_common +#: model:ir.model,name:intrastat_base.model_intrastat_common msgid "Common functions for intrastat reports for products " msgstr "" @@ -42,7 +36,7 @@ msgid "Companies" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:68 +#: code:addons/intrastat_base/models/intrastat_common.py:33 #, python-format msgid "Company not yet set on intrastat report." msgstr "" @@ -53,83 +47,126 @@ msgid "Country" msgstr "" #. module: intrastat_base -#: view:res.country:intrastat_base.view_country_search -#: field:res.country,intrastat:0 +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_create_uid +msgid "Created by" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_create_date +msgid "Created on" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common_display_name +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_display_name +msgid "Display Name" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_res_country_intrastat +#: model:ir.ui.view,arch_db:intrastat_base.res_country_view_search msgid "EU Country" msgstr "" #. module: intrastat_base -#: field:product.template,exclude_from_intrastat:0 -msgid "Exclude from Intrastat reports" -msgstr "" - -#. module: intrastat_base -#: field:account.tax,exclude_from_intrastat_if_present:0 +#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_exclude_from_intrastat_if_present msgid "Exclude invoice line from intrastat if this tax is present" msgstr "" #. module: intrastat_base -#: field:report.intrastat.common,id:0 +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common_id +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_id msgid "ID" msgstr "" #. module: intrastat_base -#: help:product.template,exclude_from_intrastat:0 -msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason." -msgstr "" - -#. module: intrastat_base -#: help:account.tax,exclude_from_intrastat_if_present:0 +#: model:ir.model.fields,help:intrastat_base.field_account_tax_exclude_from_intrastat_if_present msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." msgstr "" #. module: intrastat_base -#: view:product.template:intrastat_base.product_template_form_view +#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root +#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_config_root +#: model:ir.ui.view,arch_db:intrastat_base.view_intrastat_res_config_settings +msgid "Intrastat" +msgstr "" + +#. module: intrastat_base +#: model:ir.ui.view,arch_db:intrastat_base.product_template_form_view msgid "Intrastat Properties" msgstr "" #. module: intrastat_base -#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root -msgid "Intrastat Reporting" +#: model:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form +msgid "Intrastat Result View" msgstr "" #. module: intrastat_base -#: view:res.company:intrastat_base.view_company_form -msgid "Intrastat Settings" -msgstr "" - -#. module: intrastat_base -#: field:product.template,is_accessory_cost:0 +#: model:ir.model.fields,field_description:intrastat_base.field_product_product_is_accessory_cost +#: model:ir.model.fields,field_description:intrastat_base.field_product_template_is_accessory_cost msgid "Is accessory cost" msgstr "" #. module: intrastat_base -#: help:res.company,intrastat_remind_user_ids:0 -msgid "List of OpenERP users who will receive a notification to remind them about the Intrastat declaration." +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common___last_update +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view___last_update +msgid "Last Modified on" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/company.py:55 +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_write_uid +msgid "Last Updated by" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_write_date +msgid "Last Updated on" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,help:intrastat_base.field_res_company_intrastat_remind_user_ids +#: model:ir.model.fields,help:intrastat_base.field_res_config_settings_intrastat_remind_user_ids +msgid "List of Odoo users who will receive a notification to remind them about the Intrastat declaration." +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_email_list +msgid "List of emails of Users Receiving the Intrastat Reminder" +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/models/res_company.py:38 #, python-format msgid "Missing e-mail address on user '%s'." msgstr "" +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_note +msgid "Notes" +msgstr "" + +#. module: intrastat_base +#: model:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form +msgid "Ok" +msgstr "" + #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_product_template msgid "Product Template" msgstr "" #. module: intrastat_base -#: view:res.country:intrastat_base.view_country_search +#: model:ir.ui.view,arch_db:intrastat_base.res_country_view_search msgid "Search Countries" msgstr "" #. module: intrastat_base -#: help:res.country,intrastat:0 +#: model:ir.model.fields,help:intrastat_base.field_res_country_intrastat msgid "Set to True for all European Union countries." msgstr "" #. module: intrastat_base +#: model:product.product,name:intrastat_base.shipping_costs_exclude #: model:product.template,name:intrastat_base.shipping_costs_exclude_product_template msgid "Shipping costs" msgstr "" @@ -140,43 +177,48 @@ msgid "Tax" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:84 +#: code:addons/intrastat_base/models/intrastat_common.py:51 #, python-format msgid "The VAT number is not set for the partner '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:76 +#: code:addons/intrastat_base/models/intrastat_common.py:41 #, python-format msgid "The company currency must be 'EUR', but is currently '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:72 +#: code:addons/intrastat_base/models/intrastat_common.py:37 #, python-format msgid "The country is not set on the company '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:105 +#: code:addons/intrastat_base/models/intrastat_common.py:74 #, python-format msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/product.py:51 +#: code:addons/intrastat_base/models/product_template.py:23 #, python-format msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/intrastat_common.py:62 -#, python-format -msgid "The start date must be the first day of the month" -msgstr "" - -#. module: intrastat_base -#: field:res.company,intrastat_remind_user_ids:0 +#: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_remind_user_ids +#: model:ir.model.fields,field_description:intrastat_base.field_res_config_settings_intrastat_remind_user_ids msgid "Users Receiving the Intrastat Reminder" msgstr "" +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_intrastat_result_view +msgid "intrastat.result.view" +msgstr "" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_config_settings +msgid "res.config.settings" +msgstr "" + diff --git a/intrastat_base/models/__init__.py b/intrastat_base/models/__init__.py index b659505..68e2955 100644 --- a/intrastat_base/models/__init__.py +++ b/intrastat_base/models/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from . import res_country from . import product_template from . import account_tax diff --git a/intrastat_base/models/account_tax.py b/intrastat_base/models/account_tax.py index f9997fc..2235255 100644 --- a/intrastat_base/models/account_tax.py +++ b/intrastat_base/models/account_tax.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2011-2016 Akretion (http://www.akretion.com). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index 9508d80..ba508de 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2010-2016 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index 71cb987..a0725f8 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2010-2016 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/intrastat_base/models/res_company.py b/intrastat_base/models/res_company.py index 5d4a4e7..4b110f0 100644 --- a/intrastat_base/models/res_company.py +++ b/intrastat_base/models/res_company.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2013-2017 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/intrastat_base/models/res_config_settings.py b/intrastat_base/models/res_config_settings.py index 3457b8a..4191666 100644 --- a/intrastat_base/models/res_config_settings.py +++ b/intrastat_base/models/res_config_settings.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2017 Akretion (Alexis de Lattre ) # © 2018 brain-tec AG (Kumar Aberer ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/intrastat_base/models/res_country.py b/intrastat_base/models/res_country.py index 19f34f2..9b4868c 100644 --- a/intrastat_base/models/res_country.py +++ b/intrastat_base/models/res_country.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2011-2014 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/intrastat_base/tests/__init__.py b/intrastat_base/tests/__init__.py new file mode 100644 index 0000000..7836283 --- /dev/null +++ b/intrastat_base/tests/__init__.py @@ -0,0 +1 @@ +from . import test_all diff --git a/intrastat_base/tests/test_all.py b/intrastat_base/tests/test_all.py new file mode 100644 index 0000000..fbc91ac --- /dev/null +++ b/intrastat_base/tests/test_all.py @@ -0,0 +1,22 @@ +from odoo.tests.common import TransactionCase + + +class TestIntrastatBase(TransactionCase): + """Tests for this module""" + + def test_10_countries(self): + # check if only EU countries have the 'intrastat' bit set + france = self.env.ref('base.fr') + self.assertTrue(france.intrastat) + brazil = self.env.ref('base.br') + self.assertFalse(brazil.intrastat) + + def test_20_company(self): + # add 'Demo user' to intrastat_remind_user_ids + demo_user = self.env.ref('base.user_demo') + demo_company = self.env.ref('base.main_company') + demo_company.write({ + 'intrastat_remind_user_ids': [(6, False, [demo_user.id])] + }) + # then check if intrastat_email_list contains the email of the user + self.assertEquals(demo_company.intrastat_email_list, demo_user.email) From d23520d42e29c2701e4159d033845b2300ee786d Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Thu, 16 Aug 2018 14:32:19 +0200 Subject: [PATCH 19/39] [10.0][FIX] intrastat_common - remove check on EUR EU countries are subject to Intrastat, also EU countries outside of the EU zone. As a consequence the check on company currency == EUR must be removed from this module (the right place are the localization modules). --- intrastat_base/models/intrastat_common.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index ba508de..45b9399 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -36,11 +36,6 @@ class IntrastatCommon(models.AbstractModel): raise UserError( _("The country is not set on the company '%s'.") % company.name) - if company.currency_id.name != 'EUR': - raise UserError( - _("The company currency must be 'EUR', but is currently " - "'%s'.") - % company.currency_id.name) return True @api.multi From d33c78f1fbb5cb06f5d74e4e5d0248d216ea81cb Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 6 Dec 2018 19:34:56 +0100 Subject: [PATCH 20/39] Add new module product_harmonized_system_delivery (hide native hs_code field) Finalize port to v11 --- intrastat_base/models/account_tax.py | 10 ++++++++ intrastat_base/models/intrastat_common.py | 27 ++++++++++---------- intrastat_base/views/account_tax.xml | 4 +-- intrastat_base/views/res_config_settings.xml | 8 ++++-- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/intrastat_base/models/account_tax.py b/intrastat_base/models/account_tax.py index 2235255..df81523 100644 --- a/intrastat_base/models/account_tax.py +++ b/intrastat_base/models/account_tax.py @@ -12,3 +12,13 @@ class AccountTax(models.Model): help="If this tax is present on an invoice line, this invoice " "line will be skipped when generating Intrastat Product or " "Service lines from invoices.") + + +class AccountTaxTemplate(models.Model): + _inherit = "account.tax.template" + + exclude_from_intrastat_if_present = fields.Boolean( + string='Exclude invoice line from intrastat if this tax is present', + help="If this tax is present on an invoice line, this invoice " + "line will be skipped when generating Intrastat Product or " + "Service lines from invoices.") diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index 45b9399..bc13e5f 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -3,6 +3,8 @@ from odoo import models, fields, api, tools, _ from odoo.exceptions import UserError +import base64 +from lxml import etree import logging logger = logging.getLogger(__name__) @@ -48,29 +50,29 @@ class IntrastatCommon(models.AbstractModel): return True @api.model - def _check_xml_schema(self, xml_string, xsd_file): + def _check_xml_schema(self, xml_etree, xsd_file): '''Validate the XML file against the XSD''' - from lxml import etree - from io import StringIO xsd_etree_obj = etree.parse( tools.file_open(xsd_file)) official_schema = etree.XMLSchema(xsd_etree_obj) try: - t = etree.parse(StringIO(xml_string)) - official_schema.assertValid(t) + official_schema.assertValid(xml_etree) except Exception as e: # if the validation of the XSD fails, we arrive here logger = logging.getLogger(__name__) logger.warning( "The XML file is invalid against the XML Schema Definition") + xml_string = etree.tostring( + xml_etree, pretty_print=True, encoding='UTF-8', + xml_declaration=True).decode() logger.warning(xml_string) logger.warning(e) - raise UserError( - _("The generated XML file is not valid against the official " - "XML Schema Definition. The generated XML file and the " - "full error have been written in the server logs. " - "Here is the error, which may give you an idea on the " - "cause of the problem : %s.") + raise UserError(_( + "The generated XML file is not valid against the official " + "XML Schema Definition. The generated XML file and the " + "full error have been written in the server logs. " + "Here is the error, which may give you an idea on the " + "cause of the problem : %s.") % str(e)) return True @@ -79,13 +81,12 @@ class IntrastatCommon(models.AbstractModel): '''Attach the XML file to the report_intrastat_product/service object''' self.ensure_one() - import base64 filename = '%s_%s.xml' % (self.year_month, declaration_name) attach = self.env['ir.attachment'].create({ 'name': filename, 'res_id': self.id, 'res_model': self._name, - 'datas': base64.encodestring(xml_string), + 'datas': base64.b64encode(xml_string), 'datas_fname': filename}) return attach.id diff --git a/intrastat_base/views/account_tax.xml b/intrastat_base/views/account_tax.xml index a1e72cd..7f77213 100644 --- a/intrastat_base/views/account_tax.xml +++ b/intrastat_base/views/account_tax.xml @@ -12,9 +12,9 @@ account.tax - + - + diff --git a/intrastat_base/views/res_config_settings.xml b/intrastat_base/views/res_config_settings.xml index cb9fd76..de45030 100644 --- a/intrastat_base/views/res_config_settings.xml +++ b/intrastat_base/views/res_config_settings.xml @@ -17,8 +17,12 @@
-
From 71ce0160364763d82f055a59eb955004a72d4218 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 10 Dec 2018 15:07:40 +0100 Subject: [PATCH 21/39] [FIX+IMP] intrastat_*: Several things: * Add readonly on some fields when state of declaration is done * Division by zero in computation of accessory costs * Add FR translation * Fix strings * Minor code updates --- intrastat_base/i18n/fr.po | 227 ++++++++++++++++++++++ intrastat_base/models/product_template.py | 11 +- 2 files changed, 232 insertions(+), 6 deletions(-) create mode 100644 intrastat_base/i18n/fr.po diff --git a/intrastat_base/i18n/fr.po b/intrastat_base/i18n/fr.po new file mode 100644 index 0000000..7cca1e3 --- /dev/null +++ b/intrastat_base/i18n/fr.po @@ -0,0 +1,227 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * intrastat_base +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-12-29 09:52+0000\n" +"PO-Revision-Date: 2018-12-29 09:52+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: intrastat_base +#: model:ir.model.fields,help:intrastat_base.field_product_product_is_accessory_cost +#: model:ir.model.fields,help:intrastat_base.field_product_template_is_accessory_cost +msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." +msgstr "Activer cette option pour les frais de port, les frais d'emballage et tous les services associés à la vente de produits. Cette option est utilisée pour la DEB et la DES." + +#. module: intrastat_base +#: code:addons/intrastat_base/models/intrastat_common.py:150 +#, python-format +msgid "Cannot delete the declaration %s because it is in Done state" +msgstr "Impossible de supprimer la déclaration %s parce qu'elle est à l'état 'Terminé'." + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_intrastat_common +msgid "Common functions for intrastat reports for products " +msgstr "Common functions for intrastat reports for products " + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: intrastat_base +#: code:addons/intrastat_base/models/intrastat_common.py:35 +#, python-format +msgid "Company not yet set on intrastat report." +msgstr "Société non configurée sur le rapport DEB/DES." + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_country +msgid "Country" +msgstr "Pays" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_create_date +msgid "Created on" +msgstr "Créé le" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common_display_name +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_display_name +msgid "Display Name" +msgstr "Afficher le nom" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_res_country_intrastat +#: model:ir.ui.view,arch_db:intrastat_base.res_country_view_search +msgid "EU Country" +msgstr "Membre de l'UE" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_exclude_from_intrastat_if_present +#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present +msgid "Exclude invoice line from intrastat if this tax is present" +msgstr "Ligne de facture exclue de la DEB et de la DES si cette taxe est présente" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common_id +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_id +msgid "ID" +msgstr "ID" + +#. module: intrastat_base +#: model:ir.model.fields,help:intrastat_base.field_account_tax_exclude_from_intrastat_if_present +#: model:ir.model.fields,help:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present +msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." +msgstr "Si cette taxe est présente sur une ligne de facture, cette ligne de facture sera sautée lors de la génération de la DEB et de la DES à partir des factures." + +#. module: intrastat_base +#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root +#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_config_root +#: model:ir.ui.view,arch_db:intrastat_base.view_intrastat_res_config_settings +msgid "Intrastat" +msgstr "DEB/DES" + +#. module: intrastat_base +#: model:ir.ui.view,arch_db:intrastat_base.product_template_form_view +msgid "Intrastat Properties" +msgstr "Propriétés DEB/DES" + +#. module: intrastat_base +#: model:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form +msgid "Intrastat Result View" +msgstr "Résultat DEB" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_product_product_is_accessory_cost +#: model:ir.model.fields,field_description:intrastat_base.field_product_template_is_accessory_cost +msgid "Is accessory cost" +msgstr "Est un frais accessoire" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common___last_update +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view___last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_write_uid +msgid "Last Updated by" +msgstr "Dernière modification par" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_write_date +msgid "Last Updated on" +msgstr "Dernière modification le" + +#. module: intrastat_base +#: model:ir.model.fields,help:intrastat_base.field_res_company_intrastat_remind_user_ids +#: model:ir.model.fields,help:intrastat_base.field_res_config_settings_intrastat_remind_user_ids +msgid "List of Odoo users who will receive a notification to remind them about the Intrastat declaration." +msgstr "Liste d'utilisateurs Odoo qui recevront un rappel pour la DEB/DES." + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_email_list +msgid "List of emails of Users Receiving the Intrastat Reminder" +msgstr "Liste des emails des utilisateurs qui reçoivent le rappel DEB/DES" + +#. module: intrastat_base +#: code:addons/intrastat_base/models/res_company.py:38 +#, python-format +msgid "Missing e-mail address on user '%s'." +msgstr "Adresse e-mail manquante pour l'utilisateur '%s'." + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_note +msgid "Notes" +msgstr "Notes" + +#. module: intrastat_base +#: model:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form +msgid "Ok" +msgstr "Ok" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: intrastat_base +#: model:ir.ui.view,arch_db:intrastat_base.res_country_view_search +msgid "Search Countries" +msgstr "Recherche pays" + +#. module: intrastat_base +#: model:ir.model.fields,help:intrastat_base.field_res_country_intrastat +msgid "Set to True for all European Union countries." +msgstr "Cocher la case pour tous les pays de l'Union Européenne." + +#. module: intrastat_base +#: model:product.product,name:intrastat_base.shipping_costs_exclude +#: model:product.template,name:intrastat_base.shipping_costs_exclude_product_template +msgid "Shipping costs" +msgstr "Frais de port" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_account_tax +msgid "Tax" +msgstr "Taxe" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_account_tax_template +msgid "Templates for Taxes" +msgstr "Modèles pour les taxes" + +#. module: intrastat_base +#: code:addons/intrastat_base/models/intrastat_common.py:48 +#, python-format +msgid "The VAT number is not set for the partner '%s'." +msgstr "Numéro de TVA non renseigné sur le partenaire '%s'." + +#. module: intrastat_base +#: code:addons/intrastat_base/models/intrastat_common.py:39 +#, python-format +msgid "The country is not set on the company '%s'." +msgstr "Pays non renseigné sur la société '%s'." + +#. module: intrastat_base +#: code:addons/intrastat_base/models/intrastat_common.py:70 +#, python-format +msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." +msgstr "Le fichier XML n'est pas valide au regard du schéma de définition XML. Le fichier XML généré et l'erreur complète ont été écrits dans les logs du serveur Odoo. Voici l'erreur, qui pourrait vous aiguiller sur la cause du problème : %s." + +#. module: intrastat_base +#: code:addons/intrastat_base/models/product_template.py:23 +#, python-format +msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" +msgstr "L'option 'Est un frais accessoire' ne doit être activée que sur des articles de service. Vous avez activé cette option pour l'article '%s' qui est de type '%s'" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_remind_user_ids +#: model:ir.model.fields,field_description:intrastat_base.field_res_config_settings_intrastat_remind_user_ids +msgid "Users Receiving the Intrastat Reminder" +msgstr "Utilisateurs qui reçoivent le rappel DEB/DES" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_intrastat_result_view +msgid "intrastat.result.view" +msgstr "intrastat.result.view" + +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_config_settings +msgid "res.config.settings" +msgstr "res.config.settings" + diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index a0725f8..0f714f0 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -19,9 +19,8 @@ class ProductTemplate(models.Model): def _check_accessory_cost(self): for this in self: if this.is_accessory_cost and this.type != 'service': - raise ValidationError( - _("The option 'Is accessory cost?' should only be " - "activated on 'Service' products. You have activated " - "this option for the product '%s' which is of type " - "'%s'") % - (this.name, this.type)) + raise ValidationError(_( + "The option 'Is accessory cost' should only be " + "activated on 'Service' products. You have activated " + "this option for the product '%s' which is of type " + "'%s'") % (this.name, this.type)) From ea11ddb9db181cf54b31dff96ebc06d4c1d5ab43 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Wed, 17 Apr 2019 20:48:49 +0200 Subject: [PATCH 22/39] [MIG] intrastat_product: Migration to 11.0 * Small fixes in intrastat_base * account_tax_template [UPD] Update intrastat_base.pot --- intrastat_base/__manifest__.py | 7 +-- intrastat_base/i18n/intrastat_base.pot | 33 +++++++------- intrastat_base/models/intrastat_common.py | 45 ++++++++++--------- intrastat_base/models/product_template.py | 15 ++++--- intrastat_base/models/res_company.py | 4 +- intrastat_base/models/res_config_settings.py | 6 +-- intrastat_base/models/res_country.py | 4 +- intrastat_base/static/description/icon.png | Bin 0 -> 9455 bytes intrastat_base/views/account_tax.xml | 4 +- intrastat_base/views/res_config_settings.xml | 13 +++--- 10 files changed, 67 insertions(+), 64 deletions(-) create mode 100644 intrastat_base/static/description/icon.png diff --git a/intrastat_base/__manifest__.py b/intrastat_base/__manifest__.py index d584ab2..b92710b 100644 --- a/intrastat_base/__manifest__.py +++ b/intrastat_base/__manifest__.py @@ -1,5 +1,6 @@ -# © 2011-2016 Akretion (http://www.akretion.com) -# © 2018 brain-tec AG (Kumar Aberer ) +# Copyright 2011-2016 Akretion (http://www.akretion.com) +# Copyright 2018 brain-tec AG (Kumar Aberer ) +# Copyright 2009-2019 Noviat (http://www.noviat.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { @@ -8,7 +9,7 @@ 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat reporting', - 'author': 'Akretion,Odoo Community Association (OCA)', + 'author': 'Akretion,Noviat,Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/intrastat', 'depends': ['base_vat', 'account'], 'conflicts': ['report_intrastat'], diff --git a/intrastat_base/i18n/intrastat_base.pot b/intrastat_base/i18n/intrastat_base.pot index e9e9889..315e3f2 100644 --- a/intrastat_base/i18n/intrastat_base.pot +++ b/intrastat_base/i18n/intrastat_base.pot @@ -20,7 +20,7 @@ msgid "Activate this option for shipping costs, packaging costs and all services msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:154 +#: code:addons/intrastat_base/models/intrastat_common.py:151 #, python-format msgid "Cannot delete the declaration %s because it is in Done state" msgstr "" @@ -36,7 +36,7 @@ msgid "Companies" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:33 +#: code:addons/intrastat_base/models/intrastat_common.py:39 #, python-format msgid "Company not yet set on intrastat report." msgstr "" @@ -70,6 +70,7 @@ msgstr "" #. module: intrastat_base #: model:ir.model.fields,field_description:intrastat_base.field_account_tax_exclude_from_intrastat_if_present +#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present msgid "Exclude invoice line from intrastat if this tax is present" msgstr "" @@ -81,6 +82,7 @@ msgstr "" #. module: intrastat_base #: model:ir.model.fields,help:intrastat_base.field_account_tax_exclude_from_intrastat_if_present +#: model:ir.model.fields,help:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." msgstr "" @@ -177,35 +179,34 @@ msgid "Tax" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:51 +#: model:ir.model,name:intrastat_base.model_account_tax_template +msgid "Templates for Taxes" +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/models/intrastat_common.py:52 #, python-format msgid "The VAT number is not set for the partner '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:41 -#, python-format -msgid "The company currency must be 'EUR', but is currently '%s'." -msgstr "" - -#. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:37 +#: code:addons/intrastat_base/models/intrastat_common.py:43 #, python-format msgid "The country is not set on the company '%s'." msgstr "" -#. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:74 -#, python-format -msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." -msgstr "" - #. module: intrastat_base #: code:addons/intrastat_base/models/product_template.py:23 #, python-format msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" msgstr "" +#. module: intrastat_base +#: code:addons/intrastat_base/models/intrastat_common.py:73 +#, python-format +msgid "Unknown Error" +msgstr "" + #. module: intrastat_base #: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_remind_user_ids #: model:ir.model.fields,field_description:intrastat_base.field_res_config_settings_intrastat_remind_user_ids diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index bc13e5f..048d5c5 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -1,12 +1,16 @@ -# © 2010-2016 Akretion (Alexis de Lattre ) +# Copyright 2010-2016 Akretion () +# Copyright 2009-2019 Noviat (http://www.noviat.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api, tools, _ -from odoo.exceptions import UserError -import base64 +from io import BytesIO from lxml import etree +from sys import exc_info +from traceback import format_exception import logging +from odoo import api, fields, models, tools, _ +from odoo.exceptions import UserError + logger = logging.getLogger(__name__) @@ -50,43 +54,40 @@ class IntrastatCommon(models.AbstractModel): return True @api.model - def _check_xml_schema(self, xml_etree, xsd_file): + def _check_xml_schema(self, xml_string, xsd_file): '''Validate the XML file against the XSD''' xsd_etree_obj = etree.parse( - tools.file_open(xsd_file)) + tools.file_open(xsd_file, mode='rb')) official_schema = etree.XMLSchema(xsd_etree_obj) try: - official_schema.assertValid(xml_etree) - except Exception as e: - # if the validation of the XSD fails, we arrive here - logger = logging.getLogger(__name__) + t = etree.parse(BytesIO(xml_string)) + official_schema.assertValid(t) + except (etree.XMLSchemaParseError, etree.DocumentInvalid) as e: logger.warning( "The XML file is invalid against the XML Schema Definition") - xml_string = etree.tostring( - xml_etree, pretty_print=True, encoding='UTF-8', - xml_declaration=True).decode() logger.warning(xml_string) logger.warning(e) - raise UserError(_( - "The generated XML file is not valid against the official " - "XML Schema Definition. The generated XML file and the " - "full error have been written in the server logs. " - "Here is the error, which may give you an idea on the " - "cause of the problem : %s.") - % str(e)) - return True + usererror = '%s\n\n%s' % (e.__class__.__name__, str(e)) + raise UserError(usererror) + except Exception: + error = _("Unknown Error") + tb = ''.join(format_exception(*exc_info())) + error += '\n%s' % tb + logger.warning(error) + raise UserError(error) @api.multi def _attach_xml_file(self, xml_string, declaration_name): '''Attach the XML file to the report_intrastat_product/service object''' self.ensure_one() + import base64 filename = '%s_%s.xml' % (self.year_month, declaration_name) attach = self.env['ir.attachment'].create({ 'name': filename, 'res_id': self.id, 'res_model': self._name, - 'datas': base64.b64encode(xml_string), + 'datas': base64.encodestring(xml_string), 'datas_fname': filename}) return attach.id diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index 0f714f0..bc3f6ca 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -1,7 +1,7 @@ -# © 2010-2016 Akretion (Alexis de Lattre ) +# Copyright 2010-2016 Akretion () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api, _ +from odoo import api, fields, models, _ from odoo.exceptions import ValidationError @@ -19,8 +19,9 @@ class ProductTemplate(models.Model): def _check_accessory_cost(self): for this in self: if this.is_accessory_cost and this.type != 'service': - raise ValidationError(_( - "The option 'Is accessory cost' should only be " - "activated on 'Service' products. You have activated " - "this option for the product '%s' which is of type " - "'%s'") % (this.name, this.type)) + raise ValidationError( + _("The option 'Is accessory cost?' should only be " + "activated on 'Service' products. You have activated " + "this option for the product '%s' which is of type " + "'%s'") % + (this.name, this.type)) diff --git a/intrastat_base/models/res_company.py b/intrastat_base/models/res_company.py index 4b110f0..f67bcf5 100644 --- a/intrastat_base/models/res_company.py +++ b/intrastat_base/models/res_company.py @@ -1,7 +1,7 @@ -# © 2013-2017 Akretion (Alexis de Lattre ) +# Copyright 2013-2017 Akretion () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api, _ +from odoo import api, fields, models, _ from odoo.exceptions import ValidationError diff --git a/intrastat_base/models/res_config_settings.py b/intrastat_base/models/res_config_settings.py index 4191666..14c62ec 100644 --- a/intrastat_base/models/res_config_settings.py +++ b/intrastat_base/models/res_config_settings.py @@ -1,8 +1,8 @@ -# © 2017 Akretion (Alexis de Lattre ) -# © 2018 brain-tec AG (Kumar Aberer ) +# Copyright 2017 Akretion (Alexis de Lattre ) +# Copyright 2018 brain-tec AG (Kumar Aberer ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models, fields +from odoo import fields, models class ResConfigSettings(models.TransientModel): diff --git a/intrastat_base/models/res_country.py b/intrastat_base/models/res_country.py index 9b4868c..3af71f0 100644 --- a/intrastat_base/models/res_country.py +++ b/intrastat_base/models/res_country.py @@ -1,7 +1,7 @@ -# © 2011-2014 Akretion (Alexis de Lattre ) +# Copyright 2011-2014 Akretion () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields +from odoo import fields, models class ResCountry(models.Model): diff --git a/intrastat_base/static/description/icon.png b/intrastat_base/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h zFfekr30S!-LHmV_Su-W+rEwYXJ^;6&3|L$mMC8*bQptyOo9;>Qb9Q9`ySe3%V$A*9 zeKEe+b0{#KWGp$F+tga)0RtI)nhMa-K@JS}2krK~n8vJ=Ngm?R!9G<~RyuU0d?nz# z-5EK$o(!F?hmX*2Yt6+coY`6jGbb7tF#6nHA zuKk=GGJ;ZwON1iAfG$E#Y7MnZVmrY|j0eVI(DN_MNFJmyZ|;w4tf@=CCDZ#5N_0K= z$;R~bbk?}TpfDjfB&aiQ$VA}s?P}xPERJG{kxk5~R`iRS(SK5d+Xs9swCozZISbnS zk!)I0>t=A<-^z(cmSFz3=jZ23u13X><0b)P)^1T_))Kr`e!-pb#q&J*Q`p+B6la%C zuVl&0duN<;uOsB3%T9Fp8t{ED108<+W(nOZd?gDnfNBC3>M8WE61$So|P zVvqH0SNtDTcsUdzaMDpT=Ty0pDHHNL@Z0w$Y`XO z2M-_r1S+GaH%pz#Uy0*w$Vdl=X=rQXEzO}d6J^R6zjM1u&c9vYLvLp?W7w(?np9x1 zE_0JSAJCPB%i7p*Wvg)pn5T`8k3-uR?*NT|J`eS#_#54p>!p(mLDvmc-3o0mX*mp_ zN*AeS<>#^-{S%W<*mz^!X$w_2dHWpcJ6^j64qFBft-o}o_Vx80o0>}Du;>kLts;$8 zC`7q$QI(dKYG`Wa8#wl@V4jVWBRGQ@1dr-hstpQL)Tl+aqVpGpbSfN>5i&QMXfiZ> zaA?T1VGe?rpQ@;+pkrVdd{klI&jVS@I5_iz!=UMpTsa~mBga?1r}aRBm1WS;TT*s0f0lY=JBl66Upy)-k4J}lh=P^8(SXk~0xW=T9v*B|gzIhN z>qsO7dFd~mgxAy4V?&)=5ieYq?zi?ZEoj)&2o)RLy=@hbCRcfT5jigwtQGE{L*8<@Yd{zg;CsL5mvzfDY}P-wos_6PfprFVaeqNE%h zKZhLtcQld;ZD+>=nqN~>GvROfueSzJD&BE*}XfU|H&(FssBqY=hPCt`d zH?@s2>I(|;fcW&YM6#V#!kUIP8$Nkdh0A(bEVj``-AAyYgwY~jB zT|I7Bf@%;7aL7Wf4dZ%VqF$eiaC38OV6oy3Z#TER2G+fOCd9Iaoy6aLYbPTN{XRPz z;U!V|vBf%H!}52L2gH_+j;`bTcQRXB+y9onc^wLm5wi3-Be}U>k_u>2Eg$=k!(l@I zcCg+flakT2Nej3i0yn+g+}%NYb?ta;R?(g5SnwsQ49U8Wng8d|{B+lyRcEDvR3+`O{zfmrmvFrL6acVP%yG98X zo&+VBg@px@i)%o?dG(`T;n*$S5*rnyiR#=wW}}GsAcfyQpE|>a{=$Hjg=-*_K;UtD z#z-)AXwSRY?OPefw^iI+ z)AXz#PfEjlwTes|_{sB?4(O@fg0AJ^g8gP}ex9Ucf*@_^J(s_5jJV}c)s$`Myn|Kd z$6>}#q^n{4vN@+Os$m7KV+`}c%4)4pv@06af4-x5#wj!KKb%caK{A&Y#Rfs z-po?Dcb1({W=6FKIUirH&(yg=*6aLCekcKwyfK^JN5{wcA3nhO(o}SK#!CINhI`-I z1)6&n7O&ZmyFMuNwvEic#IiOAwNkR=u5it{B9n2sAJV5pNhar=j5`*N!Na;c7g!l$ z3aYBqUkqqTJ=Re-;)s!EOeij=7SQZ3Hq}ZRds%IM*PtM$wV z@;rlc*NRK7i3y5BETSKuumEN`Xu_8GP1Ri=OKQ$@I^ko8>H6)4rjiG5{VBM>B|%`&&s^)jS|-_95&yc=GqjNo{zFkw%%HHhS~e=s zD#sfS+-?*t|J!+ozP6KvtOl!R)@@-z24}`9{QaVLD^9VCSR2b`b!KC#o;Ki<+wXB6 zx3&O0LOWcg4&rv4QG0)4yb}7BFSEg~=IR5#ZRj8kg}dS7_V&^%#Do==#`u zpy6{ox?jWuR(;pg+f@mT>#HGWHAJRRDDDv~@(IDw&R>9643kK#HN`!1vBJHnC+RM&yIh8{gG2q zA%e*U3|N0XSRa~oX-3EAneep)@{h2vvd3Xvy$7og(sayr@95+e6~Xvi1tUqnIxoIH zVWo*OwYElb#uyW{Imam6f2rGbjR!Y3`#gPqkv57dB6K^wRGxc9B(t|aYDGS=m$&S!NmCtrMMaUg(c zc2qC=2Z`EEFMW-me5B)24AqF*bV5Dr-M5ig(l-WPS%CgaPzs6p_gnCIvTJ=Y<6!gT zVt@AfYCzjjsMEGi=rDQHo0yc;HqoRNnNFeWZgcm?f;cp(6CNylj36DoL(?TS7eU#+ z7&mfr#y))+CJOXQKUMZ7QIdS9@#-}7y2K1{8)cCt0~-X0O!O?Qx#E4Og+;A2SjalQ zs7r?qn0H044=sDN$SRG$arw~n=+T_DNdSrarmu)V6@|?1-ZB#hRn`uilTGPJ@fqEy zGt(f0B+^JDP&f=r{#Y_wi#AVDf-y!RIXU^0jXsFpf>=Ji*TeqSY!H~AMbJdCGLhC) zn7Rx+sXw6uYj;WRYrLd^5IZq@6JI1C^YkgnedZEYy<&4(z%Q$5yv#Boo{AH8n$a zhb4Y3PWdr269&?V%uI$xMcUrMzl=;w<_nm*qr=c3Rl@i5wWB;e-`t7D&c-mcQl7x! zZWB`UGcw=Y2=}~wzrfLx=uet<;m3~=8I~ZRuzvMQUQdr+yTV|ATf1Uuomr__nDf=X zZ3WYJtHp_ri(}SQAPjv+Y+0=fH4krOP@S&=zZ-t1jW1o@}z;xk8 z(Nz1co&El^HK^NrhVHa-_;&88vTU>_J33=%{if;BEY*J#1n59=07jrGQ#IP>@u#3A z;!q+E1Rj3ZJ+!4bq9F8PXJ@yMgZL;>&gYA0%_Kbi8?S=XGM~dnQZQ!yBSgcZhY96H zrWnU;k)qy`rX&&xlDyA%(a1Hhi5CWkmg(`Gb%m(HKi-7Z!LKGRP_B8@`7&hdDy5n= z`OIxqxiVfX@OX1p(mQu>0Ai*v_cTMiw4qRt3~NBvr9oBy0)r>w3p~V0SCm=An6@3n)>@z!|o-$HvDK z|3D2ZMJkLE5loMKl6R^ez@Zz%S$&mbeoqH5`Bb){Ei21q&VP)hWS2tjShfFtGE+$z zzCR$P#uktu+#!w)cX!lWN1XU%K-r=s{|j?)Akf@q#3b#{6cZCuJ~gCxuMXRmI$nGtnH+-h z+GEi!*X=AP<|fG`1>MBdTb?28JYc=fGvAi2I<$B(rs$;eoJCyR6_bc~p!XR@O-+sD z=eH`-ye})I5ic1eL~TDmtfJ|8`0VJ*Yr=hNCd)G1p2MMz4C3^Mj?7;!w|Ly%JqmuW zlIEW^Ft%z?*|fpXda>Jr^1noFZEwFgVV%|*XhH@acv8rdGxeEX{M$(vG{Zw+x(ei@ zmfXb22}8-?Fi`vo-YVrTH*C?a8%M=Hv9MqVH7H^J$KsD?>!SFZ;ZsvnHr_gn=7acz z#W?0eCdVhVMWN12VV^$>WlQ?f;P^{(&pYTops|btm6aj>_Uz+hqpGwB)vWp0Cf5y< zft8-je~nn?W11plq}N)4A{l8I7$!ks_x$PXW-2XaRFswX_BnF{R#6YIwMhAgd5F9X zGmwdadS6(a^fjHtXg8=l?Rc0Sm%hk6E9!5cLVloEy4eh(=FwgP`)~I^5~pBEWo+F6 zSf2ncyMurJN91#cJTy_u8Y}@%!bq1RkGC~-bV@SXRd4F{R-*V`bS+6;W5vZ(&+I<9$;-V|eNfLa5n-6% z2(}&uGRF;p92eS*sE*oR$@pexaqr*meB)VhmIg@h{uzkk$9~qh#cHhw#>O%)b@+(| z^IQgqzuj~Sk(J;swEM-3TrJAPCq9k^^^`q{IItKBRXYe}e0Tdr=Huf7da3$l4PdpwWDop%^}n;dD#K4s#DYA8SHZ z&1!riV4W4R7R#C))JH1~axJ)RYnM$$lIR%6fIVA@zV{XVyx}C+a-Dt8Y9M)^KU0+H zR4IUb2CJ{Hg>CuaXtD50jB(_Tcx=Z$^WYu2u5kubqmwp%drJ6 z?Fo40g!Qd<-l=TQxqHEOuPX0;^z7iX?Ke^a%XT<13TA^5`4Xcw6D@Ur&VT&CUe0d} z1GjOVF1^L@>O)l@?bD~$wzgf(nxX1OGD8fEV?TdJcZc2KoUe|oP1#=$$7ee|xbY)A zDZq+cuTpc(fFdj^=!;{k03C69lMQ(|>uhRfRu%+!k&YOi-3|1QKB z z?n?eq1XP>p-IM$Z^C;2L3itnbJZAip*Zo0aw2bs8@(s^~*8T9go!%dHcAz2lM;`yp zD=7&xjFV$S&5uDaiScyD?B-i1ze`+CoRtz`Wn+Zl&#s4&}MO{@N!ufrzjG$B79)Y2d3tBk&)TxUTw@QS0TEL_?njX|@vq?Uz(nBFK5Pq7*xj#u*R&i|?7+6# z+|r_n#SW&LXhtheZdah{ZVoqwyT{D>MC3nkFF#N)xLi{p7J1jXlmVeb;cP5?e(=f# zuT7fvjSbjS781v?7{)-X3*?>tq?)Yd)~|1{BDS(pqC zC}~H#WXlkUW*H5CDOo<)#x7%RY)A;ShGhI5s*#cRDA8YgqG(HeKDx+#(ZQ?386dv! zlXCO)w91~Vw4AmOcATuV653fa9R$fyK8ul%rG z-wfS zihugoZyr38Im?Zuh6@RcF~t1anQu7>#lPpb#}4cOA!EM11`%f*07RqOVkmX{p~KJ9 z^zP;K#|)$`^Rb{rnHGH{~>1(fawV0*Z#)}M`m8-?ZJV<+e}s9wE# z)l&az?w^5{)`S(%MRzxdNqrs1n*-=jS^_jqE*5XDrA0+VE`5^*p3CuM<&dZEeCjoz zR;uu_H9ZPZV|fQq`Cyw4nscrVwi!fE6ciMmX$!_hN7uF;jjKG)d2@aC4ropY)8etW=xJvni)8eHi`H$%#zn^WJ5NLc-rqk|u&&4Z6fD_m&JfSI1Bvb?b<*n&sfl0^t z=HnmRl`XrFvMKB%9}>PaA`m-fK6a0(8=qPkWS5bb4=v?XcWi&hRY?O5HdulRi4?fN zlsJ*N-0Qw+Yic@s0(2uy%F@ib;GjXt01Fmx5XbRo6+n|pP(&nodMoap^z{~q ziEeaUT@Mxe3vJSfI6?uLND(CNr=#^W<1b}jzW58bIfyWTDle$mmS(|x-0|2UlX+9k zQ^EX7Nw}?EzVoBfT(-LT|=9N@^hcn-_p&sqG z&*oVs2JSU+N4ZD`FhCAWaS;>|wH2G*Id|?pa#@>tyxX`+4HyIArWDvVrX)2WAOQff z0qyHu&-S@i^MS-+j--!pr4fPBj~_8({~e1bfcl0wI1kaoN>mJL6KUPQm5N7lB(ui1 zE-o%kq)&djzWJ}ob<-GfDlkB;F31j-VHKvQUGQ3sp`CwyGJk_i!y^sD0fqC@$9|jO zOqN!r!8-p==F@ZVP=U$qSpY(gQ0)59P1&t@y?5rvg<}E+GB}26NYPp4f2YFQrQtot5mn3wu_qprZ=>Ig-$ zbW26Ws~IgY>}^5w`vTB(G`PTZaDiGBo5o(tp)qli|NeV( z@H_=R8V39rt5J5YB2Ky?4eJJ#b`_iBe2ot~6%7mLt5t8Vwi^Jy7|jWXqa3amOIoRb zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4 z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/intrastat_base/views/account_tax.xml b/intrastat_base/views/account_tax.xml index 7f77213..a1e72cd 100644 --- a/intrastat_base/views/account_tax.xml +++ b/intrastat_base/views/account_tax.xml @@ -12,9 +12,9 @@ account.tax - + - + diff --git a/intrastat_base/views/res_config_settings.xml b/intrastat_base/views/res_config_settings.xml index de45030..f472061 100644 --- a/intrastat_base/views/res_config_settings.xml +++ b/intrastat_base/views/res_config_settings.xml @@ -15,14 +15,13 @@

Intrastat

-
+
+
-
-
-
-
+
+
From 5172343d23e3bfa949c251e90547d1a04ebbe502 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Mon, 20 May 2019 20:40:35 +0000 Subject: [PATCH 23/39] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: intrastat-extrastat-11.0/intrastat-extrastat-11.0-intrastat_base Translate-URL: https://translation.odoo-community.org/projects/intrastat-extrastat-11-0/intrastat-extrastat-11-0-intrastat_base/ --- intrastat_base/i18n/fr.po | 72 ++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/intrastat_base/i18n/fr.po b/intrastat_base/i18n/fr.po index 7cca1e3..7c3aeda 100644 --- a/intrastat_base/i18n/fr.po +++ b/intrastat_base/i18n/fr.po @@ -1,6 +1,6 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * intrastat_base +# * intrastat_base # msgid "" msgstr "" @@ -10,6 +10,7 @@ msgstr "" "PO-Revision-Date: 2018-12-29 09:52+0000\n" "Last-Translator: <>\n" "Language-Team: \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" @@ -18,14 +19,21 @@ msgstr "" #. module: intrastat_base #: model:ir.model.fields,help:intrastat_base.field_product_product_is_accessory_cost #: model:ir.model.fields,help:intrastat_base.field_product_template_is_accessory_cost -msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." -msgstr "Activer cette option pour les frais de port, les frais d'emballage et tous les services associés à la vente de produits. Cette option est utilisée pour la DEB et la DES." +msgid "" +"Activate this option for shipping costs, packaging costs and all services " +"related to the sale of products. This option is used for Intrastat reports." +msgstr "" +"Activer cette option pour les frais de port, les frais d'emballage et tous " +"les services associés à la vente de produits. Cette option est utilisée pour " +"la DEB et la DES." #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:150 +#: code:addons/intrastat_base/models/intrastat_common.py:151 #, python-format msgid "Cannot delete the declaration %s because it is in Done state" -msgstr "Impossible de supprimer la déclaration %s parce qu'elle est à l'état 'Terminé'." +msgstr "" +"Impossible de supprimer la déclaration %s parce qu'elle est à l'état " +"'Terminé'." #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_intrastat_common @@ -38,7 +46,7 @@ msgid "Companies" msgstr "Sociétés" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:35 +#: code:addons/intrastat_base/models/intrastat_common.py:39 #, python-format msgid "Company not yet set on intrastat report." msgstr "Société non configurée sur le rapport DEB/DES." @@ -74,7 +82,8 @@ msgstr "Membre de l'UE" #: model:ir.model.fields,field_description:intrastat_base.field_account_tax_exclude_from_intrastat_if_present #: model:ir.model.fields,field_description:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present msgid "Exclude invoice line from intrastat if this tax is present" -msgstr "Ligne de facture exclue de la DEB et de la DES si cette taxe est présente" +msgstr "" +"Ligne de facture exclue de la DEB et de la DES si cette taxe est présente" #. module: intrastat_base #: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common_id @@ -85,8 +94,13 @@ msgstr "ID" #. module: intrastat_base #: model:ir.model.fields,help:intrastat_base.field_account_tax_exclude_from_intrastat_if_present #: model:ir.model.fields,help:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present -msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." -msgstr "Si cette taxe est présente sur une ligne de facture, cette ligne de facture sera sautée lors de la génération de la DEB et de la DES à partir des factures." +msgid "" +"If this tax is present on an invoice line, this invoice line will be skipped " +"when generating Intrastat Product or Service lines from invoices." +msgstr "" +"Si cette taxe est présente sur une ligne de facture, cette ligne de facture " +"sera sautée lors de la génération de la DEB et de la DES à partir des " +"factures." #. module: intrastat_base #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root @@ -130,7 +144,9 @@ msgstr "Dernière modification le" #. module: intrastat_base #: model:ir.model.fields,help:intrastat_base.field_res_company_intrastat_remind_user_ids #: model:ir.model.fields,help:intrastat_base.field_res_config_settings_intrastat_remind_user_ids -msgid "List of Odoo users who will receive a notification to remind them about the Intrastat declaration." +msgid "" +"List of Odoo users who will receive a notification to remind them about the " +"Intrastat declaration." msgstr "Liste d'utilisateurs Odoo qui recevront un rappel pour la DEB/DES." #. module: intrastat_base @@ -186,28 +202,34 @@ msgid "Templates for Taxes" msgstr "Modèles pour les taxes" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:48 +#: code:addons/intrastat_base/models/intrastat_common.py:52 #, python-format msgid "The VAT number is not set for the partner '%s'." msgstr "Numéro de TVA non renseigné sur le partenaire '%s'." #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:39 +#: code:addons/intrastat_base/models/intrastat_common.py:43 #, python-format msgid "The country is not set on the company '%s'." msgstr "Pays non renseigné sur la société '%s'." -#. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:70 -#, python-format -msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s." -msgstr "Le fichier XML n'est pas valide au regard du schéma de définition XML. Le fichier XML généré et l'erreur complète ont été écrits dans les logs du serveur Odoo. Voici l'erreur, qui pourrait vous aiguiller sur la cause du problème : %s." - #. module: intrastat_base #: code:addons/intrastat_base/models/product_template.py:23 #, python-format -msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" -msgstr "L'option 'Est un frais accessoire' ne doit être activée que sur des articles de service. Vous avez activé cette option pour l'article '%s' qui est de type '%s'" +msgid "" +"The option 'Is accessory cost?' should only be activated on 'Service' " +"products. You have activated this option for the product '%s' which is of " +"type '%s'" +msgstr "" +"L'option 'Est un frais accessoire' ne doit être activée que sur des articles " +"de service. Vous avez activé cette option pour l'article '%s' qui est de " +"type '%s'" + +#. module: intrastat_base +#: code:addons/intrastat_base/models/intrastat_common.py:73 +#, python-format +msgid "Unknown Error" +msgstr "" #. module: intrastat_base #: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_remind_user_ids @@ -225,3 +247,13 @@ msgstr "intrastat.result.view" msgid "res.config.settings" msgstr "res.config.settings" +#~ msgid "" +#~ "The generated XML file is not valid against the official XML Schema " +#~ "Definition. The generated XML file and the full error have been written " +#~ "in the server logs. Here is the error, which may give you an idea on the " +#~ "cause of the problem : %s." +#~ msgstr "" +#~ "Le fichier XML n'est pas valide au regard du schéma de définition XML. Le " +#~ "fichier XML généré et l'erreur complète ont été écrits dans les logs du " +#~ "serveur Odoo. Voici l'erreur, qui pourrait vous aiguiller sur la cause du " +#~ "problème : %s." From ca74737b471e44bd55c6b458f0337572288dffff Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 27 May 2019 19:45:06 +0200 Subject: [PATCH 24/39] Prepare v12 branch --- intrastat_base/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intrastat_base/__manifest__.py b/intrastat_base/__manifest__.py index b92710b..c372a09 100644 --- a/intrastat_base/__manifest__.py +++ b/intrastat_base/__manifest__.py @@ -25,5 +25,5 @@ 'demo': [ 'demo/intrastat_demo.xml', ], - 'installable': True, + 'installable': False, } From bf1c3be0c6f1a94c1259594a9d1ea7159692b023 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 28 May 2019 19:09:32 +0200 Subject: [PATCH 25/39] [MIG] Migrate all modules from v11 to v12 [UPD] Update intrastat_base.pot --- intrastat_base/__manifest__.py | 6 +- intrastat_base/demo/intrastat_demo.xml | 5 +- intrastat_base/i18n/intrastat_base.pot | 121 ++++++++++++------- intrastat_base/models/account_tax.py | 2 +- intrastat_base/models/intrastat_common.py | 11 +- intrastat_base/models/product_template.py | 1 - intrastat_base/models/res_company.py | 5 +- intrastat_base/models/res_config_settings.py | 2 +- intrastat_base/models/res_country.py | 3 +- intrastat_base/readme/CONTRIBUTORS.rst | 4 + intrastat_base/readme/DESCRIPTION.rst | 11 ++ intrastat_base/readme/INSTALL.rst | 5 + intrastat_base/readme/USAGE.rst | 9 ++ intrastat_base/views/account_tax.xml | 3 +- intrastat_base/views/intrastat.xml | 4 +- intrastat_base/views/product_template.xml | 3 +- intrastat_base/views/res_config_settings.xml | 7 +- intrastat_base/views/res_country.xml | 10 +- intrastat_base/views/res_partner.xml | 2 +- 19 files changed, 135 insertions(+), 79 deletions(-) create mode 100644 intrastat_base/readme/CONTRIBUTORS.rst create mode 100644 intrastat_base/readme/DESCRIPTION.rst create mode 100644 intrastat_base/readme/INSTALL.rst create mode 100644 intrastat_base/readme/USAGE.rst diff --git a/intrastat_base/__manifest__.py b/intrastat_base/__manifest__.py index c372a09..0113306 100644 --- a/intrastat_base/__manifest__.py +++ b/intrastat_base/__manifest__.py @@ -5,14 +5,14 @@ { 'name': 'Intrastat Reporting Base', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat reporting', 'author': 'Akretion,Noviat,Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/intrastat', 'depends': ['base_vat', 'account'], - 'conflicts': ['report_intrastat'], + 'excludes': ['account_intrastat'], 'data': [ 'data/country_data.xml', 'views/product_template.xml', @@ -25,5 +25,5 @@ 'demo': [ 'demo/intrastat_demo.xml', ], - 'installable': False, + 'installable': True, } diff --git a/intrastat_base/demo/intrastat_demo.xml b/intrastat_base/demo/intrastat_demo.xml index f53d397..181a244 100644 --- a/intrastat_base/demo/intrastat_demo.xml +++ b/intrastat_base/demo/intrastat_demo.xml @@ -1,6 +1,7 @@ @@ -10,7 +11,7 @@ FR58441019213 - + BE0884025633 True diff --git a/intrastat_base/i18n/intrastat_base.pot b/intrastat_base/i18n/intrastat_base.pot index 315e3f2..00e44dc 100644 --- a/intrastat_base/i18n/intrastat_base.pot +++ b/intrastat_base/i18n/intrastat_base.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 11.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" @@ -14,13 +14,13 @@ msgstr "" "Plural-Forms: \n" #. module: intrastat_base -#: model:ir.model.fields,help:intrastat_base.field_product_product_is_accessory_cost -#: model:ir.model.fields,help:intrastat_base.field_product_template_is_accessory_cost +#: model:ir.model.fields,help:intrastat_base.field_product_product__is_accessory_cost +#: model:ir.model.fields,help:intrastat_base.field_product_template__is_accessory_cost msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:151 +#: code:addons/intrastat_base/models/intrastat_common.py:143 #, python-format msgid "Cannot delete the declaration %s because it is in Done state" msgstr "" @@ -36,134 +36,159 @@ msgid "Companies" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:39 +#: code:addons/intrastat_base/models/intrastat_common.py:38 #, python-format msgid "Company not yet set on intrastat report." msgstr "" +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_config_settings +msgid "Config Settings" +msgstr "" + #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_res_country msgid "Country" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_create_uid +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__create_uid msgid "Created by" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_create_date +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__create_date msgid "Created on" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common_display_name -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_display_name +#: model_terms:ir.ui.view,arch_db:intrastat_base.res_country_view_search +msgid "Currency" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common__display_name +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__display_name msgid "Display Name" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_res_country_intrastat -#: model:ir.ui.view,arch_db:intrastat_base.res_country_view_search +#: model:ir.model.fields,field_description:intrastat_base.field_res_country__intrastat +#: model_terms:ir.ui.view,arch_db:intrastat_base.res_country_view_search msgid "EU Country" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_exclude_from_intrastat_if_present -#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present +#: model:ir.model.fields,field_description:intrastat_base.field_account_tax__exclude_from_intrastat_if_present +#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_template__exclude_from_intrastat_if_present msgid "Exclude invoice line from intrastat if this tax is present" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common_id -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_id +#: model_terms:ir.ui.view,arch_db:intrastat_base.res_country_view_search +msgid "Group By" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common__id +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__id msgid "ID" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,help:intrastat_base.field_account_tax_exclude_from_intrastat_if_present -#: model:ir.model.fields,help:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present +#: model:ir.model.fields,help:intrastat_base.field_account_tax__exclude_from_intrastat_if_present +#: model:ir.model.fields,help:intrastat_base.field_account_tax_template__exclude_from_intrastat_if_present msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." msgstr "" #. module: intrastat_base #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_config_root -#: model:ir.ui.view,arch_db:intrastat_base.view_intrastat_res_config_settings +#: model_terms:ir.ui.view,arch_db:intrastat_base.view_intrastat_res_config_settings msgid "Intrastat" msgstr "" #. module: intrastat_base -#: model:ir.ui.view,arch_db:intrastat_base.product_template_form_view +#: model_terms:ir.ui.view,arch_db:intrastat_base.product_template_form_view msgid "Intrastat Properties" msgstr "" #. module: intrastat_base -#: model:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form +#: model_terms:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form msgid "Intrastat Result View" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_product_product_is_accessory_cost -#: model:ir.model.fields,field_description:intrastat_base.field_product_template_is_accessory_cost +#: model:ir.model.fields,field_description:intrastat_base.field_product_product__is_accessory_cost +#: model:ir.model.fields,field_description:intrastat_base.field_product_template__is_accessory_cost msgid "Is accessory cost" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common___last_update -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view___last_update +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common____last_update +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view____last_update msgid "Last Modified on" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_write_uid +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__write_uid msgid "Last Updated by" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_write_date +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__write_date msgid "Last Updated on" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,help:intrastat_base.field_res_company_intrastat_remind_user_ids -#: model:ir.model.fields,help:intrastat_base.field_res_config_settings_intrastat_remind_user_ids +#: model:ir.model.fields,help:intrastat_base.field_res_company__intrastat_remind_user_ids +#: model:ir.model.fields,help:intrastat_base.field_res_config_settings__intrastat_remind_user_ids msgid "List of Odoo users who will receive a notification to remind them about the Intrastat declaration." msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_email_list +#: model:ir.model.fields,field_description:intrastat_base.field_res_company__intrastat_email_list msgid "List of emails of Users Receiving the Intrastat Reminder" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/res_company.py:38 +#: code:addons/intrastat_base/models/res_company.py:37 #, python-format msgid "Missing e-mail address on user '%s'." msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_note +#: model_terms:ir.ui.view,arch_db:intrastat_base.res_country_view_search +msgid "Name or Code" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__note msgid "Notes" msgstr "" #. module: intrastat_base -#: model:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form +#: model_terms:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form msgid "Ok" msgstr "" +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_intrastat_result_view +msgid "Pop-up to show errors on intrastat report generation" +msgstr "" + #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_product_template msgid "Product Template" msgstr "" #. module: intrastat_base -#: model:ir.ui.view,arch_db:intrastat_base.res_country_view_search +#: model_terms:ir.ui.view,arch_db:intrastat_base.res_country_view_search msgid "Search Countries" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,help:intrastat_base.field_res_country_intrastat +#: model:ir.model.fields,help:intrastat_base.field_res_country__intrastat msgid "Set to True for all European Union countries." msgstr "" @@ -184,42 +209,44 @@ msgid "Templates for Taxes" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:52 +#: code:addons/intrastat_base/models/intrastat_common.py:50 #, python-format msgid "The VAT number is not set for the partner '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:43 +#: code:addons/intrastat_base/models/intrastat_common.py:42 #, python-format msgid "The country is not set on the company '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/product_template.py:23 +#: code:addons/intrastat_base/models/product_template.py:22 #, python-format msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:73 +#: model:product.product,uom_name:intrastat_base.shipping_costs_exclude +#: model:product.template,uom_name:intrastat_base.shipping_costs_exclude_product_template +msgid "Unit(s)" +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/models/intrastat_common.py:71 #, python-format msgid "Unknown Error" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_remind_user_ids -#: model:ir.model.fields,field_description:intrastat_base.field_res_config_settings_intrastat_remind_user_ids +#: model:ir.model.fields,field_description:intrastat_base.field_res_company__intrastat_remind_user_ids +#: model:ir.model.fields,field_description:intrastat_base.field_res_config_settings__intrastat_remind_user_ids msgid "Users Receiving the Intrastat Reminder" msgstr "" #. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_intrastat_result_view -msgid "intrastat.result.view" -msgstr "" - -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_res_config_settings -msgid "res.config.settings" +#: model:product.product,weight_uom_name:intrastat_base.shipping_costs_exclude +#: model:product.template,weight_uom_name:intrastat_base.shipping_costs_exclude_product_template +msgid "kg" msgstr "" diff --git a/intrastat_base/models/account_tax.py b/intrastat_base/models/account_tax.py index df81523..79f5c72 100644 --- a/intrastat_base/models/account_tax.py +++ b/intrastat_base/models/account_tax.py @@ -1,4 +1,4 @@ -# © 2011-2016 Akretion (http://www.akretion.com). +# Copyright 2011-2019 Akretion France (http://www.akretion.com). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models, fields diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index 048d5c5..1b9e36a 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -5,6 +5,7 @@ from io import BytesIO from lxml import etree from sys import exc_info +import base64 from traceback import format_exception import logging @@ -19,7 +20,6 @@ class IntrastatCommon(models.AbstractModel): _description = "Common functions for intrastat reports for products " "and services" - @api.multi @api.depends('declaration_line_ids.amount_company_currency') def _compute_numbers(self): for this in self: @@ -31,7 +31,6 @@ class IntrastatCommon(models.AbstractModel): this.num_decl_lines = num_lines this.total_amount = total_amount - @api.multi def _check_generate_lines(self): """Check wether all requirements are met for generating lines.""" for this in self: @@ -44,7 +43,6 @@ class IntrastatCommon(models.AbstractModel): % company.name) return True - @api.multi def _check_generate_xml(self): for this in self: if not this.company_id.partner_id.vat: @@ -76,12 +74,10 @@ class IntrastatCommon(models.AbstractModel): logger.warning(error) raise UserError(error) - @api.multi def _attach_xml_file(self, xml_string, declaration_name): '''Attach the XML file to the report_intrastat_product/service object''' self.ensure_one() - import base64 filename = '%s_%s.xml' % (self.year_month, declaration_name) attach = self.env['ir.attachment'].create({ 'name': filename, @@ -91,7 +87,6 @@ class IntrastatCommon(models.AbstractModel): 'datas_fname': filename}) return attach.id - @api.multi def _unlink_attachments(self): atts = self.env['ir.attachment'].search( [('res_model', '=', self._name), @@ -114,7 +109,6 @@ class IntrastatCommon(models.AbstractModel): } return action - @api.multi def _generate_xml(self): """ Inherit this method in the localization module @@ -128,7 +122,6 @@ class IntrastatCommon(models.AbstractModel): """ return False - @api.multi def send_reminder_email(self, mail_template_xmlid): mail_template = self.env.ref(mail_template_xmlid) for this in self: @@ -143,7 +136,6 @@ class IntrastatCommon(models.AbstractModel): 'empty on company %s' % this.company_id.name) return True - @api.multi def unlink(self): for intrastat in self: if intrastat.state == 'done': @@ -158,6 +150,7 @@ class IntrastatResultView(models.TransientModel): Transient Model to display Intrastat Report results """ _name = 'intrastat.result.view' + _description = 'Pop-up to show errors on intrastat report generation' note = fields.Text( string='Notes', readonly=True, diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index bc3f6ca..804aa59 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -14,7 +14,6 @@ class ProductTemplate(models.Model): "costs and all services related to the sale of products. " "This option is used for Intrastat reports.") - @api.multi @api.constrains('type', 'is_accessory_cost') def _check_accessory_cost(self): for this in self: diff --git a/intrastat_base/models/res_company.py b/intrastat_base/models/res_company.py index f67bcf5..05c3d15 100644 --- a/intrastat_base/models/res_company.py +++ b/intrastat_base/models/res_company.py @@ -1,4 +1,5 @@ -# Copyright 2013-2017 Akretion () +# Copyright 2013-2017 Akretion France (http://www.akretion.com/) +# @author: # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, fields, models, _ @@ -17,7 +18,6 @@ class ResCompany(models.Model): compute='_compute_intrastat_email_list', string='List of emails of Users Receiving the Intrastat Reminder') - @api.multi @api.depends( 'intrastat_remind_user_ids', 'intrastat_remind_user_ids.email') def _compute_intrastat_email_list(self): @@ -28,7 +28,6 @@ class ResCompany(models.Model): emails.append(user.email) this.intrastat_email_list = ','.join(emails) - @api.multi @api.constrains('intrastat_remind_user_ids') def _check_intrastat_remind_users(self): for this in self: diff --git a/intrastat_base/models/res_config_settings.py b/intrastat_base/models/res_config_settings.py index 14c62ec..51bec6c 100644 --- a/intrastat_base/models/res_config_settings.py +++ b/intrastat_base/models/res_config_settings.py @@ -9,4 +9,4 @@ class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' intrastat_remind_user_ids = fields.Many2many( - related='company_id.intrastat_remind_user_ids') + related='company_id.intrastat_remind_user_ids', readonly=False) diff --git a/intrastat_base/models/res_country.py b/intrastat_base/models/res_country.py index 3af71f0..74f0685 100644 --- a/intrastat_base/models/res_country.py +++ b/intrastat_base/models/res_country.py @@ -1,4 +1,5 @@ -# Copyright 2011-2014 Akretion () +# Copyright 2011-2019 Akretion France (http://www.akretion.com/) +# @author: # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import fields, models diff --git a/intrastat_base/readme/CONTRIBUTORS.rst b/intrastat_base/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..6a9e1c1 --- /dev/null +++ b/intrastat_base/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Alexis de Lattre, Akretion +* Luc De Meyer, Noviat +* Kumar Aberer, brain-tec AG +* Andrea Stirpe diff --git a/intrastat_base/readme/DESCRIPTION.rst b/intrastat_base/readme/DESCRIPTION.rst new file mode 100644 index 0000000..179c7eb --- /dev/null +++ b/intrastat_base/readme/DESCRIPTION.rst @@ -0,0 +1,11 @@ +This module contains common functions for the intrastat reporting and +should be used in combination with the generic reporting module +*intrastat_product* and with the country-specific reporting modules such +as: + +- *l10n_fr_intrastat_service*: + the module for the *Déclaration Européenne des Services* (DES) for France +- *l10n_fr_intrastat_product*: + the module for the *Déclaration d'Echange de Biens* (DEB) for France +- *l10n_be_intrastat_product*: + the module for the Intrastat Declaration for Belgium. diff --git a/intrastat_base/readme/INSTALL.rst b/intrastat_base/readme/INSTALL.rst new file mode 100644 index 0000000..2f4f69f --- /dev/null +++ b/intrastat_base/readme/INSTALL.rst @@ -0,0 +1,5 @@ +WARNING: + +This module conflicts with the module *account_intrastat* from Odoo Enterprise. +If you have already installed the module *account_intrastat*, +you should uninstall it first before installing this module. diff --git a/intrastat_base/readme/USAGE.rst b/intrastat_base/readme/USAGE.rst new file mode 100644 index 0000000..32dbe07 --- /dev/null +++ b/intrastat_base/readme/USAGE.rst @@ -0,0 +1,9 @@ +This module adds an intrastat property on countries and activates this property +on the countries of the European Union. + +With this module, the country field on partners becomes a required field. + +It adds an option *Exclude invoice line from intrastat if this tax is present* +on taxes. + +It adds an *Intrastat* section on the *Invoicing* configuration page. diff --git a/intrastat_base/views/account_tax.xml b/intrastat_base/views/account_tax.xml index a1e72cd..222f71b 100644 --- a/intrastat_base/views/account_tax.xml +++ b/intrastat_base/views/account_tax.xml @@ -1,6 +1,7 @@ diff --git a/intrastat_base/views/intrastat.xml b/intrastat_base/views/intrastat.xml index cc5a186..3381e0c 100644 --- a/intrastat_base/views/intrastat.xml +++ b/intrastat_base/views/intrastat.xml @@ -1,7 +1,7 @@ diff --git a/intrastat_base/views/product_template.xml b/intrastat_base/views/product_template.xml index 6440407..fff74e1 100644 --- a/intrastat_base/views/product_template.xml +++ b/intrastat_base/views/product_template.xml @@ -1,6 +1,7 @@ diff --git a/intrastat_base/views/res_config_settings.xml b/intrastat_base/views/res_config_settings.xml index f472061..ec5ea7d 100644 --- a/intrastat_base/views/res_config_settings.xml +++ b/intrastat_base/views/res_config_settings.xml @@ -1,7 +1,8 @@ @@ -21,7 +22,7 @@
+
diff --git a/intrastat_base/views/res_country.xml b/intrastat_base/views/res_country.xml index e9dec05..3ecc2fd 100644 --- a/intrastat_base/views/res_country.xml +++ b/intrastat_base/views/res_country.xml @@ -1,6 +1,6 @@ @@ -36,10 +36,14 @@ res.country - + + + domain="[('intrastat', '=', True)]" /> + + + diff --git a/intrastat_base/views/res_partner.xml b/intrastat_base/views/res_partner.xml index 7a9dfeb..5f31add 100644 --- a/intrastat_base/views/res_partner.xml +++ b/intrastat_base/views/res_partner.xml @@ -1,6 +1,6 @@ From 6a6bdb8fea3d0257b326720ec31615f9a97d997b Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sun, 16 Jun 2019 11:04:22 +0000 Subject: [PATCH 26/39] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: intrastat-extrastat-12.0/intrastat-extrastat-12.0-intrastat_base Translate-URL: https://translation.odoo-community.org/projects/intrastat-extrastat-12-0/intrastat-extrastat-12-0-intrastat_base/ [UPD] README.rst [UPD] README.rst --- intrastat_base/README.rst | 79 +++- intrastat_base/i18n/fr.po | 124 +++-- intrastat_base/static/description/index.html | 452 +++++++++++++++++++ 3 files changed, 584 insertions(+), 71 deletions(-) create mode 100644 intrastat_base/static/description/index.html diff --git a/intrastat_base/README.rst b/intrastat_base/README.rst index 2dece29..777cf4d 100644 --- a/intrastat_base/README.rst +++ b/intrastat_base/README.rst @@ -1,10 +1,29 @@ -.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 +======================== +Intrastat Reporting Base +======================== -============== -Intrastat Base -============== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fintrastat--extrastat-lightgray.png?logo=github + :target: https://github.com/OCA/intrastat-extrastat/tree/12.0/intrastat_base + :alt: OCA/intrastat-extrastat +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/intrastat-extrastat-12-0/intrastat-extrastat-12-0-intrastat_base + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/227/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| This module contains common functions for the intrastat reporting and should be used in combination with the generic reporting module @@ -18,63 +37,73 @@ as: - *l10n_be_intrastat_product*: the module for the Intrastat Declaration for Belgium. +**Table of contents** + +.. contents:: + :local: Installation ============ WARNING: -This module conflicts with the module *report_intrastat* from the official addons. -If you have already installed the module *report_intrastat*, +This module conflicts with the module *account_intrastat* from Odoo Enterprise. +If you have already installed the module *account_intrastat*, you should uninstall it first before installing this module. Usage ===== This module adds an intrastat property on countries and activates this property -on the 28 countries of the European Union. +on the countries of the European Union. With this module, the country field on partners becomes a required field. It adds an option *Exclude invoice line from intrastat if this tax is present* on taxes. -It adds a tab *Intrastat* on the company form view. - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/227/11.0 +It adds an *Intrastat* section on the *Invoicing* configuration page. Bug Tracker =========== -Bugs are tracked on `GitHub Issues -`_. In case -of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and -welcomed feedback. +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Akretion +* Noviat + Contributors ------------- +~~~~~~~~~~~~ * Alexis de Lattre, Akretion * Luc De Meyer, Noviat * Kumar Aberer, brain-tec AG +* Andrea Stirpe -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/intrastat-extrastat `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/intrastat_base/i18n/fr.po b/intrastat_base/i18n/fr.po index 7c3aeda..2f074a6 100644 --- a/intrastat_base/i18n/fr.po +++ b/intrastat_base/i18n/fr.po @@ -17,8 +17,8 @@ msgstr "" "Plural-Forms: \n" #. module: intrastat_base -#: model:ir.model.fields,help:intrastat_base.field_product_product_is_accessory_cost -#: model:ir.model.fields,help:intrastat_base.field_product_template_is_accessory_cost +#: model:ir.model.fields,help:intrastat_base.field_product_product__is_accessory_cost +#: model:ir.model.fields,help:intrastat_base.field_product_template__is_accessory_cost msgid "" "Activate this option for shipping costs, packaging costs and all services " "related to the sale of products. This option is used for Intrastat reports." @@ -28,7 +28,7 @@ msgstr "" "la DEB et la DES." #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:151 +#: code:addons/intrastat_base/models/intrastat_common.py:143 #, python-format msgid "Cannot delete the declaration %s because it is in Done state" msgstr "" @@ -46,54 +46,71 @@ msgid "Companies" msgstr "Sociétés" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:39 +#: code:addons/intrastat_base/models/intrastat_common.py:38 #, python-format msgid "Company not yet set on intrastat report." msgstr "Société non configurée sur le rapport DEB/DES." +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_res_config_settings +#, fuzzy +#| msgid "res.config.settings" +msgid "Config Settings" +msgstr "res.config.settings" + #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_res_country msgid "Country" msgstr "Pays" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_create_uid +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__create_uid msgid "Created by" msgstr "Créé par" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_create_date +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__create_date msgid "Created on" msgstr "Créé le" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common_display_name -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_display_name +#: model_terms:ir.ui.view,arch_db:intrastat_base.res_country_view_search +msgid "Currency" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common__display_name +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__display_name msgid "Display Name" msgstr "Afficher le nom" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_res_country_intrastat -#: model:ir.ui.view,arch_db:intrastat_base.res_country_view_search +#: model:ir.model.fields,field_description:intrastat_base.field_res_country__intrastat +#: model_terms:ir.ui.view,arch_db:intrastat_base.res_country_view_search msgid "EU Country" msgstr "Membre de l'UE" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_exclude_from_intrastat_if_present -#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present +#: model:ir.model.fields,field_description:intrastat_base.field_account_tax__exclude_from_intrastat_if_present +#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_template__exclude_from_intrastat_if_present msgid "Exclude invoice line from intrastat if this tax is present" msgstr "" "Ligne de facture exclue de la DEB et de la DES si cette taxe est présente" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common_id -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_id +#: model_terms:ir.ui.view,arch_db:intrastat_base.res_country_view_search +msgid "Group By" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common__id +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__id msgid "ID" msgstr "ID" #. module: intrastat_base -#: model:ir.model.fields,help:intrastat_base.field_account_tax_exclude_from_intrastat_if_present -#: model:ir.model.fields,help:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present +#: model:ir.model.fields,help:intrastat_base.field_account_tax__exclude_from_intrastat_if_present +#: model:ir.model.fields,help:intrastat_base.field_account_tax_template__exclude_from_intrastat_if_present msgid "" "If this tax is present on an invoice line, this invoice line will be skipped " "when generating Intrastat Product or Service lines from invoices." @@ -105,83 +122,93 @@ msgstr "" #. module: intrastat_base #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_config_root -#: model:ir.ui.view,arch_db:intrastat_base.view_intrastat_res_config_settings +#: model_terms:ir.ui.view,arch_db:intrastat_base.view_intrastat_res_config_settings msgid "Intrastat" msgstr "DEB/DES" #. module: intrastat_base -#: model:ir.ui.view,arch_db:intrastat_base.product_template_form_view +#: model_terms:ir.ui.view,arch_db:intrastat_base.product_template_form_view msgid "Intrastat Properties" msgstr "Propriétés DEB/DES" #. module: intrastat_base -#: model:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form +#: model_terms:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form msgid "Intrastat Result View" msgstr "Résultat DEB" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_product_product_is_accessory_cost -#: model:ir.model.fields,field_description:intrastat_base.field_product_template_is_accessory_cost +#: model:ir.model.fields,field_description:intrastat_base.field_product_product__is_accessory_cost +#: model:ir.model.fields,field_description:intrastat_base.field_product_template__is_accessory_cost msgid "Is accessory cost" msgstr "Est un frais accessoire" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common___last_update -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view___last_update +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_common____last_update +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view____last_update msgid "Last Modified on" msgstr "Dernière modification le" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_write_uid +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__write_uid msgid "Last Updated by" msgstr "Dernière modification par" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_write_date +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__write_date msgid "Last Updated on" msgstr "Dernière modification le" #. module: intrastat_base -#: model:ir.model.fields,help:intrastat_base.field_res_company_intrastat_remind_user_ids -#: model:ir.model.fields,help:intrastat_base.field_res_config_settings_intrastat_remind_user_ids +#: model:ir.model.fields,help:intrastat_base.field_res_company__intrastat_remind_user_ids +#: model:ir.model.fields,help:intrastat_base.field_res_config_settings__intrastat_remind_user_ids msgid "" "List of Odoo users who will receive a notification to remind them about the " "Intrastat declaration." msgstr "Liste d'utilisateurs Odoo qui recevront un rappel pour la DEB/DES." #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_email_list +#: model:ir.model.fields,field_description:intrastat_base.field_res_company__intrastat_email_list msgid "List of emails of Users Receiving the Intrastat Reminder" msgstr "Liste des emails des utilisateurs qui reçoivent le rappel DEB/DES" #. module: intrastat_base -#: code:addons/intrastat_base/models/res_company.py:38 +#: code:addons/intrastat_base/models/res_company.py:37 #, python-format msgid "Missing e-mail address on user '%s'." msgstr "Adresse e-mail manquante pour l'utilisateur '%s'." #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view_note +#: model_terms:ir.ui.view,arch_db:intrastat_base.res_country_view_search +msgid "Name or Code" +msgstr "" + +#. module: intrastat_base +#: model:ir.model.fields,field_description:intrastat_base.field_intrastat_result_view__note msgid "Notes" msgstr "Notes" #. module: intrastat_base -#: model:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form +#: model_terms:ir.ui.view,arch_db:intrastat_base.intrastat_result_view_form msgid "Ok" msgstr "Ok" +#. module: intrastat_base +#: model:ir.model,name:intrastat_base.model_intrastat_result_view +msgid "Pop-up to show errors on intrastat report generation" +msgstr "" + #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_product_template msgid "Product Template" msgstr "Modèle d'article" #. module: intrastat_base -#: model:ir.ui.view,arch_db:intrastat_base.res_country_view_search +#: model_terms:ir.ui.view,arch_db:intrastat_base.res_country_view_search msgid "Search Countries" msgstr "Recherche pays" #. module: intrastat_base -#: model:ir.model.fields,help:intrastat_base.field_res_country_intrastat +#: model:ir.model.fields,help:intrastat_base.field_res_country__intrastat msgid "Set to True for all European Union countries." msgstr "Cocher la case pour tous les pays de l'Union Européenne." @@ -202,19 +229,19 @@ msgid "Templates for Taxes" msgstr "Modèles pour les taxes" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:52 +#: code:addons/intrastat_base/models/intrastat_common.py:50 #, python-format msgid "The VAT number is not set for the partner '%s'." msgstr "Numéro de TVA non renseigné sur le partenaire '%s'." #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:43 +#: code:addons/intrastat_base/models/intrastat_common.py:42 #, python-format msgid "The country is not set on the company '%s'." msgstr "Pays non renseigné sur la société '%s'." #. module: intrastat_base -#: code:addons/intrastat_base/models/product_template.py:23 +#: code:addons/intrastat_base/models/product_template.py:22 #, python-format msgid "" "The option 'Is accessory cost?' should only be activated on 'Service' " @@ -226,26 +253,31 @@ msgstr "" "type '%s'" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:73 +#: model:product.product,uom_name:intrastat_base.shipping_costs_exclude +#: model:product.template,uom_name:intrastat_base.shipping_costs_exclude_product_template +msgid "Unit(s)" +msgstr "" + +#. module: intrastat_base +#: code:addons/intrastat_base/models/intrastat_common.py:71 #, python-format msgid "Unknown Error" msgstr "" #. module: intrastat_base -#: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_remind_user_ids -#: model:ir.model.fields,field_description:intrastat_base.field_res_config_settings_intrastat_remind_user_ids +#: model:ir.model.fields,field_description:intrastat_base.field_res_company__intrastat_remind_user_ids +#: model:ir.model.fields,field_description:intrastat_base.field_res_config_settings__intrastat_remind_user_ids msgid "Users Receiving the Intrastat Reminder" msgstr "Utilisateurs qui reçoivent le rappel DEB/DES" #. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_intrastat_result_view -msgid "intrastat.result.view" -msgstr "intrastat.result.view" +#: model:product.product,weight_uom_name:intrastat_base.shipping_costs_exclude +#: model:product.template,weight_uom_name:intrastat_base.shipping_costs_exclude_product_template +msgid "kg" +msgstr "" -#. module: intrastat_base -#: model:ir.model,name:intrastat_base.model_res_config_settings -msgid "res.config.settings" -msgstr "res.config.settings" +#~ msgid "intrastat.result.view" +#~ msgstr "intrastat.result.view" #~ msgid "" #~ "The generated XML file is not valid against the official XML Schema " diff --git a/intrastat_base/static/description/index.html b/intrastat_base/static/description/index.html new file mode 100644 index 0000000..b3e9e21 --- /dev/null +++ b/intrastat_base/static/description/index.html @@ -0,0 +1,452 @@ + + + + + + +Intrastat Reporting Base + + + +
+

Intrastat Reporting Base

+ + +

Beta License: AGPL-3 OCA/intrastat-extrastat Translate me on Weblate Try me on Runbot

+

This module contains common functions for the intrastat reporting and +should be used in combination with the generic reporting module +intrastat_product and with the country-specific reporting modules such +as:

+
    +
  • l10n_fr_intrastat_service: +the module for the Déclaration Européenne des Services (DES) for France
  • +
  • l10n_fr_intrastat_product: +the module for the Déclaration d’Echange de Biens (DEB) for France
  • +
  • l10n_be_intrastat_product: +the module for the Intrastat Declaration for Belgium.
  • +
+

Table of contents

+ +
+

Installation

+

WARNING:

+

This module conflicts with the module account_intrastat from Odoo Enterprise. +If you have already installed the module account_intrastat, +you should uninstall it first before installing this module.

+
+
+

Usage

+

This module adds an intrastat property on countries and activates this property +on the countries of the European Union.

+

With this module, the country field on partners becomes a required field.

+

It adds an option Exclude invoice line from intrastat if this tax is present +on taxes.

+

It adds an Intrastat section on the Invoicing configuration page.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
  • Noviat
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/intrastat-extrastat project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + From 3d58bc2f900c764857f6f0800b3b5b3f85efe442 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Tue, 14 Jan 2020 18:15:30 +0100 Subject: [PATCH 27/39] [MIG] intrastat_base: Migration to 13.0 --- intrastat_base/__manifest__.py | 4 ++-- intrastat_base/demo/intrastat_demo.xml | 1 - intrastat_base/views/res_config_settings.xml | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/intrastat_base/__manifest__.py b/intrastat_base/__manifest__.py index 0113306..15ef179 100644 --- a/intrastat_base/__manifest__.py +++ b/intrastat_base/__manifest__.py @@ -1,11 +1,11 @@ # Copyright 2011-2016 Akretion (http://www.akretion.com) # Copyright 2018 brain-tec AG (Kumar Aberer ) -# Copyright 2009-2019 Noviat (http://www.noviat.com) +# Copyright 2009-2020 Noviat (http://www.noviat.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Intrastat Reporting Base', - 'version': '12.0.1.0.0', + 'version': '13.0.1.0.0', 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat reporting', diff --git a/intrastat_base/demo/intrastat_demo.xml b/intrastat_base/demo/intrastat_demo.xml index 181a244..d5354c1 100644 --- a/intrastat_base/demo/intrastat_demo.xml +++ b/intrastat_base/demo/intrastat_demo.xml @@ -13,7 +13,6 @@ BE0884025633 - True diff --git a/intrastat_base/views/res_config_settings.xml b/intrastat_base/views/res_config_settings.xml index ec5ea7d..c62345e 100644 --- a/intrastat_base/views/res_config_settings.xml +++ b/intrastat_base/views/res_config_settings.xml @@ -13,7 +13,7 @@ res.config.settings - +

Intrastat

From 5d9212399ac37c1bb83493d6e5291d316fa93790 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Tue, 14 Jan 2020 18:47:50 +0100 Subject: [PATCH 28/39] pre-commit --- intrastat_base/__manifest__.py | 40 ++++--- intrastat_base/models/account_tax.py | 12 +- intrastat_base/models/intrastat_common.py | 109 ++++++++++--------- intrastat_base/models/product_template.py | 20 ++-- intrastat_base/models/res_company.py | 25 +++-- intrastat_base/models/res_config_settings.py | 5 +- intrastat_base/models/res_country.py | 6 +- intrastat_base/tests/test_all.py | 12 +- 8 files changed, 121 insertions(+), 108 deletions(-) diff --git a/intrastat_base/__manifest__.py b/intrastat_base/__manifest__.py index 15ef179..3615941 100644 --- a/intrastat_base/__manifest__.py +++ b/intrastat_base/__manifest__.py @@ -4,26 +4,24 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Intrastat Reporting Base', - 'version': '13.0.1.0.0', - 'category': 'Intrastat', - 'license': 'AGPL-3', - 'summary': 'Base module for Intrastat reporting', - 'author': 'Akretion,Noviat,Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/intrastat', - 'depends': ['base_vat', 'account'], - 'excludes': ['account_intrastat'], - 'data': [ - 'data/country_data.xml', - 'views/product_template.xml', - 'views/res_partner.xml', - 'views/res_country.xml', - 'views/account_tax.xml', - 'views/res_config_settings.xml', - 'views/intrastat.xml', + "name": "Intrastat Reporting Base", + "version": "13.0.1.0.0", + "category": "Intrastat", + "license": "AGPL-3", + "summary": "Base module for Intrastat reporting", + "author": "Akretion,Noviat,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/intrastat", + "depends": ["base_vat", "account"], + "excludes": ["account_intrastat"], + "data": [ + "data/country_data.xml", + "views/product_template.xml", + "views/res_partner.xml", + "views/res_country.xml", + "views/account_tax.xml", + "views/res_config_settings.xml", + "views/intrastat.xml", ], - 'demo': [ - 'demo/intrastat_demo.xml', - ], - 'installable': True, + "demo": ["demo/intrastat_demo.xml"], + "installable": True, } diff --git a/intrastat_base/models/account_tax.py b/intrastat_base/models/account_tax.py index 79f5c72..35966a7 100644 --- a/intrastat_base/models/account_tax.py +++ b/intrastat_base/models/account_tax.py @@ -1,24 +1,26 @@ # Copyright 2011-2019 Akretion France (http://www.akretion.com). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields +from odoo import fields, models class AccountTax(models.Model): _inherit = "account.tax" exclude_from_intrastat_if_present = fields.Boolean( - string='Exclude invoice line from intrastat if this tax is present', + string="Exclude invoice line from intrastat if this tax is present", help="If this tax is present on an invoice line, this invoice " "line will be skipped when generating Intrastat Product or " - "Service lines from invoices.") + "Service lines from invoices.", + ) class AccountTaxTemplate(models.Model): _inherit = "account.tax.template" exclude_from_intrastat_if_present = fields.Boolean( - string='Exclude invoice line from intrastat if this tax is present', + string="Exclude invoice line from intrastat if this tax is present", help="If this tax is present on an invoice line, this invoice " "line will be skipped when generating Intrastat Product or " - "Service lines from invoices.") + "Service lines from invoices.", + ) diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index 1b9e36a..2fe12ce 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -2,14 +2,15 @@ # Copyright 2009-2019 Noviat (http://www.noviat.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from io import BytesIO -from lxml import etree -from sys import exc_info import base64 -from traceback import format_exception import logging +from io import BytesIO +from sys import exc_info +from traceback import format_exception -from odoo import api, fields, models, tools, _ +from lxml import etree + +from odoo import _, api, fields, models, tools from odoo.exceptions import UserError logger = logging.getLogger(__name__) @@ -20,7 +21,7 @@ class IntrastatCommon(models.AbstractModel): _description = "Common functions for intrastat reports for products " "and services" - @api.depends('declaration_line_ids.amount_company_currency') + @api.depends("declaration_line_ids.amount_company_currency") def _compute_numbers(self): for this in self: total_amount = 0 # it is an integer @@ -39,8 +40,8 @@ class IntrastatCommon(models.AbstractModel): company = this.company_id if not company.country_id: raise UserError( - _("The country is not set on the company '%s'.") - % company.name) + _("The country is not set on the company '%s'.") % company.name + ) return True def _check_generate_xml(self): @@ -48,64 +49,66 @@ class IntrastatCommon(models.AbstractModel): if not this.company_id.partner_id.vat: raise UserError( _("The VAT number is not set for the partner '%s'.") - % this.company_id.partner_id.name) + % this.company_id.partner_id.name + ) return True @api.model def _check_xml_schema(self, xml_string, xsd_file): - '''Validate the XML file against the XSD''' - xsd_etree_obj = etree.parse( - tools.file_open(xsd_file, mode='rb')) + """Validate the XML file against the XSD""" + xsd_etree_obj = etree.parse(tools.file_open(xsd_file, mode="rb")) official_schema = etree.XMLSchema(xsd_etree_obj) try: t = etree.parse(BytesIO(xml_string)) official_schema.assertValid(t) except (etree.XMLSchemaParseError, etree.DocumentInvalid) as e: - logger.warning( - "The XML file is invalid against the XML Schema Definition") + logger.warning("The XML file is invalid against the XML Schema Definition") logger.warning(xml_string) logger.warning(e) - usererror = '%s\n\n%s' % (e.__class__.__name__, str(e)) + usererror = "{}\n\n{}".format(e.__class__.__name__, str(e)) raise UserError(usererror) except Exception: error = _("Unknown Error") - tb = ''.join(format_exception(*exc_info())) - error += '\n%s' % tb + tb = "".join(format_exception(*exc_info())) + error += "\n%s" % tb logger.warning(error) raise UserError(error) def _attach_xml_file(self, xml_string, declaration_name): - '''Attach the XML file to the report_intrastat_product/service - object''' + """Attach the XML file to the report_intrastat_product/service + object""" self.ensure_one() - filename = '%s_%s.xml' % (self.year_month, declaration_name) - attach = self.env['ir.attachment'].create({ - 'name': filename, - 'res_id': self.id, - 'res_model': self._name, - 'datas': base64.encodestring(xml_string), - 'datas_fname': filename}) + filename = "{}_{}.xml".format(self.year_month, declaration_name) + attach = self.env["ir.attachment"].create( + { + "name": filename, + "res_id": self.id, + "res_model": self._name, + "datas": base64.encodestring(xml_string), + "datas_fname": filename, + } + ) return attach.id def _unlink_attachments(self): - atts = self.env['ir.attachment'].search( - [('res_model', '=', self._name), - ('res_id', '=', self.id)]) + atts = self.env["ir.attachment"].search( + [("res_model", "=", self._name), ("res_id", "=", self.id)] + ) atts.unlink() @api.model - def _open_attach_view(self, attach_id, title='XML file'): - '''Returns an action which opens the form view of the - corresponding attachement''' + def _open_attach_view(self, attach_id, title="XML file"): + """Returns an action which opens the form view of the + corresponding attachement""" action = { - 'name': title, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'ir.attachment', - 'type': 'ir.actions.act_window', - 'nodestroy': True, - 'target': 'current', - 'res_id': attach_id, + "name": title, + "view_type": "form", + "view_mode": "form", + "res_model": "ir.attachment", + "type": "ir.actions.act_window", + "nodestroy": True, + "target": "current", + "res_id": attach_id, } return action @@ -128,20 +131,23 @@ class IntrastatCommon(models.AbstractModel): if this.company_id.intrastat_remind_user_ids: mail_template.send_mail(this.id) logger.info( - 'Intrastat Reminder email has been sent (XMLID: %s).' - % mail_template_xmlid) + "Intrastat Reminder email has been sent (XMLID: %s)." + % mail_template_xmlid + ) else: logger.warning( - 'The list of users receiving the Intrastat Reminder is ' - 'empty on company %s' % this.company_id.name) + "The list of users receiving the Intrastat Reminder is " + "empty on company %s" % this.company_id.name + ) return True def unlink(self): for intrastat in self: - if intrastat.state == 'done': + if intrastat.state == "done": raise UserError( - _('Cannot delete the declaration %s ' - 'because it is in Done state') % self.year_month) + _("Cannot delete the declaration %s " "because it is in Done state") + % self.year_month + ) return super(IntrastatCommon, self).unlink() @@ -149,9 +155,10 @@ class IntrastatResultView(models.TransientModel): """ Transient Model to display Intrastat Report results """ - _name = 'intrastat.result.view' - _description = 'Pop-up to show errors on intrastat report generation' + + _name = "intrastat.result.view" + _description = "Pop-up to show errors on intrastat report generation" note = fields.Text( - string='Notes', readonly=True, - default=lambda self: self._context.get('note')) + string="Notes", readonly=True, default=lambda self: self._context.get("note") + ) diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index 804aa59..d5cb3b4 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -1,7 +1,7 @@ # Copyright 2010-2016 Akretion () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models, _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError @@ -9,18 +9,22 @@ class ProductTemplate(models.Model): _inherit = "product.template" is_accessory_cost = fields.Boolean( - string='Is accessory cost', + string="Is accessory cost", help="Activate this option for shipping costs, packaging " "costs and all services related to the sale of products. " - "This option is used for Intrastat reports.") + "This option is used for Intrastat reports.", + ) - @api.constrains('type', 'is_accessory_cost') + @api.constrains("type", "is_accessory_cost") def _check_accessory_cost(self): for this in self: - if this.is_accessory_cost and this.type != 'service': + if this.is_accessory_cost and this.type != "service": raise ValidationError( - _("The option 'Is accessory cost?' should only be " + _( + "The option 'Is accessory cost?' should only be " "activated on 'Service' products. You have activated " "this option for the product '%s' which is of type " - "'%s'") % - (this.name, this.type)) + "'%s'" + ) + % (this.name, this.type) + ) diff --git a/intrastat_base/models/res_company.py b/intrastat_base/models/res_company.py index 05c3d15..63a0936 100644 --- a/intrastat_base/models/res_company.py +++ b/intrastat_base/models/res_company.py @@ -2,7 +2,7 @@ # @author: # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models, _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError @@ -10,29 +10,32 @@ class ResCompany(models.Model): _inherit = "res.company" intrastat_remind_user_ids = fields.Many2many( - 'res.users', column1='company_id', column2='user_id', + "res.users", + column1="company_id", + column2="user_id", string="Users Receiving the Intrastat Reminder", help="List of Odoo users who will receive a notification to " - "remind them about the Intrastat declaration.") + "remind them about the Intrastat declaration.", + ) intrastat_email_list = fields.Char( - compute='_compute_intrastat_email_list', - string='List of emails of Users Receiving the Intrastat Reminder') + compute="_compute_intrastat_email_list", + string="List of emails of Users Receiving the Intrastat Reminder", + ) - @api.depends( - 'intrastat_remind_user_ids', 'intrastat_remind_user_ids.email') + @api.depends("intrastat_remind_user_ids", "intrastat_remind_user_ids.email") def _compute_intrastat_email_list(self): for this in self: emails = [] for user in this.intrastat_remind_user_ids: if user.email: emails.append(user.email) - this.intrastat_email_list = ','.join(emails) + this.intrastat_email_list = ",".join(emails) - @api.constrains('intrastat_remind_user_ids') + @api.constrains("intrastat_remind_user_ids") def _check_intrastat_remind_users(self): for this in self: for user in this.intrastat_remind_user_ids: if not user.email: raise ValidationError( - _("Missing e-mail address on user '%s'.") % - (user.name)) + _("Missing e-mail address on user '%s'.") % (user.name) + ) diff --git a/intrastat_base/models/res_config_settings.py b/intrastat_base/models/res_config_settings.py index 51bec6c..c208d79 100644 --- a/intrastat_base/models/res_config_settings.py +++ b/intrastat_base/models/res_config_settings.py @@ -6,7 +6,8 @@ from odoo import fields, models class ResConfigSettings(models.TransientModel): - _inherit = 'res.config.settings' + _inherit = "res.config.settings" intrastat_remind_user_ids = fields.Many2many( - related='company_id.intrastat_remind_user_ids', readonly=False) + related="company_id.intrastat_remind_user_ids", readonly=False + ) diff --git a/intrastat_base/models/res_country.py b/intrastat_base/models/res_country.py index 74f0685..cbf2482 100644 --- a/intrastat_base/models/res_country.py +++ b/intrastat_base/models/res_country.py @@ -6,8 +6,8 @@ from odoo import fields, models class ResCountry(models.Model): - _inherit = 'res.country' + _inherit = "res.country" intrastat = fields.Boolean( - string='EU Country', - help="Set to True for all European Union countries.") + string="EU Country", help="Set to True for all European Union countries." + ) diff --git a/intrastat_base/tests/test_all.py b/intrastat_base/tests/test_all.py index fbc91ac..18d64d4 100644 --- a/intrastat_base/tests/test_all.py +++ b/intrastat_base/tests/test_all.py @@ -6,17 +6,15 @@ class TestIntrastatBase(TransactionCase): def test_10_countries(self): # check if only EU countries have the 'intrastat' bit set - france = self.env.ref('base.fr') + france = self.env.ref("base.fr") self.assertTrue(france.intrastat) - brazil = self.env.ref('base.br') + brazil = self.env.ref("base.br") self.assertFalse(brazil.intrastat) def test_20_company(self): # add 'Demo user' to intrastat_remind_user_ids - demo_user = self.env.ref('base.user_demo') - demo_company = self.env.ref('base.main_company') - demo_company.write({ - 'intrastat_remind_user_ids': [(6, False, [demo_user.id])] - }) + demo_user = self.env.ref("base.user_demo") + demo_company = self.env.ref("base.main_company") + demo_company.write({"intrastat_remind_user_ids": [(6, False, [demo_user.id])]}) # then check if intrastat_email_list contains the email of the user self.assertEquals(demo_company.intrastat_email_list, demo_user.email) From 62ee3e5bef7b95e522a4413293c2e3069a8c95e5 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Fri, 17 Jan 2020 14:14:27 +0000 Subject: [PATCH 29/39] [UPD] Update intrastat_base.pot --- intrastat_base/i18n/intrastat_base.pot | 46 ++++++++++++++------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/intrastat_base/i18n/intrastat_base.pot b/intrastat_base/i18n/intrastat_base.pot index 00e44dc..40d82d2 100644 --- a/intrastat_base/i18n/intrastat_base.pot +++ b/intrastat_base/i18n/intrastat_base.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * intrastat_base +# * intrastat_base # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 13.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" @@ -16,11 +16,13 @@ msgstr "" #. module: intrastat_base #: model:ir.model.fields,help:intrastat_base.field_product_product__is_accessory_cost #: model:ir.model.fields,help:intrastat_base.field_product_template__is_accessory_cost -msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports." +msgid "" +"Activate this option for shipping costs, packaging costs and all services " +"related to the sale of products. This option is used for Intrastat reports." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:143 +#: code:addons/intrastat_base/models/intrastat_common.py:0 #, python-format msgid "Cannot delete the declaration %s because it is in Done state" msgstr "" @@ -36,7 +38,7 @@ msgid "Companies" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:38 +#: code:addons/intrastat_base/models/intrastat_common.py:0 #, python-format msgid "Company not yet set on intrastat report." msgstr "" @@ -98,7 +100,9 @@ msgstr "" #. module: intrastat_base #: model:ir.model.fields,help:intrastat_base.field_account_tax__exclude_from_intrastat_if_present #: model:ir.model.fields,help:intrastat_base.field_account_tax_template__exclude_from_intrastat_if_present -msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices." +msgid "" +"If this tax is present on an invoice line, this invoice line will be skipped" +" when generating Intrastat Product or Service lines from invoices." msgstr "" #. module: intrastat_base @@ -143,7 +147,9 @@ msgstr "" #. module: intrastat_base #: model:ir.model.fields,help:intrastat_base.field_res_company__intrastat_remind_user_ids #: model:ir.model.fields,help:intrastat_base.field_res_config_settings__intrastat_remind_user_ids -msgid "List of Odoo users who will receive a notification to remind them about the Intrastat declaration." +msgid "" +"List of Odoo users who will receive a notification to remind them about the " +"Intrastat declaration." msgstr "" #. module: intrastat_base @@ -152,7 +158,7 @@ msgid "List of emails of Users Receiving the Intrastat Reminder" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/res_company.py:37 +#: code:addons/intrastat_base/models/res_company.py:0 #, python-format msgid "Missing e-mail address on user '%s'." msgstr "" @@ -209,31 +215,34 @@ msgid "Templates for Taxes" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:50 +#: code:addons/intrastat_base/models/intrastat_common.py:0 #, python-format msgid "The VAT number is not set for the partner '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:42 +#: code:addons/intrastat_base/models/intrastat_common.py:0 #, python-format msgid "The country is not set on the company '%s'." msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/product_template.py:22 +#: code:addons/intrastat_base/models/product_template.py:0 #, python-format -msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" +msgid "" +"The option 'Is accessory cost?' should only be activated on 'Service' " +"products. You have activated this option for the product '%s' which is of " +"type '%s'" msgstr "" #. module: intrastat_base #: model:product.product,uom_name:intrastat_base.shipping_costs_exclude #: model:product.template,uom_name:intrastat_base.shipping_costs_exclude_product_template -msgid "Unit(s)" +msgid "Units" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:71 +#: code:addons/intrastat_base/models/intrastat_common.py:0 #, python-format msgid "Unknown Error" msgstr "" @@ -243,10 +252,3 @@ msgstr "" #: model:ir.model.fields,field_description:intrastat_base.field_res_config_settings__intrastat_remind_user_ids msgid "Users Receiving the Intrastat Reminder" msgstr "" - -#. module: intrastat_base -#: model:product.product,weight_uom_name:intrastat_base.shipping_costs_exclude -#: model:product.template,weight_uom_name:intrastat_base.shipping_costs_exclude_product_template -msgid "kg" -msgstr "" - From c4eb2a3df259e6dc473699d8017b34a83fd08c28 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Fri, 17 Jan 2020 14:19:50 +0000 Subject: [PATCH 30/39] [UPD] README.rst --- intrastat_base/README.rst | 10 +++++----- intrastat_base/static/description/index.html | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/intrastat_base/README.rst b/intrastat_base/README.rst index 777cf4d..5c8888f 100644 --- a/intrastat_base/README.rst +++ b/intrastat_base/README.rst @@ -14,13 +14,13 @@ Intrastat Reporting Base :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fintrastat--extrastat-lightgray.png?logo=github - :target: https://github.com/OCA/intrastat-extrastat/tree/12.0/intrastat_base + :target: https://github.com/OCA/intrastat-extrastat/tree/13.0/intrastat_base :alt: OCA/intrastat-extrastat .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/intrastat-extrastat-12-0/intrastat-extrastat-12-0-intrastat_base + :target: https://translation.odoo-community.org/projects/intrastat-extrastat-13-0/intrastat-extrastat-13-0-intrastat_base :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/227/12.0 + :target: https://runbot.odoo-community.org/runbot/227/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -70,7 +70,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -104,6 +104,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/intrastat-extrastat `_ project on GitHub. +This module is part of the `OCA/intrastat-extrastat `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/intrastat_base/static/description/index.html b/intrastat_base/static/description/index.html index b3e9e21..b12b2e2 100644 --- a/intrastat_base/static/description/index.html +++ b/intrastat_base/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/intrastat-extrastat Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/intrastat-extrastat Translate me on Weblate Try me on Runbot

This module contains common functions for the intrastat reporting and should be used in combination with the generic reporting module intrastat_product and with the country-specific reporting modules such @@ -415,7 +415,7 @@ on taxes.

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -443,7 +443,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/intrastat-extrastat project on GitHub.

+

This module is part of the OCA/intrastat-extrastat project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

From 5fb08c862dab559f267a73490fa2cf077021b491 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Fri, 31 Jan 2020 17:47:46 +0000 Subject: [PATCH 31/39] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: intrastat-extrastat-13.0/intrastat-extrastat-13.0-intrastat_base Translate-URL: https://translation.odoo-community.org/projects/intrastat-extrastat-13-0/intrastat-extrastat-13-0-intrastat_base/ --- intrastat_base/i18n/fr.po | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/intrastat_base/i18n/fr.po b/intrastat_base/i18n/fr.po index 2f074a6..73707c0 100644 --- a/intrastat_base/i18n/fr.po +++ b/intrastat_base/i18n/fr.po @@ -28,7 +28,7 @@ msgstr "" "la DEB et la DES." #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:143 +#: code:addons/intrastat_base/models/intrastat_common.py:0 #, python-format msgid "Cannot delete the declaration %s because it is in Done state" msgstr "" @@ -46,7 +46,7 @@ msgid "Companies" msgstr "Sociétés" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:38 +#: code:addons/intrastat_base/models/intrastat_common.py:0 #, python-format msgid "Company not yet set on intrastat report." msgstr "Société non configurée sur le rapport DEB/DES." @@ -172,7 +172,7 @@ msgid "List of emails of Users Receiving the Intrastat Reminder" msgstr "Liste des emails des utilisateurs qui reçoivent le rappel DEB/DES" #. module: intrastat_base -#: code:addons/intrastat_base/models/res_company.py:37 +#: code:addons/intrastat_base/models/res_company.py:0 #, python-format msgid "Missing e-mail address on user '%s'." msgstr "Adresse e-mail manquante pour l'utilisateur '%s'." @@ -229,19 +229,19 @@ msgid "Templates for Taxes" msgstr "Modèles pour les taxes" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:50 +#: code:addons/intrastat_base/models/intrastat_common.py:0 #, python-format msgid "The VAT number is not set for the partner '%s'." msgstr "Numéro de TVA non renseigné sur le partenaire '%s'." #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:42 +#: code:addons/intrastat_base/models/intrastat_common.py:0 #, python-format msgid "The country is not set on the company '%s'." msgstr "Pays non renseigné sur la société '%s'." #. module: intrastat_base -#: code:addons/intrastat_base/models/product_template.py:22 +#: code:addons/intrastat_base/models/product_template.py:0 #, python-format msgid "" "The option 'Is accessory cost?' should only be activated on 'Service' " @@ -255,11 +255,11 @@ msgstr "" #. module: intrastat_base #: model:product.product,uom_name:intrastat_base.shipping_costs_exclude #: model:product.template,uom_name:intrastat_base.shipping_costs_exclude_product_template -msgid "Unit(s)" +msgid "Units" msgstr "" #. module: intrastat_base -#: code:addons/intrastat_base/models/intrastat_common.py:71 +#: code:addons/intrastat_base/models/intrastat_common.py:0 #, python-format msgid "Unknown Error" msgstr "" @@ -270,12 +270,6 @@ msgstr "" msgid "Users Receiving the Intrastat Reminder" msgstr "Utilisateurs qui reçoivent le rappel DEB/DES" -#. module: intrastat_base -#: model:product.product,weight_uom_name:intrastat_base.shipping_costs_exclude -#: model:product.template,weight_uom_name:intrastat_base.shipping_costs_exclude_product_template -msgid "kg" -msgstr "" - #~ msgid "intrastat.result.view" #~ msgstr "intrastat.result.view" From 0b776050804cd27ea9f7036a8bb676ad2c32b16c Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Wed, 26 Feb 2020 22:16:50 +0100 Subject: [PATCH 32/39] [MIG] intrastat_product: Migration to 13.0 --- intrastat_base/demo/intrastat_demo.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intrastat_base/demo/intrastat_demo.xml b/intrastat_base/demo/intrastat_demo.xml index d5354c1..f8adbb7 100644 --- a/intrastat_base/demo/intrastat_demo.xml +++ b/intrastat_base/demo/intrastat_demo.xml @@ -17,7 +17,7 @@ Shipping costs - SHIP + SHIP_S service 30 From 83f40fb5da58dc4c995dcbb7986a20a5aaa7d366 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Tue, 3 Mar 2020 20:54:13 +0100 Subject: [PATCH 33/39] [13.0][FIX]attach_xml_file --- intrastat_base/models/intrastat_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index 2fe12ce..00ac4b1 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -85,7 +85,7 @@ class IntrastatCommon(models.AbstractModel): "res_id": self.id, "res_model": self._name, "datas": base64.encodestring(xml_string), - "datas_fname": filename, + "store_fname": filename, } ) return attach.id From f14e1471736d0d1dc463fb645a67920b79d4da59 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Tue, 3 Mar 2020 20:25:45 +0000 Subject: [PATCH 34/39] intrastat_base 13.0.1.1.0 --- intrastat_base/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intrastat_base/__manifest__.py b/intrastat_base/__manifest__.py index 3615941..ec74e37 100644 --- a/intrastat_base/__manifest__.py +++ b/intrastat_base/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Intrastat Reporting Base", - "version": "13.0.1.0.0", + "version": "13.0.1.1.0", "category": "Intrastat", "license": "AGPL-3", "summary": "Base module for Intrastat reporting", From a75f7782ee6a7ab783d3eb9fe32e7e3682cf7c2b Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Sat, 14 Mar 2020 12:01:50 +0100 Subject: [PATCH 35/39] pre-commit update --- intrastat_base/data/country_data.xml | 60 ++++++------- intrastat_base/demo/intrastat_demo.xml | 36 ++++---- intrastat_base/views/account_tax.xml | 25 +++--- intrastat_base/views/intrastat.xml | 48 +++++----- intrastat_base/views/product_template.xml | 37 ++++---- intrastat_base/views/res_config_settings.xml | 20 +++-- intrastat_base/views/res_country.xml | 92 ++++++++++---------- intrastat_base/views/res_partner.xml | 35 ++++---- 8 files changed, 174 insertions(+), 179 deletions(-) diff --git a/intrastat_base/data/country_data.xml b/intrastat_base/data/country_data.xml index 3c75a3a..cb950e6 100644 --- a/intrastat_base/data/country_data.xml +++ b/intrastat_base/data/country_data.xml @@ -1,89 +1,87 @@ - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - diff --git a/intrastat_base/demo/intrastat_demo.xml b/intrastat_base/demo/intrastat_demo.xml index f8adbb7..5a93379 100644 --- a/intrastat_base/demo/intrastat_demo.xml +++ b/intrastat_base/demo/intrastat_demo.xml @@ -1,27 +1,23 @@ - + - - - - FR58441019213 - - - - BE0884025633 - - - - Shipping costs - SHIP_S - service - - 30 - True - - + + FR58441019213 + + + + BE0884025633 + + + Shipping costs + SHIP_S + service + + 30 + True + diff --git a/intrastat_base/views/account_tax.xml b/intrastat_base/views/account_tax.xml index 222f71b..0479a6f 100644 --- a/intrastat_base/views/account_tax.xml +++ b/intrastat_base/views/account_tax.xml @@ -1,22 +1,19 @@ - + - - - - - intrastat.base.tax - account.tax - - - - + + + intrastat.base.tax + account.tax + + + + + - - - + diff --git a/intrastat_base/views/intrastat.xml b/intrastat_base/views/intrastat.xml index 3381e0c..92bfba2 100644 --- a/intrastat_base/views/intrastat.xml +++ b/intrastat_base/views/intrastat.xml @@ -1,33 +1,35 @@ - + - - - - - - + + - intrastat.result_view_form - intrastat.result.view - -
- - - -
-
-
-
+ intrastat.result_view_form + intrastat.result.view + +
+ + + +
+
+
+
-
diff --git a/intrastat_base/views/product_template.xml b/intrastat_base/views/product_template.xml index fff74e1..4dc5b90 100644 --- a/intrastat_base/views/product_template.xml +++ b/intrastat_base/views/product_template.xml @@ -1,29 +1,26 @@ - + - - - - - intrastat.base.product.template.form - product.template - - - - - - + + - - - - - +
+
diff --git a/intrastat_base/views/res_config_settings.xml b/intrastat_base/views/res_config_settings.xml index c62345e..3c1340b 100644 --- a/intrastat_base/views/res_config_settings.xml +++ b/intrastat_base/views/res_config_settings.xml @@ -1,27 +1,31 @@ - + - - intrastat.res.config.settings.form res.config.settings - +

Intrastat

-
+
-
@@ -29,6 +33,4 @@ - - diff --git a/intrastat_base/views/res_country.xml b/intrastat_base/views/res_country.xml index 3ecc2fd..c0e1626 100644 --- a/intrastat_base/views/res_country.xml +++ b/intrastat_base/views/res_country.xml @@ -1,52 +1,56 @@ - + - - - - - - intrastat.base.country.tree - res.country - - - - + + + intrastat.base.country.tree + res.country + + + + + - - - - - intrastat.base.country.form - res.country - - - - + + + intrastat.base.country.form + res.country + + + + + - - - - - - intrastat.base.country.search - res.country - - - - - - - - - - - - - - + + + + intrastat.base.country.search + res.country + + + + + + + + + + + + diff --git a/intrastat_base/views/res_partner.xml b/intrastat_base/views/res_partner.xml index 5f31add..8c2f652 100644 --- a/intrastat_base/views/res_partner.xml +++ b/intrastat_base/views/res_partner.xml @@ -1,25 +1,24 @@ - + - - - - - res.partner - - - - 1 - - - 1 - - - - + + + res.partner + + + + 1 + + + 1 + + + From aa79b94031273ab6a262e071551dc1074abde6c8 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 8 Jun 2020 22:39:46 +0200 Subject: [PATCH 36/39] intrastat_product: Add xml_attachment_id field intrastat_product: add mail.activity.mixin and widget in form view product_harmonized_system: remove archive button (use Action menu) All modules: - use super() instead of super(class, self) - Update domain_force in multi-company ir.rule to v13 standard --- intrastat_base/models/intrastat_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index 00ac4b1..45ad7c6 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -148,7 +148,7 @@ class IntrastatCommon(models.AbstractModel): _("Cannot delete the declaration %s " "because it is in Done state") % self.year_month ) - return super(IntrastatCommon, self).unlink() + return super().unlink() class IntrastatResultView(models.TransientModel): From 821fd1f3a85766a0de6ffdb3c9e4a0b941ea43ad Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sun, 16 Aug 2020 11:27:26 +0000 Subject: [PATCH 37/39] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: intrastat-extrastat-13.0/intrastat-extrastat-13.0-intrastat_base Translate-URL: https://translation.odoo-community.org/projects/intrastat-extrastat-13-0/intrastat-extrastat-13-0-intrastat_base/ --- intrastat_base/i18n/fr.po | 1 - 1 file changed, 1 deletion(-) diff --git a/intrastat_base/i18n/fr.po b/intrastat_base/i18n/fr.po index 73707c0..c95b44d 100644 --- a/intrastat_base/i18n/fr.po +++ b/intrastat_base/i18n/fr.po @@ -54,7 +54,6 @@ msgstr "Société non configurée sur le rapport DEB/DES." #. module: intrastat_base #: model:ir.model,name:intrastat_base.model_res_config_settings #, fuzzy -#| msgid "res.config.settings" msgid "Config Settings" msgstr "res.config.settings" From b03b74ad7bb55f54d305cb73f4b0cae1e4d820ed Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 14 Oct 2020 22:19:30 +0200 Subject: [PATCH 38/39] [MIG] intrastat_base from v13 to v14 Up-port PR #98 --- intrastat_base/__manifest__.py | 7 ++++--- intrastat_base/demo/intrastat_demo.xml | 4 ++-- intrastat_base/models/account_tax.py | 2 +- intrastat_base/models/intrastat_common.py | 5 ++--- intrastat_base/models/product_template.py | 4 ++-- intrastat_base/models/res_company.py | 5 +++-- intrastat_base/models/res_config_settings.py | 5 +++-- intrastat_base/models/res_country.py | 2 +- intrastat_base/security/ir.model.access.csv | 2 ++ intrastat_base/tests/test_all.py | 2 +- intrastat_base/views/account_tax.xml | 7 +++---- intrastat_base/views/intrastat.xml | 6 +++--- intrastat_base/views/product_template.xml | 6 +++--- intrastat_base/views/res_config_settings.xml | 4 ++-- intrastat_base/views/res_country.xml | 3 ++- intrastat_base/views/res_partner.xml | 2 +- 16 files changed, 35 insertions(+), 31 deletions(-) create mode 100644 intrastat_base/security/ir.model.access.csv diff --git a/intrastat_base/__manifest__.py b/intrastat_base/__manifest__.py index ec74e37..4d0f6d2 100644 --- a/intrastat_base/__manifest__.py +++ b/intrastat_base/__manifest__.py @@ -1,11 +1,11 @@ -# Copyright 2011-2016 Akretion (http://www.akretion.com) -# Copyright 2018 brain-tec AG (Kumar Aberer ) +# Copyright 2011-2020 Akretion (http://www.akretion.com) +# Copyright 2018-2020 brain-tec AG (Kumar Aberer ) # Copyright 2009-2020 Noviat (http://www.noviat.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Intrastat Reporting Base", - "version": "13.0.1.1.0", + "version": "14.0.1.0.0", "category": "Intrastat", "license": "AGPL-3", "summary": "Base module for Intrastat reporting", @@ -14,6 +14,7 @@ "depends": ["base_vat", "account"], "excludes": ["account_intrastat"], "data": [ + "security/ir.model.access.csv", "data/country_data.xml", "views/product_template.xml", "views/res_partner.xml", diff --git a/intrastat_base/demo/intrastat_demo.xml b/intrastat_base/demo/intrastat_demo.xml index 5a93379..6e6cd90 100644 --- a/intrastat_base/demo/intrastat_demo.xml +++ b/intrastat_base/demo/intrastat_demo.xml @@ -1,6 +1,6 @@ @@ -18,6 +18,6 @@ service 30 - True + diff --git a/intrastat_base/models/account_tax.py b/intrastat_base/models/account_tax.py index 35966a7..ebe693b 100644 --- a/intrastat_base/models/account_tax.py +++ b/intrastat_base/models/account_tax.py @@ -1,4 +1,4 @@ -# Copyright 2011-2019 Akretion France (http://www.akretion.com). +# Copyright 2011-2020 Akretion France (http://www.akretion.com). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import fields, models diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index 45ad7c6..057cc8b 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -1,5 +1,5 @@ -# Copyright 2010-2016 Akretion () -# Copyright 2009-2019 Noviat (http://www.noviat.com) +# Copyright 2010-2020 Akretion () +# Copyright 2009-2020 Noviat (http://www.noviat.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import base64 @@ -102,7 +102,6 @@ class IntrastatCommon(models.AbstractModel): corresponding attachement""" action = { "name": title, - "view_type": "form", "view_mode": "form", "res_model": "ir.attachment", "type": "ir.actions.act_window", diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index d5cb3b4..d63656c 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -1,4 +1,4 @@ -# Copyright 2010-2016 Akretion () +# Copyright 2010-2020 Akretion () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _, api, fields, models @@ -26,5 +26,5 @@ class ProductTemplate(models.Model): "this option for the product '%s' which is of type " "'%s'" ) - % (this.name, this.type) + % (this.display_name, this.type) ) diff --git a/intrastat_base/models/res_company.py b/intrastat_base/models/res_company.py index 63a0936..eefce32 100644 --- a/intrastat_base/models/res_company.py +++ b/intrastat_base/models/res_company.py @@ -1,4 +1,4 @@ -# Copyright 2013-2017 Akretion France (http://www.akretion.com/) +# Copyright 2013-2020 Akretion France (http://www.akretion.com/) # @author: # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -10,7 +10,8 @@ class ResCompany(models.Model): _inherit = "res.company" intrastat_remind_user_ids = fields.Many2many( - "res.users", + comodel_name="res.users", + relation="company_intrastat_reminder_user_rel", column1="company_id", column2="user_id", string="Users Receiving the Intrastat Reminder", diff --git a/intrastat_base/models/res_config_settings.py b/intrastat_base/models/res_config_settings.py index c208d79..25e1b37 100644 --- a/intrastat_base/models/res_config_settings.py +++ b/intrastat_base/models/res_config_settings.py @@ -1,5 +1,6 @@ -# Copyright 2017 Akretion (Alexis de Lattre ) -# Copyright 2018 brain-tec AG (Kumar Aberer ) +# Copyright 2017-2020 Akretion France (http://www.akretion.com/) +# Copyright 2018-2020 brain-tec AG (Kumar Aberer ) +# @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import fields, models diff --git a/intrastat_base/models/res_country.py b/intrastat_base/models/res_country.py index cbf2482..10743b7 100644 --- a/intrastat_base/models/res_country.py +++ b/intrastat_base/models/res_country.py @@ -1,4 +1,4 @@ -# Copyright 2011-2019 Akretion France (http://www.akretion.com/) +# Copyright 2011-2020 Akretion France (http://www.akretion.com/) # @author: # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/intrastat_base/security/ir.model.access.csv b/intrastat_base/security/ir.model.access.csv new file mode 100644 index 0000000..fbe710c --- /dev/null +++ b/intrastat_base/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_intrastat_result_view,Access on intrastat.result.view,model_intrastat_result_view,account.group_account_user,1,1,1,0 diff --git a/intrastat_base/tests/test_all.py b/intrastat_base/tests/test_all.py index 18d64d4..62b1787 100644 --- a/intrastat_base/tests/test_all.py +++ b/intrastat_base/tests/test_all.py @@ -17,4 +17,4 @@ class TestIntrastatBase(TransactionCase): demo_company = self.env.ref("base.main_company") demo_company.write({"intrastat_remind_user_ids": [(6, False, [demo_user.id])]}) # then check if intrastat_email_list contains the email of the user - self.assertEquals(demo_company.intrastat_email_list, demo_user.email) + self.assertEqual(demo_company.intrastat_email_list, demo_user.email) diff --git a/intrastat_base/views/account_tax.xml b/intrastat_base/views/account_tax.xml index 0479a6f..a135bb5 100644 --- a/intrastat_base/views/account_tax.xml +++ b/intrastat_base/views/account_tax.xml @@ -1,19 +1,18 @@ - intrastat.base.tax account.tax - + - + diff --git a/intrastat_base/views/intrastat.xml b/intrastat_base/views/intrastat.xml index 92bfba2..ca14bae 100644 --- a/intrastat_base/views/intrastat.xml +++ b/intrastat_base/views/intrastat.xml @@ -1,7 +1,7 @@ @@ -27,7 +27,7 @@
-
diff --git a/intrastat_base/views/product_template.xml b/intrastat_base/views/product_template.xml index 4dc5b90..4854cdd 100644 --- a/intrastat_base/views/product_template.xml +++ b/intrastat_base/views/product_template.xml @@ -1,6 +1,6 @@ @@ -11,9 +11,9 @@ - + + localisation module to set invisible="0" --> diff --git a/intrastat_base/views/res_country.xml b/intrastat_base/views/res_country.xml index c0e1626..5ce3edb 100644 --- a/intrastat_base/views/res_country.xml +++ b/intrastat_base/views/res_country.xml @@ -1,6 +1,7 @@ diff --git a/intrastat_base/views/res_partner.xml b/intrastat_base/views/res_partner.xml index 8c2f652..3b1d193 100644 --- a/intrastat_base/views/res_partner.xml +++ b/intrastat_base/views/res_partner.xml @@ -1,6 +1,6 @@ From ef04b29cd92476acdd5b0a9a687fecde03932756 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 15 Oct 2020 00:51:36 +0200 Subject: [PATCH 39/39] intrastat_base: remove methods in intrastat.common that are not useful any more Rename variables to avoid misunderstanding between string and bytes --- intrastat_base/models/intrastat_common.py | 43 +++++++---------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index 057cc8b..a78ae4d 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -21,16 +21,10 @@ class IntrastatCommon(models.AbstractModel): _description = "Common functions for intrastat reports for products " "and services" - @api.depends("declaration_line_ids.amount_company_currency") - def _compute_numbers(self): - for this in self: - total_amount = 0 # it is an integer - num_lines = 0 - for line in this.declaration_line_ids: - total_amount += line.amount_company_currency - num_lines += 1 - this.num_decl_lines = num_lines - this.total_amount = total_amount + # The method _compute_numbers has been removed + # because it was using a loop on lines, which is slow -> we should + # use read_group() instead, but then the code depends on + # the line object, so it can't be factorized here def _check_generate_lines(self): """Check wether all requirements are met for generating lines.""" @@ -54,16 +48,16 @@ class IntrastatCommon(models.AbstractModel): return True @api.model - def _check_xml_schema(self, xml_string, xsd_file): + def _check_xml_schema(self, xml_bytes, xsd_file): """Validate the XML file against the XSD""" xsd_etree_obj = etree.parse(tools.file_open(xsd_file, mode="rb")) official_schema = etree.XMLSchema(xsd_etree_obj) try: - t = etree.parse(BytesIO(xml_string)) + t = etree.parse(BytesIO(xml_bytes)) official_schema.assertValid(t) except (etree.XMLSchemaParseError, etree.DocumentInvalid) as e: logger.warning("The XML file is invalid against the XML Schema Definition") - logger.warning(xml_string) + logger.warning(xml_bytes) logger.warning(e) usererror = "{}\n\n{}".format(e.__class__.__name__, str(e)) raise UserError(usererror) @@ -74,7 +68,7 @@ class IntrastatCommon(models.AbstractModel): logger.warning(error) raise UserError(error) - def _attach_xml_file(self, xml_string, declaration_name): + def _attach_xml_file(self, xml_bytes, declaration_name): """Attach the XML file to the report_intrastat_product/service object""" self.ensure_one() @@ -84,8 +78,7 @@ class IntrastatCommon(models.AbstractModel): "name": filename, "res_id": self.id, "res_model": self._name, - "datas": base64.encodestring(xml_string), - "store_fname": filename, + "datas": base64.encodebytes(xml_bytes), } ) return attach.id @@ -96,20 +89,10 @@ class IntrastatCommon(models.AbstractModel): ) atts.unlink() - @api.model - def _open_attach_view(self, attach_id, title="XML file"): - """Returns an action which opens the form view of the - corresponding attachement""" - action = { - "name": title, - "view_mode": "form", - "res_model": "ir.attachment", - "type": "ir.actions.act_window", - "nodestroy": True, - "target": "current", - "res_id": attach_id, - } - return action + # Method _open_attach_view() removed + # Let's handle attachments like in l10n_fr_intrastat_service v14 + # with the field attachment_id on the declaration and the download + # link directly on the form view of the declaration. def _generate_xml(self): """