[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.
This commit is contained in:
Alexis de Lattre
2011-04-05 00:57:21 +02:00
committed by Alexis de Lattre
parent 6b21a6c01f
commit b5f1d9ac8f
16 changed files with 987 additions and 0 deletions

View File

@@ -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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import country
import product
import tax
import partner_address
import intrastat_common

View File

@@ -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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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 <alexis.delattre@akretion.com> 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,
}

35
intrastat_base/country.py Normal file
View File

@@ -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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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()

View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="base.fr" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.de" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.at" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.cy" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.dk" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.es" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.ee" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.fi" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.gr" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.hu" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.ie" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.it" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.lv" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.lt" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.lu" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.mt" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.nl" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.pl" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.pt" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.sk" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.cz" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.uk" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.si" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.se" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.ro" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.bg" model="res.country">
<field name="intrastat" eval="True"/>
</record>
<record id="base.be" model="res.country">
<field name="intrastat" eval="True"/>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>)
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<!-- Add intrastat field on res_country -->
<record id="intrastat_base_country_tree" model="ir.ui.view">
<field name="name">intrastat.base.country.tree</field>
<field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_tree" />
<field name="arch" type="xml">
<field name="code" position="after">
<field name="intrastat" />
</field>
</field>
</record>
<record id="intrastat_base_country_form" model="ir.ui.view">
<field name="name">intrastat.base.country.form</field>
<field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_form" />
<field name="arch" type="xml">
<field name="code" position="after">
<field name="intrastat" select="1" />
</field>
</field>
</record>
</data>
</openerp>

View File

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

View File

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

View File

@@ -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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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()

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2011 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data noupdate="1">
<record id="base.main_partner" model="res.partner">
<field name="vat">FR58441019213</field>
</record>
<record id="base.res_partner_6" model="res.partner"> <!-- Elec Import -->
<field name="vat">BE0828696437</field>
<field name="supplier">True</field>
</record>
<record id="base.res_partner_5" model="res.partner"> <!-- Ecole de Commerce de Liege -->
<field name="vat">BE0443167858</field>
<field name="supplier">True</field>
</record>
<record id="base.res_partner_agrolait" model="res.partner">
<field name="vat">BE0884025633</field>
<field name="supplier">True</field>
</record>
<record id="account.sales_journal" model="account.journal">
<field name="update_posted">True</field>
</record>
<record id="account.refund_sales_journal" model="account.journal">
<field name="update_posted">True</field>
</record>
<record id="account.expenses_journal" model="account.journal">
<field name="update_posted">True</field>
</record>
<record id="account.refund_expenses_journal" model="account.journal">
<field name="update_posted">True</field>
</record>
<record id="shipping_costs_exclude" model="product.product">
<field name="name">Shipping costs</field>
<field name="code">SHIP</field>
<field name="type">service</field>
<field name="categ_id" ref="product.product_category_services"/>
<field name="list_price">30</field>
<field name="is_accessory_cost">True</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2011 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,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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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()

49
intrastat_base/product.py Normal file
View File

@@ -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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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()

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010-2011 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<!-- Add field on product.product view -->
<record id="intrastat_base_product_normal_form" model="ir.ui.view">
<field name="name">intrastat.base.product.normal.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="account.product_normal_form_view" />
<field name="arch" type="xml">
<data>
<field name="property_account_expense" position="after">
<separator string="Intrastat properties" colspan="4"/>
<group colspan="4">
<field name="exclude_from_intrastat" />
</group>
</field>
<field name="purchase_ok" position="after">
<field name="is_accessory_cost" />
</field>
</data>
</field>
</record>
<!-- Same on product.template view -->
<record id="intrastat_base_product_template_form" model="ir.ui.view">
<field name="name">intrastat.base.product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="account.product_template_form_view"/>
<field name="arch" type="xml">
<data>
<field name="property_account_expense" position="after">
<separator string="Intrastat properties" colspan="4"/>
<group colspan="4">
<field name="exclude_from_intrastat" />
</group>
</field>
<field name="purchase_ok" position="after">
<field name="is_accessory_cost" />
</field>
</data>
</field>
</record>
</data>
</openerp>

View File

@@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_report_intrastat_common Read access on report.intrastat.common model_report_intrastat_common base.group_user 1 0 0 0

33
intrastat_base/tax.py Normal file
View File

@@ -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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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()

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2011 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<!-- Add 'exclude_from_intrastat_if_present' on tax form view -->
<record id="intrastat_base_tax" model="ir.ui.view">
<field name="name">intrastat.base.tax</field>
<field name="model">account.tax</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.view_tax_form"/>
<field name="arch" type="xml">
<data>
<field name="type_tax_use" position="after">
<field name="exclude_from_intrastat_if_present" />
</field>
</data>
</field>
</record>
</data>
</openerp>