[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
This commit is contained in:
Alexis de Lattre
2015-04-14 22:33:32 +02:00
committed by Alexis de Lattre
parent 27abedf5b9
commit 6f94b5197a
11 changed files with 273 additions and 261 deletions

44
intrastat_base/README.rst Normal file
View File

@@ -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 <alexis.delattre@akretion.com>
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.

View File

@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Report intrastat base module for Odoo # Intrastat base module for Odoo
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com) # Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com> # @author Alexis de Lattre <alexis.delattre@akretion.com>
# #
@@ -23,23 +23,13 @@
{ {
'name': 'Intrastat Reporting Base', 'name': 'Intrastat Reporting Base',
'version': '1.1', 'version': '1.1',
'category': 'Localisation/Report Intrastat', 'category': 'Intrastat',
'license': 'AGPL-3', 'license': 'AGPL-3',
'summary': 'Base module for Intrastat reporting', 'summary': 'Base module for Intrastat reporting',
'description': """This module contains the common functions for 2 other modules : 'author': 'Akretion,Odoo Community Association (OCA)',
- 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 <alexis.delattre@akretion.com> for any help or question about this module.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com', 'website': 'http://www.akretion.com',
'depends': ['base_vat'], 'depends': ['base_vat'],
'conflicts': ['report_intrastat'],
'data': [ 'data': [
'country_data.xml', 'country_data.xml',
'product_view.xml', 'product_view.xml',
@@ -47,7 +37,7 @@ Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com> for
'country_view.xml', 'country_view.xml',
'tax_view.xml', 'tax_view.xml',
'company_view.xml', 'company_view.xml',
'intrastat_menu.xml', 'intrastat_view.xml',
], ],
'demo': ['intrastat_demo.xml'], 'demo': ['intrastat_demo.xml'],
'installable': True, 'installable': True,

View File

@@ -16,7 +16,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<notebook> <notebook>
<page position="inside" string="Intrastat Settings"> <page position="inside" string="Intrastat Settings">
<group name="intrastat-common" string="Common Intrastat Settings"> <group name="intrastat-common" string="Intrastat Settings">
<field name="intrastat_remind_user_ids" widget="many2many_tags" /> <field name="intrastat_remind_user_ids" widget="many2many_tags" />
</group> </group>
</page> </page>

View File

@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Report intrastat base module for Odoo # Intrastat base module for Odoo
# Copyright (C) 2011-2014 Akretion (http://www.akretion.com). # Copyright (C) 2011-2014 Akretion (http://www.akretion.com).
# @author Alexis de Lattre <alexis.delattre@akretion.com> # @author Alexis de Lattre <alexis.delattre@akretion.com>
# #

View File

@@ -1,14 +1,14 @@
# Translation of OpenERP Server. # Translation of Odoo Server.
# This file contains the translation of the following modules: # This file contains the translation of the following modules:
# * intrastat_base # * intrastat_base
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n" "Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-04-14 14:18+0000\n" "POT-Creation-Date: 2015-05-27 18:43+0000\n"
"PO-Revision-Date: 2014-04-14 14:18+0000\n" "PO-Revision-Date: 2015-05-27 18:43+0000\n"
"Last-Translator: Alexis de Lattre <alexis.delattre@akretion.com>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\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." 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 #. 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" msgid "Common Intrastat Settings"
msgstr "Paramètres communs DEB et DES" msgstr "Paramètres communs DEB et DES"
#. module: intrastat_base #. module: intrastat_base
#: model:ir.model,name:intrastat_base.model_report_intrastat_common #: 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 "Fonctions communes pour la DEB et la DES" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: model:ir.model,name:intrastat_base.model_res_company #: model:ir.model,name:intrastat_base.model_res_company
msgid "Companies" msgid "Companies"
msgstr "Sociétés" 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 #. module: intrastat_base
#: model:ir.model,name:intrastat_base.model_res_country #: model:ir.model,name:intrastat_base.model_res_country
msgid "Country" msgid "Country"
msgstr "Pays" msgstr "Pays"
#. module: intrastat_base #. module: intrastat_base
#: view:res.country:0 #: view:res.country:intrastat_base.view_country_search
#: field:res.country,intrastat:0 #: field:res.country,intrastat:0
msgid "EU Country" msgid "EU Country"
msgstr "Pays UE" 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 #. module: intrastat_base
#: field:product.template,exclude_from_intrastat:0 #: field:product.template,exclude_from_intrastat:0
msgid "Exclude from Intrastat reports" 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" 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" 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 #. module: intrastat_base
#: help:product.template,exclude_from_intrastat:0 #: 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." 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." 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 #. module: intrastat_base
#: view:product.product:0 #: view:product.template:intrastat_base.product_template_form_view
#: view:product.template:0
msgid "Intrastat Properties" msgid "Intrastat Properties"
msgstr "Propriétés DEB/DES" msgstr "Propriétés DEB/DES"
#. module: intrastat_base
#: view:res.company:0
msgid "Intrastat Settings"
msgstr "Configuration DEB/DES"
#. module: intrastat_base #. module: intrastat_base
#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root
msgid "Intrastat Reporting" msgid "Intrastat Reporting"
msgstr "DEB et DES" 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 #. module: intrastat_base
#: field:product.template,is_accessory_cost:0 #: field:product.template,is_accessory_cost:0
msgid "Is accessory cost" 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." msgstr "Liste d'utilisateurs OpenERP qui recevront le rappel pour la DEB et/ou la DES."
#. module: intrastat_base #. module: intrastat_base
#: field:res.company,intrastat_email_list:0 #: code:addons/intrastat_base/company.py:55
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 #, python-format
msgid "Missing e-mail address on user '%s'." msgid "Missing e-mail address on user '%s'."
msgstr "Adresse e-mail manquante sur l'utilisateur '%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 #. module: intrastat_base
#: model:ir.model,name:intrastat_base.model_product_template #: model:ir.model,name:intrastat_base.model_product_template
msgid "Product Template" msgid "Product Template"
msgstr "Modèle d'article" msgstr "Modèle d'article"
#. module: intrastat_base #. module: intrastat_base
#: view:res.country:0 #: view:res.country:intrastat_base.view_country_search
msgid "Search Countries" msgid "Search Countries"
msgstr "Recherche des pays" msgstr "Recherche des pays"
@@ -150,42 +140,43 @@ msgid "Tax"
msgstr "Taxes" msgstr "Taxes"
#. module: intrastat_base #. module: intrastat_base
#: code:addons/intrastat_base/intrastat_common.py:91 #: code:addons/intrastat_base/intrastat_common.py:84
#, python-format #, python-format
msgid "The VAT number is not set for the partner '%s'." 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'." msgstr "Le numéro de TVA n'est pas renseigné pour le partenaire '%s'."
#. module: intrastat_base #. module: intrastat_base
#: code:addons/intrastat_base/intrastat_common.py:83 #: code:addons/intrastat_base/intrastat_common.py:76
#, python-format #, python-format
msgid "The company currency must be 'EUR', but is currently '%s'." 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'." msgstr "La monnaie de la société doit être 'EUR', mais est actuellement '%s'."
#. module: intrastat_base #. module: intrastat_base
#: code:addons/intrastat_base/intrastat_common.py:78 #: code:addons/intrastat_base/intrastat_common.py:72
#, python-format #, python-format
msgid "The country is not set on the company '%s'." msgid "The country is not set on the company '%s'."
msgstr "Le pays n'est pas renseigné sur la société '%s'." msgstr "Le pays n'est pas renseigné sur la société '%s'."
#. module: intrastat_base #. module: intrastat_base
#: code:addons/intrastat_base/intrastat_common.py:111 #: code:addons/intrastat_base/intrastat_common.py:105
#, python-format #, 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." 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." 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 #. module: intrastat_base
#: code:addons/intrastat_base/product.py:56 #: code:addons/intrastat_base/product.py:51
#, python-format #, 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 "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'" 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 #. module: intrastat_base
#: field:res.company,intrastat_remind_user_ids:0 #: field:res.company,intrastat_remind_user_ids:0
msgid "Users Receiving the Intrastat Reminder" msgid "Users Receiving the Intrastat Reminder"
msgstr "Utilisateurs qui reçoivent le rappel DEB/DES" 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"

View File

@@ -1,13 +1,13 @@
# Translation of OpenERP Server. # Translation of Odoo Server.
# This file contains the translation of the following modules: # This file contains the translation of the following modules:
# * intrastat_base # * intrastat_base
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n" "Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-04-14 14:18+0000\n" "POT-Creation-Date: 2015-05-27 18:43+0000\n"
"PO-Revision-Date: 2014-04-14 14:18+0000\n" "PO-Revision-Date: 2015-05-27 18:43+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@@ -21,13 +21,19 @@ msgid "Activate this option for shipping costs, packaging costs and all services
msgstr "" msgstr ""
#. module: intrastat_base #. 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" msgid "Common Intrastat Settings"
msgstr "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: model:ir.model,name:intrastat_base.model_report_intrastat_common #: 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 "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
@@ -35,33 +41,23 @@ msgstr ""
msgid "Companies" msgid "Companies"
msgstr "" 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 #. module: intrastat_base
#: model:ir.model,name:intrastat_base.model_res_country #: model:ir.model,name:intrastat_base.model_res_country
msgid "Country" msgid "Country"
msgstr "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: view:res.country:0 #: view:res.country:intrastat_base.view_country_search
#: field:res.country,intrastat:0 #: field:res.country,intrastat:0
msgid "EU Country" msgid "EU Country"
msgstr "" 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 #. module: intrastat_base
#: field:product.template,exclude_from_intrastat:0 #: field:product.template,exclude_from_intrastat:0
msgid "Exclude from Intrastat reports" msgid "Exclude from Intrastat reports"
@@ -72,6 +68,11 @@ msgstr ""
msgid "Exclude invoice line from intrastat if this tax is present" msgid "Exclude invoice line from intrastat if this tax is present"
msgstr "" msgstr ""
#. module: intrastat_base
#: field:report.intrastat.common,id:0
msgid "ID"
msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: help:product.template,exclude_from_intrastat:0 #: 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." 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 "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: view:product.product:0 #: view:product.template:intrastat_base.product_template_form_view
#: view:product.template:0
msgid "Intrastat Properties" msgid "Intrastat Properties"
msgstr "" msgstr ""
#. module: intrastat_base
#: view:res.company:0
msgid "Intrastat Settings"
msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root #: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root
msgid "Intrastat Reporting" msgid "Intrastat Reporting"
msgstr "" msgstr ""
#. module: intrastat_base
#: view:res.company:intrastat_base.view_company_form
msgid "Intrastat Settings"
msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: field:product.template,is_accessory_cost:0 #: field:product.template,is_accessory_cost:0
msgid "Is accessory cost" msgid "Is accessory cost"
@@ -109,28 +109,18 @@ msgid "List of OpenERP users who will receive a notification to remind them abou
msgstr "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: field:res.company,intrastat_email_list:0 #: code:addons/intrastat_base/company.py:55
msgid "List of emails of Users Receiving the Intrastat Reminder"
msgstr ""
#. module: intrastat_base
#: code:addons/intrastat_base/company.py:59
#, python-format #, python-format
msgid "Missing e-mail address on user '%s'." msgid "Missing e-mail address on user '%s'."
msgstr "" msgstr ""
#. module: intrastat_base
#: model:ir.model,name:intrastat_base.model_res_partner
msgid "Partner"
msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: model:ir.model,name:intrastat_base.model_product_template #: model:ir.model,name:intrastat_base.model_product_template
msgid "Product Template" msgid "Product Template"
msgstr "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: view:res.country:0 #: view:res.country:intrastat_base.view_country_search
msgid "Search Countries" msgid "Search Countries"
msgstr "" msgstr ""
@@ -150,42 +140,43 @@ msgid "Tax"
msgstr "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: code:addons/intrastat_base/intrastat_common.py:91 #: code:addons/intrastat_base/intrastat_common.py:84
#, python-format #, python-format
msgid "The VAT number is not set for the partner '%s'." msgid "The VAT number is not set for the partner '%s'."
msgstr "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: code:addons/intrastat_base/intrastat_common.py:83 #: code:addons/intrastat_base/intrastat_common.py:76
#, python-format #, python-format
msgid "The company currency must be 'EUR', but is currently '%s'." msgid "The company currency must be 'EUR', but is currently '%s'."
msgstr "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: code:addons/intrastat_base/intrastat_common.py:78 #: code:addons/intrastat_base/intrastat_common.py:72
#, python-format #, python-format
msgid "The country is not set on the company '%s'." msgid "The country is not set on the company '%s'."
msgstr "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: code:addons/intrastat_base/intrastat_common.py:111 #: code:addons/intrastat_base/intrastat_common.py:105
#, python-format #, 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." 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 "" msgstr ""
#. module: intrastat_base #. module: intrastat_base
#: code:addons/intrastat_base/product.py:56 #: code:addons/intrastat_base/product.py:51
#, python-format #, 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 "" 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 #. module: intrastat_base
#: field:res.company,intrastat_remind_user_ids:0 #: field:res.company,intrastat_remind_user_ids:0
msgid "Users Receiving the Intrastat Reminder" msgid "Users Receiving the Intrastat Reminder"
msgstr "" msgstr ""
#. module: intrastat_base
#: constraint:res.company:0
msgid "error msg in raise"
msgstr ""

View File

@@ -1,8 +1,8 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Report intrastat base module for OpenERP # Intrastat base module for Odoo
# Copyright (C) 2010-2013 Akretion (http://www.akretion.com/). # Copyright (C) 2010-2014 Akretion (http://www.akretion.com/).
# @author Alexis de Lattre <alexis.delattre@akretion.com> # @author Alexis de Lattre <alexis.delattre@akretion.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
@@ -20,91 +20,72 @@
# #
############################################################################## ##############################################################################
from openerp.osv import orm from openerp import models, fields, api, tools, _
from openerp.tools.translate import _ from openerp.exceptions import Warning, ValidationError
from openerp import tools
from datetime import datetime
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class report_intrastat_common(orm.TransientModel): class IntrastatCommon(models.AbstractModel):
_name = "report.intrastat.common" _name = "intrastat.common"
_description = "Common functions for intrastat reports for products " _description = "Common functions for intrastat reports for products "
"and services" "and services"
def _compute_numbers(self, cr, uid, ids, object, context=None): @api.one
result = {} @api.depends('declaration_line_ids.amount_company_currency')
for intrastat in object.browse(cr, uid, ids, context=context): def _compute_numbers(self):
total_amount = 0.0 total_amount = 0.0
num_lines = 0 num_lines = 0
for line in intrastat.intrastat_line_ids: for line in self.declaration_line_ids:
total_amount += line.amount_company_currency total_amount += line.amount_company_currency
num_lines += 1 num_lines += 1
result[intrastat.id] = { self.num_decl_lines = num_lines
'num_lines': num_lines, self.total_amount = total_amount
'total_amount': total_amount,
}
return result
def _compute_dates(self, cr, uid, ids, object, context=None): @api.one
result = {} @api.depends('start_date')
for intrastat in object.browse(cr, uid, ids, context=context): def _compute_dates(self):
start_date_datetime = datetime.strptime( start_date_dt = fields.Date.from_string(self.start_date)
intrastat.start_date, '%Y-%m-%d') self.end_date = fields.Date.to_string(
end_date_str = datetime.strftime( start_date_dt + relativedelta(day=31))
start_date_datetime + relativedelta(day=31), '%Y-%m-%d') self.year_month = start_date_dt.strftime('%Y-%m')
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): @api.one
def _check_start_date(self):
'''Check that the start date is the first day of the month''' '''Check that the start date is the first day of the month'''
for date_to_check in object.read( datetime_to_check = fields.Date.from_string(self.start_date)
cr, uid, ids, ['start_date'], context=context): if datetime_to_check.day != 1:
datetime_to_check = datetime.strptime( raise ValidationError(
date_to_check['start_date'], '%Y-%m-%d') _('The start date must be the first day of the month'))
if datetime_to_check.day != 1:
return False
return True
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.""" """Check wether all requirements are met for generating lines."""
if not intrastat.company_id: if not self.company_id:
# Should not be possible, but just in case: raise Warning(_("Company not yet set on intrastat report."))
raise orm.except_orm( company_obj = self.company_id
_('Error :'),
_("Company not yet set on intrastat report.")
)
company_obj = intrastat.company_id # Simplify references
if not company_obj.country_id: if not company_obj.country_id:
raise orm.except_orm( raise Warning(
_('Error :'),
_("The country is not set on the company '%s'.") _("The country is not set on the company '%s'.")
% company_obj.name % company_obj.name)
) if company_obj.currency_id.name != 'EUR':
if not company_obj.currency_id.name == 'EUR': raise Warning(
raise orm.except_orm(
_('Error :'),
_("The company currency must be 'EUR', but is currently '%s'.") _("The company currency must be 'EUR', but is currently '%s'.")
% company_obj.currency_id.name % company_obj.currency_id.name)
)
return True return True
def _check_generate_xml(self, cr, uid, intrastat, context=None): @api.one
if not intrastat.company_id.partner_id.vat: def _check_generate_xml(self):
raise orm.except_orm( if not self.company_id.partner_id.vat:
_('Error :'), raise Warning(
_("The VAT number is not set for the partner '%s'.") _("The VAT number is not set for the partner '%s'.")
% intrastat.company_id.partner_id.name) % self.company_id.partner_id.name)
return True return True
def _check_xml_schema( @api.model
self, cr, uid, xml_root, xml_string, xsd_file, context=None): def _check_xml_schema(self, xml_root, xml_string, xsd_file):
'''Validate the XML file against the XSD''' '''Validate the XML file against the XSD'''
from lxml import etree from lxml import etree
xsd_etree_obj = etree.parse( xsd_etree_obj = etree.parse(
@@ -114,13 +95,12 @@ class report_intrastat_common(orm.TransientModel):
official_schema.assertValid(xml_root) official_schema.assertValid(xml_root)
except Exception, e: except Exception, e:
# if the validation of the XSD fails, we arrive here # if the validation of the XSD fails, we arrive here
_logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
_logger.warning( logger.warning(
"The XML file is invalid against the XML Schema Definition") "The XML file is invalid against the XML Schema Definition")
_logger.warning(xml_string) logger.warning(xml_string)
_logger.warning(e) logger.warning(e)
raise orm.except_orm( raise Warning(
_('Error :'),
_("The generated XML file is not valid against the official " _("The generated XML file is not valid against the official "
"XML Schema Definition. The generated XML file and the " "XML Schema Definition. The generated XML file and the "
"full error have been written in the server logs. " "full error have been written in the server logs. "
@@ -129,39 +109,29 @@ class report_intrastat_common(orm.TransientModel):
% str(e)) % str(e))
return True return True
def _attach_xml_file( @api.multi
self, cr, uid, ids, object, xml_string, start_date_datetime, def _attach_xml_file(self, xml_string, declaration_name):
declaration_name, context=None): '''Attach the XML file to the report_intrastat_product/service
'''Attach the XML file to the report_intrastat_product/service ''' object'''
'''object''' self.ensure_one()
import base64 import base64
assert len(ids) == 1, "Only one ID accepted" filename = '%s_%s.xml' % (self.year_month, declaration_name)
filename = '%s_%s.xml' % ( attach = self.env['ir.attachment'].create({
datetime.strftime(start_date_datetime, '%Y-%m'), 'name': filename,
declaration_name) 'res_id': self.id,
if not context: 'res_model': self._name,
context = {} 'datas': base64.encodestring(xml_string),
context.update({ 'datas_fname': filename})
'default_res_id': ids[0], return attach.id
'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( @api.model
self, cr, uid, attach_id, title='XML file', context=None): def _open_attach_view(self, attach_id, title='XML file'):
'''Returns an action which opens the form view of the ''' '''Returns an action which opens the form view of the
'''corresponding attachement''' corresponding attachement'''
action = { action = {
'name': title, 'name': title,
'view_type': 'form', 'view_type': 'form',
'view_mode': 'form,tree', 'view_mode': 'form',
'view_id': False,
'res_model': 'ir.attachment', 'res_model': 'ir.attachment',
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'nodestroy': True, 'nodestroy': True,
@@ -170,30 +140,36 @@ class report_intrastat_common(orm.TransientModel):
} }
return action return action
def partner_on_change(self, cr, uid, ids, partner_id=False, context=None): @api.one
result = {} def send_reminder_email(self, mail_template_xmlid):
result['value'] = {} mail_template = self.env.ref(mail_template_xmlid)
if partner_id: if self.company_id.intrastat_remind_user_ids:
company = self.pool['res.partner'].read( mail_template.send_mail(self.id)
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)
logger.info( logger.info(
'Intrastat Reminder email has been sent (XMLID: %s).' 'Intrastat Reminder email has been sent (XMLID: %s).'
% template_xmlid) % mail_template_xmlid)
else: else:
logger.warning( logger.warning(
'The list of users receiving the Intrastat Reminder is empty ' 'The list of users receiving the Intrastat Reminder is empty '
'on company %s' % company.name) 'on company %s' % self.company_id.name)
return True 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'))

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2011-2014 Akretion (http://www.akretion.com/)
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<!-- Menu entry for Intrastat -->
<menuitem id="menu_intrastat_base_root" name="Intrastat Reporting" parent="account.menu_finance_legal_statement" />
</data>
</openerp>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2011-2015 Akretion (http://www.akretion.com/)
Copyright (C) 2015 Noviat (http://www.noviat.com/)
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<!-- Menu entries for Intrastat -->
<menuitem id="menu_intrastat_base_root"
name="Intrastat Reporting"
parent="account.menu_finance_legal_statement"/>
<menuitem id="menu_intrastat_config_root" name="Intrastat"
parent="account.menu_finance_configuration" sequence="50"/>
<record id="intrastat_result_view" model="ir.ui.view">
<field name="name">intrastat.result_view_form</field>
<field name="model">intrastat.result.view</field>
<field name="arch" type="xml">
<form string="Intrastat Result View">
<group name="main">
<field name="note" nolabel="1"/>
</group>
<footer>
<button string="Ok" class="oe_highlight" special="cancel"/>
</footer>
</form>
</field>
</record>
</data>
</openerp>

View File

@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Report intrastat base module for OpenERP # Intrastat base module for Odoo
# Copyright (C) 2010-2014 Akretion (http://www.akretion.com/) # Copyright (C) 2010-2014 Akretion (http://www.akretion.com/)
# @author Alexis de Lattre <alexis.delattre@akretion.com> # @author Alexis de Lattre <alexis.delattre@akretion.com>
# #

View File

@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Report intrastat base module for Odoo # Intrastat base module for Odoo
# Copyright (C) 2011-2014 Akretion (http://www.akretion.com). # Copyright (C) 2011-2014 Akretion (http://www.akretion.com).
# @author Alexis de Lattre <alexis.delattre@akretion.com> # @author Alexis de Lattre <alexis.delattre@akretion.com>
# #