[ADD] l10n_be_intrastat: Belgian Intrastat report

Closes #2247
This commit is contained in:
Nicolas Seinlet 2014-09-08 13:22:20 +02:00 committed by Olivier Dony
parent 4af53de399
commit 35b3836276
19 changed files with 151673 additions and 0 deletions

View File

@ -0,0 +1,24 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Business Applications
# Copyright (C) 2014-2015 Odoo S.A. <http://www.odoo.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 l10n_be_intrastat
import wizard

View File

@ -0,0 +1,43 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Business Applications
# Copyright (C) 2014-2015 Odoo S.A. <http://www.odoo.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': 'Belgian Intrastat Declaration',
'version': '1.0',
'category': 'Reporting',
'description': """
Generates Intrastat XML report for declaration
Based on invoices.
""",
'author': 'Odoo SA',
'depends': ['report_intrastat', 'sale_stock', 'account_accountant', 'l10n_be'],
'data': [
'data/regions.xml',
'data/report.intrastat.code.csv',
'data/transaction.codes.xml',
'data/transport.modes.xml',
'security/groups.xml',
'security/ir.model.access.csv',
'l10n_be_intrastat.xml',
'wizard/l10n_be_intrastat_xml_view.xml',
],
'installable': True,
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="l10n_be_intrastat.intrastat_region_1" model="l10n_be_intrastat.region">
<field name="code">1</field>
<field name="name">Flemish region</field>
<field name="country_id" ref="base.be"/>
<field name="description">Includes Antwerp, Flemish Brabant, West Flanders, East Flanders and Limburg provinces</field>
</record>
<record id="l10n_be_intrastat.intrastat_region_2" model="l10n_be_intrastat.region">
<field name="code">2</field>
<field name="name">Walloon region</field>
<field name="country_id" ref="base.be"/>
<field name="description">Includes Walloon Brabant, Hainaut, Liège, Luxembourg and Namur provinces</field>
</record>
<record id="l10n_be_intrastat.intrastat_region_3" model="l10n_be_intrastat.region">
<field name="code">3</field>
<field name="name">Brussels region</field>
<field name="country_id" ref="base.be"/>
<field name="description">Includes 19 districts</field>
</record>
</data>
</openerp>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="l10n_be_intrastat.intrastat_transaction_1" model="l10n_be_intrastat.transaction">
<field name="code">1</field>
<field name="description">Transactions involving an actual or intended transfer of ownership from residents to non-residents against financial or other compensation (except the transactions listed under 2, 7 and 8)</field>
</record>
<record id="l10n_be_intrastat.intrastat_transaction_2" model="l10n_be_intrastat.transaction">
<field name="code">2</field>
<field name="description">Return and replacement of goods free of charge after registration of the original transaction</field>
</record>
<record id="l10n_be_intrastat.intrastat_transaction_3" model="l10n_be_intrastat.transaction">
<field name="code">3</field>
<field name="description">Transactions involving transfer of ownership without financial or in kind compensation (e.g. aid shipments)</field>
</record>
<record id="l10n_be_intrastat.intrastat_transaction_4" model="l10n_be_intrastat.transaction">
<field name="code">4</field>
<field name="description">Operations with a view to processing 1 under contract (no transfer of ownership to the processor)</field>
</record>
<record id="l10n_be_intrastat.intrastat_transaction_5" model="l10n_be_intrastat.transaction">
<field name="code">5</field>
<field name="description">Operations following processing under contract (no transfer of ownership to the processor)</field>
</record>
<record id="l10n_be_intrastat.intrastat_transaction_6" model="l10n_be_intrastat.transaction">
<field name="code">6</field>
<field name="description">Operations "following" repair or maintenance, other than under joint inter-governmental production programmes. Repair and maintenance can be against payment or free of charge. These operations do not involve a (future) transfer of ownership*.</field>
</record>
<record id="l10n_be_intrastat.intrastat_transaction_7" model="l10n_be_intrastat.transaction">
<field name="code">7</field>
<field name="description">Operations under joint defence projects or other joint intergovernmental production programmes</field>
</record>
<record id="l10n_be_intrastat.intrastat_transaction_8" model="l10n_be_intrastat.transaction">
<field name="code">8</field>
<field name="description">Transactions involving the supply of building materials and technical equipment under a general construction or civil engineering contract for which no separate invoicing of the goods is required and an invoice for the total contract is issued</field>
</record>
<record id="l10n_be_intrastat.intrastat_transaction_9" model="l10n_be_intrastat.transaction">
<field name="code">9</field>
<field name="description">Other transactions which cannot be classified under other codes</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="l10n_be_intrastat.intrastat_trmode_1" model="l10n_be_intrastat.transport_mode">
<field name="code">1</field>
<field name="name">Sea transport (including wagons, motor vehicles, trailers, semi-trailers and lighters on board of a ship)</field>
</record>
<record id="l10n_be_intrastat.intrastat_trmode_2" model="l10n_be_intrastat.transport_mode">
<field name="code">2</field>
<field name="name">Railway transport (including lorries on railway wagons)</field>
</record>
<record id="l10n_be_intrastat.intrastat_trmode_3" model="l10n_be_intrastat.transport_mode">
<field name="code">3</field>
<field name="name">Road transport</field>
</record>
<record id="l10n_be_intrastat.intrastat_trmode_4" model="l10n_be_intrastat.transport_mode">
<field name="code">4</field>
<field name="name">Air transport</field>
</record>
<record id="l10n_be_intrastat.intrastat_trmode_5" model="l10n_be_intrastat.transport_mode">
<field name="code">5</field>
<field name="name">Postal consignments</field>
</record>
<record id="l10n_be_intrastat.intrastat_trmode_7" model="l10n_be_intrastat.transport_mode">
<field name="code">7</field>
<field name="name">Fixed transport installations (e.g. pipelines, high-tension cables)</field>
</record>
<record id="l10n_be_intrastat.intrastat_trmode_8" model="l10n_be_intrastat.transport_mode">
<field name="code">8</field>
<field name="name">Inland waterway transport</field>
</record>
<record id="l10n_be_intrastat.intrastat_trmode_9" model="l10n_be_intrastat.transport_mode">
<field name="code">9</field>
<field name="name">Own propulsion (imported or exported means of transport crossing the border under their own power, e.g. aircraft, lorries, boats, etc.)</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,67 @@
Intrastat Module
++++++++++++++++
This module can generate legal electronic reports for intrastat declaration
1 Security groups
*****************
There's two security groups, a standard and an extended, that can be used to view/hide fields linked to the intrastat declaration. The extended group is mainly here to hide the two useless fields if you don't have to send an extended declaration, "Means of transport" and "Incoterm".
2 Intrastat codes
*****************
The system must be able to associate an intrastat code to each product exported. The system can do this in different ways.
Each product can have a category, and each category can have a parent category. To retrieve the intrastat code associated to a product, the system search in this order :
#. check if product have an intrastat code
#. if not, check if product's category have an intrastat code
#. if not, check parent category if it have an intrastat code
#. if not, check parent category of parent category if it have an intrastat code (and so on)
#. if none found, an error is shown
So, in a user point of view, to easily record your intrastat codes, you can procede on the low-level categories, and then, for the product in a category with a wrong code for this item, set the intrastat code in the product form
3 Country of destination
************************
Intrastat declares all movements from an EU member country to another. In an invoice, a zone called "intrastat country" is used to determine the destination of goods. If this field is empty, the invoiced partner's country is used.
==============
Direct invoice
==============
If you create an invoice directly, the intrastat country is empty by default, and the invoiced partner's country is used. If the country of destination is different from the country of invoice, simply fill in the field "Intrastat country".
=======================
Invoice from sale order
=======================
If you create an invoice from a sale order, there are two cases. If you're not using different addresses for invoicing and delivery, the country of the partner is used to fill in the "Intrastat country" of the invoice
If you're using different addresses, the country of delivery address is used, if there's none, the country of the partner's address, and if none, the country of invoice address.
=====================
Invoice from purchase
=====================
If you create an invoice from a purchase order, the "Intrastat country" field is filled with the partner address.
4 Regions, Type of transaction
******************************
In the intrastat declaration the system must fill an information regarding the region of origin of products, and an information regarding the type of transaction.
======
Region
======
The region of origin of products is determined by using two parameters. If your invoice is linked to a sale order or to a purchase order, the system go to the order, check if the order is linked to a warehouse, and check the warehouse region.
If the system hasn't find a region, the system goes to the company, and check the region of the company. If there's none, an error message is generated.
===================
Type of transaction
===================
Intrastat define a list of transactions types. To determine the type of transaction for a particular invoice, the system check if a transaction type is selected in the invoice. If not, the type 1 is selected by default.

View File

@ -0,0 +1,454 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_be_intrastat
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-02-03 18:32+0000\n"
"PO-Revision-Date: 2015-02-03 18:32+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: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "April"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat_xml.xml_decl,arrivals:0
msgid "Arrivals"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "August"
msgstr ""
#. module: l10n_be_intrastat
#: model:l10n_be_intrastat.region,name:l10n_be_intrastat.intrastat_region_3
msgid "Brussels region"
msgstr ""
#. module: l10n_be_intrastat
#: view:l10n_be_intrastat_xml.xml_decl:l10n_be_intrastat.view_intrastat_declaration_xml
msgid "Cancel"
msgstr ""
#. module: l10n_be_intrastat
#: view:l10n_be_intrastat_xml.xml_decl:l10n_be_intrastat.view_intrastat_declaration_xml
msgid "Close"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat.region,code:0
#: field:l10n_be_intrastat.transaction,code:0
#: field:l10n_be_intrastat.transport_mode,code:0
msgid "Code"
msgstr ""
#. module: l10n_be_intrastat
#: sql_constraint:l10n_be_intrastat.region:0
#: sql_constraint:l10n_be_intrastat.transaction:0
#: sql_constraint:l10n_be_intrastat.transport_mode:0
msgid "Code must be unique."
msgstr ""
#. module: l10n_be_intrastat
#: model:ir.model,name:l10n_be_intrastat.model_res_company
msgid "Companies"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat_xml.xml_decl,tax_code_id:0
msgid "Company Tax Chart"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat.region,country_id:0
msgid "Country"
msgstr ""
#. module: l10n_be_intrastat
#: view:l10n_be_intrastat_xml.xml_decl:l10n_be_intrastat.view_intrastat_declaration_xml
msgid "Create XML"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat.region,create_uid:0
#: field:l10n_be_intrastat.transaction,create_uid:0
#: field:l10n_be_intrastat.transport_mode,create_uid:0
#: field:l10n_be_intrastat_xml.xml_decl,create_uid:0
msgid "Created by"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat.region,create_date:0
#: field:l10n_be_intrastat.transaction,create_date:0
#: field:l10n_be_intrastat.transport_mode,create_date:0
#: field:l10n_be_intrastat_xml.xml_decl,create_date:0
msgid "Created on"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "December"
msgstr ""
#. module: l10n_be_intrastat
#: field:res.company,incoterm_id:0
msgid "Default incoterm for Intrastat"
msgstr ""
#. module: l10n_be_intrastat
#: field:res.company,transport_mode_id:0
msgid "Default transport mode"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat.region,description:0
#: field:l10n_be_intrastat.transaction,description:0
#: field:l10n_be_intrastat.transport_mode,name:0
msgid "Description"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat_xml.xml_decl,dispatches:0
msgid "Dispatches"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,state:0
msgid "Download"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,state:0
msgid "Draft"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,arrivals:0
#: selection:l10n_be_intrastat_xml.xml_decl,dispatches:0
msgid "Exempt"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,arrivals:0
#: selection:l10n_be_intrastat_xml.xml_decl,dispatches:0
msgid "Extended"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "February"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat_xml.xml_decl,name:0
msgid "File Name"
msgstr ""
#. module: l10n_be_intrastat
#: model:l10n_be_intrastat.region,name:l10n_be_intrastat.intrastat_region_1
msgid "Flemish region"
msgstr ""
#. module: l10n_be_intrastat
#: code:addons/l10n_be_intrastat/wizard/xml_decl.py:96
#, python-format
msgid "Go to company configuration screen"
msgstr ""
#. module: l10n_be_intrastat
#: view:l10n_be_intrastat_xml.xml_decl:l10n_be_intrastat.view_intrastat_declaration_xml
msgid "Here is the XML file with your intrastat declaration:"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat.region,id:0
#: field:l10n_be_intrastat.transaction,id:0
#: field:l10n_be_intrastat.transport_mode,id:0
#: field:l10n_be_intrastat_xml.xml_decl,id:0
msgid "ID"
msgstr ""
#. module: l10n_be_intrastat
#: field:account.invoice,incoterm_id:0
msgid "Incoterm"
msgstr ""
#. module: l10n_be_intrastat
#: help:account.invoice,incoterm_id:0
#: help:res.company,incoterm_id:0
msgid "International Commercial Terms are a series of predefined commercial terms used in international transactions."
msgstr ""
#. module: l10n_be_intrastat
#: view:product.category:l10n_be_intrastat.l10n_be_intrastat_xml_decl_product_category_view
msgid "Intrastat"
msgstr ""
#. module: l10n_be_intrastat
#: field:product.category,intrastat_id:0
msgid "Intrastat Code"
msgstr ""
#. module: l10n_be_intrastat
#: field:account.invoice,intrastat_country_id:0
msgid "Intrastat Country"
msgstr ""
#. module: l10n_be_intrastat
#: model:ir.actions.act_window,name:l10n_be_intrastat.action_intrastat_xml_declaration
#: model:ir.ui.menu,name:l10n_be_intrastat.l10n_be_intrastat_xml_declaration
#: view:l10n_be_intrastat_xml.xml_decl:l10n_be_intrastat.view_intrastat_declaration_xml
msgid "Intrastat Declaration"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat_xml.xml_decl,file_save:0
msgid "Intrastat Report File"
msgstr ""
#. module: l10n_be_intrastat
#: field:account.invoice,intrastat_transaction_id:0
msgid "Intrastat Transaction Type"
msgstr ""
#. module: l10n_be_intrastat
#: field:account.invoice,transport_mode_id:0
msgid "Intrastat Transport Mode"
msgstr ""
#. module: l10n_be_intrastat
#: model:ir.model,name:l10n_be_intrastat.model_l10n_be_intrastat_xml_xml_decl
msgid "Intrastat XML Declaration"
msgstr ""
#. module: l10n_be_intrastat
#: model:ir.model,name:l10n_be_intrastat.model_report_intrastat_code
msgid "Intrastat code"
msgstr ""
#. module: l10n_be_intrastat
#: help:account.invoice,intrastat_country_id:0
msgid "Intrastat country, delivery for sales, origin for purchases"
msgstr ""
#. module: l10n_be_intrastat
#: model:res.groups,name:l10n_be_intrastat.intrastat_extended
msgid "Intrastat extended"
msgstr ""
#. module: l10n_be_intrastat
#: help:account.invoice,intrastat_transaction_id:0
msgid "Intrastat nature of transaction"
msgstr ""
#. module: l10n_be_intrastat
#: field:res.company,region_id:0
#: field:stock.warehouse,region_id:0
msgid "Intrastat region"
msgstr ""
#. module: l10n_be_intrastat
#: view:l10n_be_intrastat.transaction:l10n_be_intrastat.intra_view_transaction_form
msgid "Intrastat transaction form"
msgstr ""
#. module: l10n_be_intrastat
#: view:l10n_be_intrastat.transaction:l10n_be_intrastat.intra_view_transaction_tree
msgid "Intrastat transaction types"
msgstr ""
#. module: l10n_be_intrastat
#: view:l10n_be_intrastat.transport_mode:l10n_be_intrastat.intra_view_transport_mode_form
msgid "Intrastat transportation mode form"
msgstr ""
#. module: l10n_be_intrastat
#: view:l10n_be_intrastat.transport_mode:l10n_be_intrastat.intra_view_transport_mode_tree
msgid "Intrastat transportation modes"
msgstr ""
#. module: l10n_be_intrastat
#: model:ir.model,name:l10n_be_intrastat.model_account_invoice
msgid "Invoice"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "January"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "July"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "June"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat.region,write_uid:0
#: field:l10n_be_intrastat.transaction,write_uid:0
#: field:l10n_be_intrastat.transport_mode,write_uid:0
#: field:l10n_be_intrastat_xml.xml_decl,write_uid:0
msgid "Last Updated by"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat.region,write_date:0
#: field:l10n_be_intrastat.transaction,write_date:0
#: field:l10n_be_intrastat.transport_mode,write_date:0
#: field:l10n_be_intrastat_xml.xml_decl,write_date:0
msgid "Last Updated on"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "March"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "May"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat_xml.xml_decl,month:0
msgid "Month"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat.region,name:0
msgid "Name"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "November"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "October"
msgstr ""
#. module: l10n_be_intrastat
#: model:ir.model,name:l10n_be_intrastat.model_product_product
msgid "Product"
msgstr ""
#. module: l10n_be_intrastat
#: code:addons/l10n_be_intrastat/wizard/xml_decl.py:291
#, python-format
msgid "Product \"%s\" has no intrastat code, please configure it"
msgstr ""
#. module: l10n_be_intrastat
#: model:ir.model,name:l10n_be_intrastat.model_product_category
msgid "Product Category"
msgstr ""
#. module: l10n_be_intrastat
#: model:ir.model,name:l10n_be_intrastat.model_purchase_order
msgid "Purchase Order"
msgstr ""
#. module: l10n_be_intrastat
#: model:ir.model,name:l10n_be_intrastat.model_sale_order
msgid "Sales Order"
msgstr ""
#. module: l10n_be_intrastat
#: code:addons/l10n_be_intrastat/wizard/xml_decl.py:156
#, python-format
msgid "Save"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,month:0
msgid "September"
msgstr ""
#. module: l10n_be_intrastat
#: selection:l10n_be_intrastat_xml.xml_decl,arrivals:0
#: selection:l10n_be_intrastat_xml.xml_decl,dispatches:0
msgid "Standard"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat_xml.xml_decl,state:0
msgid "State"
msgstr ""
#. module: l10n_be_intrastat
#: code:addons/l10n_be_intrastat/wizard/xml_decl.py:280
#, python-format
msgid "The Intrastat Region of the selected company is not set, please make sure to configure it first."
msgstr ""
#. module: l10n_be_intrastat
#: code:addons/l10n_be_intrastat/wizard/xml_decl.py:109
#, python-format
msgid "The country of your company is not set, please make sure to configure it first."
msgstr ""
#. module: l10n_be_intrastat
#: code:addons/l10n_be_intrastat/wizard/xml_decl.py:316
#, python-format
msgid "The default Incoterm of your company is not set, please make sure to configure it first."
msgstr ""
#. module: l10n_be_intrastat
#: code:addons/l10n_be_intrastat/wizard/xml_decl.py:304
#, python-format
msgid "The default Intrastat transport mode of your company is not set, please make sure to configure it first."
msgstr ""
#. module: l10n_be_intrastat
#: code:addons/l10n_be_intrastat/wizard/xml_decl.py:116
#, python-format
msgid "The registry number of your company is not set, please make sure to configure it first."
msgstr ""
#. module: l10n_be_intrastat
#: model:l10n_be_intrastat.region,name:l10n_be_intrastat.intrastat_region_2
msgid "Walloon region"
msgstr ""
#. module: l10n_be_intrastat
#: model:ir.model,name:l10n_be_intrastat.model_stock_warehouse
msgid "Warehouse"
msgstr ""
#. module: l10n_be_intrastat
#: view:l10n_be_intrastat_xml.xml_decl:l10n_be_intrastat.view_intrastat_declaration_xml
msgid "XML Intratstat Declaration"
msgstr ""
#. module: l10n_be_intrastat
#: field:l10n_be_intrastat_xml.xml_decl,year:0
msgid "Year"
msgstr ""
#. module: l10n_be_intrastat
#: code:addons/l10n_be_intrastat/wizard/xml_decl.py:120
#, python-format
msgid "Year must be 4 digits number (YYYY)"
msgstr ""
#. module: l10n_be_intrastat
#: view:l10n_be_intrastat_xml.xml_decl:l10n_be_intrastat.view_intrastat_declaration_xml
msgid "or"
msgstr ""

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,203 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Business Applications
# Copyright (C) 2014-2015 Odoo S.A. <http://www.odoo.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 openerp.osv import fields, osv
class account_invoice(osv.osv):
_inherit = "account.invoice"
_columns = {
'incoterm_id': fields.many2one(
'stock.incoterms', 'Incoterm',
help="International Commercial Terms are a series of predefined commercial terms "
"used in international transactions."),
'intrastat_transaction_id': fields.many2one(
'l10n_be_intrastat.transaction', 'Intrastat Transaction Type',
help="Intrastat nature of transaction"),
'transport_mode_id': fields.many2one(
'l10n_be_intrastat.transport_mode', 'Intrastat Transport Mode'),
'intrastat_country_id': fields.many2one(
'res.country', 'Intrastat Country',
help='Intrastat country, delivery for sales, origin for purchases',
domain=[('intrastat','=',True)]),
}
class intrastat_region(osv.osv):
_name = 'l10n_be_intrastat.region'
_columns = {
'code': fields.char('Code', required=True),
'country_id': fields.many2one('res.country', 'Country'),
'name': fields.char('Name', translate=True),
'description': fields.char('Description'),
}
_sql_constraints = [
('l10n_be_intrastat_regioncodeunique', 'UNIQUE (code)', 'Code must be unique.'),
]
class intrastat_transaction(osv.osv):
_name = 'l10n_be_intrastat.transaction'
_rec_name = 'code'
_columns = {
'code': fields.char('Code', required=True, readonly=True),
'description': fields.text('Description', readonly=True),
}
_sql_constraints = [
('l10n_be_intrastat_trcodeunique', 'UNIQUE (code)', 'Code must be unique.'),
]
class intrastat_transport_mode(osv.osv):
_name = 'l10n_be_intrastat.transport_mode'
_columns = {
'code': fields.char('Code', required=True, readonly=True),
'name': fields.char('Description', readonly=True),
}
_sql_constraints = [
('l10n_be_intrastat_trmodecodeunique', 'UNIQUE (code)', 'Code must be unique.'),
]
class product_category(osv.osv):
_name = "product.category"
_inherit = "product.category"
_columns = {
'intrastat_id': fields.many2one('report.intrastat.code', 'Intrastat Code'),
}
def get_intrastat_recursively(self, cr, uid, category, context=None):
""" Recursively search in categories to find an intrastat code id
:param category : Browse record of a category
"""
if category.intrastat_id:
res = category.intrastat_id.id
elif category.parent_id:
res = self.get_intrastat_recursively(cr, uid, category.parent_id, context=context)
else:
res = None
return res
class product_product(osv.osv):
_name = "product.product"
_inherit = "product.product"
def get_intrastat_recursively(self, cr, uid, id, context=None):
""" Recursively search in categories to find an intrastat code id
"""
product = self.browse(cr, uid, id, context=context)
if product.intrastat_id:
res = product.intrastat_id.id
elif product.categ_id:
res = self.pool['product.category'].get_intrastat_recursively(
cr, uid, product.categ_id, context=context)
else:
res = None
return res
class purchase_order(osv.osv):
_inherit = "purchase.order"
def _prepare_invoice(self, cr, uid, order, line_ids, context=None):
"""
copy incoterm from purchase order to invoice
"""
invoice = super(purchase_order, self)._prepare_invoice(
cr, uid, order, line_ids, context=context)
if order.incoterm_id:
invoice['incoterm_id'] = order.incoterm_id.id
#Try to determine products origin
if order.partner_id.country_id:
#It comes from supplier
invoice['intrastat_country_id'] = order.partner_id.country_id.id
return invoice
class report_intrastat_code(osv.osv):
_inherit = "report.intrastat.code"
_columns = {
'description': fields.text('Description', translate=True),
}
class res_company(osv.osv):
_inherit = "res.company"
_columns = {
'region_id': fields.many2one('l10n_be_intrastat.region', 'Intrastat region'),
'transport_mode_id': fields.many2one('l10n_be_intrastat.transport_mode',
'Default transport mode'),
'incoterm_id': fields.many2one('stock.incoterms', 'Default incoterm for Intrastat',
help="International Commercial Terms are a series of "
"predefined commercial terms used in international "
"transactions."),
}
class sale_order(osv.osv):
_inherit = "sale.order"
def _prepare_invoice(self, cr, uid, saleorder, lines, context=None):
"""
copy incoterm from sale order to invoice
"""
invoice = super(sale_order, self)._prepare_invoice(
cr, uid, saleorder, lines, context=context)
if saleorder.incoterm:
invoice['incoterm_id'] = saleorder.incoterm.id
# Guess products destination
if saleorder.partner_shipping_id.country_id:
invoice['intrastat_country_id'] = saleorder.partner_shipping_id.country_id.id
elif saleorder.partner_id.country_id:
invoice['intrastat_country_id'] = saleorder.partner_id.country_id.id
elif saleorder.partner_invoice_id.country_id:
invoice['intrastat_country_id'] = saleorder.partner_invoice_id.country_id.id
return invoice
class stock_warehouse(osv.osv):
_inherit = "stock.warehouse"
_columns = {
'region_id': fields.many2one('l10n_be_intrastat.region', 'Intrastat region'),
}
def get_regionid_from_locationid(self, cr, uid, location_id, context=None):
location_model = self.pool['stock.location']
location = location_model.browse(cr, uid, location_id, context=context)
location_ids = location_model.search(cr, uid,
[('parent_left', '<=', location.parent_left),
('parent_right', '>=', location.parent_right)],
context=context)
warehouse_ids = self.search(cr, uid,
[('lot_stock_id', 'in', location_ids),
('region_id', '!=', False)],
context=context)
warehouses = self.browse(cr, uid, warehouse_ids, context=context)
if warehouses and warehouses[0]:
return warehouses[0].region_id.id
return None

View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Customer Invoice Form -->
<record id="l10n_be_intrastat_xml_decl_cust_invoice_view" model="ir.ui.view">
<field name="name">l10n_be_intrastat_xml.custinvoice_form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='date_due']" position="after">
<field name="incoterm_id" groups="l10n_be_intrastat.intrastat_extended"/>
</xpath>
<xpath expr="//field[@name='move_id']" position="after">
<field name="intrastat_transaction_id"/>
<field name="transport_mode_id" groups="l10n_be_intrastat.intrastat_extended"/>
<field name="intrastat_country_id"/>
</xpath>
</field>
</record>
<!-- Transaction Form -->
<record model="ir.ui.view" id="intra_view_transaction_form">
<field name="name">intra.view.transaction_form</field>
<field name="model">l10n_be_intrastat.transaction</field>
<field name="arch" type="xml">
<form string="Intrastat transaction form">
<group>
<field name="code"/>
<field name="description"/>
</group>
</form>
</field>
</record>
<!-- Transaction List -->
<record model="ir.ui.view" id="intra_view_transaction_tree">
<field name="name">intra.view.transaction_tree</field>
<field name="model">l10n_be_intrastat.transaction</field>
<field name="arch" type="xml">
<tree string="Intrastat transaction types">
<field name="code"/>
<field name="description"/>
</tree>
</field>
</record>
<!-- Transport mode Form -->
<record model="ir.ui.view" id="intra_view_transport_mode_form">
<field name="name">intra.view.transport_mode_form</field>
<field name="model">l10n_be_intrastat.transport_mode</field>
<field name="arch" type="xml">
<form string="Intrastat transportation mode form">
<group>
<field name="code"/>
<field name="name"/>
</group>
</form>
</field>
</record>
<!-- Transport mode List -->
<record model="ir.ui.view" id="intra_view_transport_mode_tree">
<field name="name">intra.view.transport_mode_tree</field>
<field name="model">l10n_be_intrastat.transport_mode</field>
<field name="arch" type="xml">
<tree string="Intrastat transportation modes">
<field name="code"/>
<field name="name"/>
</tree>
</field>
</record>
<!-- Category Form -->
<record id="l10n_be_intrastat_xml_decl_product_category_view" model="ir.ui.view">
<field name="name">l10n_be_intrastat_xml.productcategory_form</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='parent']" position="inside">
<group string="Intrastat" colspan="2">
<field name="intrastat_id"/>
</group>
</xpath>
</field>
</record>
<!-- Company -->
<record id="l10n_be_intrastat_xml_decl_res_company_form_view" model="ir.ui.view">
<field name="name">l10n_be_intrastat_xml.rescompany_form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='company_registry']" position="after">
<field name="region_id" domain="[('country_id','=',country_id)]"/>
<field name="transport_mode_id" groups="l10n_be_intrastat.intrastat_extended"/>
<field name="incoterm_id" groups="l10n_be_intrastat.intrastat_extended"/>
</xpath>
</field>
</record>
<!-- Warehouse -->
<record id="l10n_be_intrastat_xml_decl_stock_warehouse_form_view" model="ir.ui.view">
<field name="name">l10n_be_intrastat_xml.stockwarehouse_form</field>
<field name="model">stock.warehouse</field>
<field name="inherit_id" ref="stock.view_warehouse"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="region_id"/>
</xpath>
</field>
</record>
<!-- Supplier Invoice Form -->
<record id="l10n_be_intrastat_xml_decl_supp_invoice_view" model="ir.ui.view">
<field name="name">l10n_be_intrastat_xml.suppinvoice_form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_term']" position="after">
<field name="incoterm_id" groups="l10n_be_intrastat.intrastat_extended"/>
</xpath>
<xpath expr="//field[@name='period_id']" position="after">
<field name="intrastat_transaction_id" />
<field name="transport_mode_id" groups="l10n_be_intrastat.intrastat_extended"/>
<field name="intrastat_country_id" />
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="intrastat_extended" model="res.groups">
<field name="name">Intrastat extended</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,4 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_l10n_be_intrastat_transaction","Intrastat transaction type","model_l10n_be_intrastat_transaction",,1,0,0,0
"access_l10n_be_intrastat_transport_mode","Intrastat transport mode","model_l10n_be_intrastat_transport_mode",,1,0,0,0
"access_l10n_be_intrastat_region","Intrastat regions","model_l10n_be_intrastat_region",,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_l10n_be_intrastat_transaction Intrastat transaction type model_l10n_be_intrastat_transaction 1 0 0 0
3 access_l10n_be_intrastat_transport_mode Intrastat transport mode model_l10n_be_intrastat_transport_mode 1 0 0 0
4 access_l10n_be_intrastat_region Intrastat regions model_l10n_be_intrastat_region 1 0 0 0

View File

@ -0,0 +1,22 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Business Applications
# Copyright (C) 2014-2015 Odoo S.A. <http://www.odoo.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 xml_decl

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_intrastat_declaration_xml" model="ir.ui.view">
<field name="name">Intrastat XML Declaration</field>
<field name="model">l10n_be_intrastat_xml.xml_decl</field>
<field name="arch" type="xml">
<form string="XML Intratstat Declaration">
<!-- Need the field in the view in order to be able to hide or show part of the view according the state -->
<field name="state" invisible="1" />
<field name="name" invisible="1"/>
<group states="draft">
<group>
<field name="month"/>
<field name="year"/>
<field name="tax_code_id"/>
</group>
<group>
<field name="arrivals"/>
<field name="dispatches"/>
</group>
</group>
<div states="download">
<h2>Intrastat Declaration</h2>
<p>Here is the XML file with your intrastat declaration: <field name="file_save" filename="name"/></p>
</div>
<footer>
<group states="draft">
<button name="create_xml" string="Create XML" type="object" default_focus="1" class="oe_highlight" />
or
<button string="Cancel" class="oe_link" special="cancel" />
</group>
<group states="download">
<button string="Close" special="cancel" />
</group>
</footer>
</form>
</field>
</record>
<record id="action_intrastat_xml_declaration" model="ir.actions.act_window">
<field name="name">Intrastat Declaration</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">l10n_be_intrastat_xml.xml_decl</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_intrastat_declaration_xml"/>
<field name="target">new</field>
</record>
<menuitem
name="Intrastat Declaration"
parent="l10n_be.menu_finance_belgian_statement"
action="action_intrastat_xml_declaration"
id="l10n_be_intrastat_xml_declaration"
groups="account.group_account_manager"/>
</data>
</openerp>

View File

@ -0,0 +1,373 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Business Applications
# Copyright (C) 2014-2015 Odoo S.A. <http://www.odoo.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 base64
import xml.etree.ElementTree as ET
from collections import namedtuple
from datetime import datetime
from openerp import exceptions, SUPERUSER_ID, tools
from openerp.osv import fields, osv
from openerp.tools.translate import _
INTRASTAT_XMLNS = 'http://www.onegate.eu/2010-01-01'
class xml_decl(osv.TransientModel):
"""
Intrastat XML Declaration
"""
_name = "l10n_be_intrastat_xml.xml_decl"
_description = 'Intrastat XML Declaration'
def _get_tax_code(self, cr, uid, context=None):
obj_tax_code = self.pool.get('account.tax.code')
obj_user = self.pool.get('res.users')
company_id = obj_user.browse(cr, uid, uid, context=context).company_id.id
tax_code_ids = obj_tax_code.search(cr, uid, [('company_id', '=', company_id),
('parent_id', '=', False)],
context=context)
return tax_code_ids and tax_code_ids[0] or False
def _get_def_monthyear(self, cr, uid, context=None):
td = datetime.strptime(fields.date.context_today(self, cr, uid, context=context),
tools.DEFAULT_SERVER_DATE_FORMAT).date()
return td.strftime('%Y'), td.strftime('%m')
def _get_def_month(self, cr, uid, context=None):
return self._get_def_monthyear(cr, uid, context=context)[1]
def _get_def_year(self, cr, uid, context=None):
return self._get_def_monthyear(cr, uid, context=context)[0]
_columns = {
'name': fields.char('File Name'),
'month': fields.selection([('01','January'), ('02','February'), ('03','March'),
('04','April'), ('05','May'), ('06','June'), ('07','July'),
('08','August'), ('09','September'), ('10','October'),
('11','November'), ('12','December')], 'Month', required=True),
'year': fields.char('Year', size=4, required=True),
'tax_code_id': fields.many2one('account.tax.code', 'Company Tax Chart',
domain=[('parent_id', '=', False)], required=True),
'arrivals': fields.selection([('be-exempt', 'Exempt'),
('be-standard', 'Standard'),
('be-extended', 'Extended')],
'Arrivals', required=True),
'dispatches': fields.selection([('be-exempt', 'Exempt'),
('be-standard', 'Standard'),
('be-extended', 'Extended')],
'Dispatches', required=True),
'file_save': fields.binary('Intrastat Report File', readonly=True),
'state': fields.selection([('draft', 'Draft'), ('download', 'Download')], string="State"),
}
_defaults = {
'arrivals': 'be-standard',
'dispatches': 'be-standard',
'name': 'intrastat.xml',
'tax_code_id': _get_tax_code,
'month': _get_def_month,
'year': _get_def_year,
'state': 'draft',
}
def _company_warning(self, cr, uid, translated_msg, context=None):
""" Raise a error with custom message, asking user to configure company settings """
xmlid_mod = self.pool['ir.model.data']
action_id = xmlid_mod.xmlid_to_res_id(cr, uid, 'base.action_res_company_form')
raise exceptions.RedirectWarning(
translated_msg, action_id, _('Go to company configuration screen'))
def create_xml(self, cr, uid, ids, context=None):
"""Creates xml that is to be exported and sent to estate for partner vat intra.
:return: Value for next action.
:rtype: dict
"""
decl_datas = self.browse(cr, uid, ids[0])
company = decl_datas.tax_code_id.company_id
if not (company.partner_id and company.partner_id.country_id and
company.partner_id.country_id.id):
self._company_warning(
cr, uid,
_('The country of your company is not set, '
'please make sure to configure it first.'),
context=context)
kbo = company.company_registry
if not kbo:
self._company_warning(
cr, uid,
_('The registry number of your company is not set, '
'please make sure to configure it first.'),
context=context)
if len(decl_datas.year) != 4:
raise exceptions.Warning(_('Year must be 4 digits number (YYYY)'))
#Create root declaration
decl = ET.Element('DeclarationReport')
decl.set('xmlns', INTRASTAT_XMLNS)
#Add Administration elements
admin = ET.SubElement(decl, 'Administration')
fromtag = ET.SubElement(admin, 'From')
fromtag.text = kbo
fromtag.set('declarerType', 'KBO')
ET.SubElement(admin, 'To').text = "NBB"
ET.SubElement(admin, 'Domain').text = "SXX"
if decl_datas.arrivals == 'be-standard':
decl.append(self._get_lines(cr, SUPERUSER_ID, ids, decl_datas, company,
dispatchmode=False, extendedmode=False, context=context))
elif decl_datas.arrivals == 'be-extended':
decl.append(self._get_lines(cr, SUPERUSER_ID, ids, decl_datas, company,
dispatchmode=False, extendedmode=True, context=context))
if decl_datas.dispatches == 'be-standard':
decl.append(self._get_lines(cr, SUPERUSER_ID, ids, decl_datas, company,
dispatchmode=True, extendedmode=False, context=context))
elif decl_datas.dispatches == 'be-extended':
decl.append(self._get_lines(cr, SUPERUSER_ID, ids, decl_datas, company,
dispatchmode=True, extendedmode=True, context=context))
#Get xml string with declaration
data_file = ET.tostring(decl, encoding='UTF-8', method='xml')
#change state of the wizard
self.write(cr, uid, ids,
{'name': 'intrastat_%s%s.xml' % (decl_datas.year, decl_datas.month),
'file_save': base64.encodestring(data_file),
'state': 'download'},
context=context)
return {
'name': _('Save'),
'context': context,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'l10n_be_intrastat_xml.xml_decl',
'type': 'ir.actions.act_window',
'target': 'new',
'res_id': ids[0],
}
def _get_lines(self, cr, uid, ids, decl_datas, company, dispatchmode=False,
extendedmode=False, context=None):
intrastatcode_mod = self.pool['report.intrastat.code']
invoiceline_mod = self.pool['account.invoice.line']
product_mod = self.pool['product.product']
region_mod = self.pool['l10n_be_intrastat.region']
warehouse_mod = self.pool['stock.warehouse']
if dispatchmode:
mode1 = 'out_invoice'
mode2 = 'in_refund'
declcode = "29"
else:
mode1 = 'in_invoice'
mode2 = 'out_refund'
declcode = "19"
decl = ET.Element('Report')
if not extendedmode:
decl.set('code', 'EX%sS' % declcode)
else:
decl.set('code', 'EX%sE' % declcode)
decl.set('date', '%s-%s' % (decl_datas.year, decl_datas.month))
datas = ET.SubElement(decl, 'Data')
if not extendedmode:
datas.set('form', 'EXF%sS' % declcode)
else:
datas.set('form', 'EXF%sE' % declcode)
datas.set('close', 'true')
intrastatkey = namedtuple("intrastatkey",
['EXTRF', 'EXCNT', 'EXTTA', 'EXREG',
'EXGO', 'EXTPC', 'EXDELTRM'])
entries = {}
sqlreq = """
select
inv_line.id
from
account_invoice_line inv_line
join account_invoice inv on inv_line.invoice_id=inv.id
left join res_country on res_country.id = inv.intrastat_country_id
left join res_partner on res_partner.id = inv.partner_id
left join res_country countrypartner on countrypartner.id = res_partner.country_id
join product_product on inv_line.product_id=product_product.id
join product_template on product_product.product_tmpl_id=product_template.id
where
inv.state in ('open','paid')
and inv.company_id=%s
and not product_template.type='service'
and (res_country.intrastat=true or (inv.intrastat_country_id is null
and countrypartner.intrastat=true))
and ((res_country.code is not null and not res_country.code=%s)
or (res_country.code is null and countrypartner.code is not null
and not countrypartner.code=%s))
and inv.type in (%s, %s)
and to_char(inv.date_invoice, 'YYYY')=%s
and to_char(inv.date_invoice, 'MM')=%s
"""
cr.execute(sqlreq, (company.id, company.partner_id.country_id.code,
company.partner_id.country_id.code, mode1, mode2,
decl_datas.year, decl_datas.month))
lines = cr.fetchall()
invoicelines_ids = [rec[0] for rec in lines]
invoicelines = invoiceline_mod.browse(cr, uid, invoicelines_ids, context=context)
for inv_line in invoicelines:
#Check type of transaction
if inv_line.invoice_id.intrastat_transaction_id:
extta = inv_line.invoice_id.intrastat_transaction_id.code
else:
extta = "1"
#Check country
if inv_line.invoice_id.intrastat_country_id:
excnt = inv_line.invoice_id.intrastat_country_id.code
else:
excnt = inv_line.invoice_id.partner_id.country_id.code
#Check region
#If purchase, comes from purchase order, linked to a location,
#which is linked to the warehouse
#if sales, the sale order is linked to the warehouse
#if sales, from a delivery order, linked to a location,
#which is linked to the warehouse
#If none found, get the company one.
exreg = None
if inv_line.invoice_id.type in ('in_invoice', 'in_refund'):
#comes from purchase
POL = self.pool['purchase.order.line']
poline_ids = POL.search(
cr, uid, [('invoice_lines', 'in', inv_line.id)], context=context)
if poline_ids:
purchaseorder = POL.browse(cr, uid, poline_ids[0], context=context).order_id
region_id = warehouse_mod.get_regionid_from_locationid(
cr, uid, purchaseorder.location_id.id, context=context)
if region_id:
exreg = region_mod.browse(cr, uid, region_id).code
elif inv_line.invoice_id.type in ('out_invoice', 'out_refund'):
#comes from sales
soline_ids = self.pool['sale.order.line'].search(
cr, uid, [('invoice_lines', 'in', inv_line.id)], context=context)
if soline_ids:
saleorder = self.pool['sale.order.line'].browse(
cr, uid, soline_ids[0], context=context).order_id
if saleorder and saleorder.warehouse_id and saleorder.warehouse_id.region_id:
exreg = region_mod.browse(
cr, uid, saleorder.warehouse_id.region_id.id, context=context).code
if not exreg:
if company.region_id:
exreg = company.region_id.code
else:
self._company_warning(
cr, uid,
_('The Intrastat Region of the selected company is not set, '
'please make sure to configure it first.'),
context=context)
#Check commodity codes
intrastat_id = product_mod.get_intrastat_recursively(
cr, uid, inv_line.product_id.id, context=context)
if intrastat_id:
exgo = intrastatcode_mod.browse(cr, uid, intrastat_id, context=context).name
else:
raise exceptions.Warning(
_('Product "%s" has no intrastat code, please configure it') %
inv_line.product_id.display_name)
#In extended mode, 2 more fields required
if extendedmode:
#Check means of transport
if inv_line.invoice_id.transport_mode_id:
extpc = inv_line.invoice_id.transport_mode_id.code
elif company.transport_mode_id:
extpc = company.transport_mode_id.code
else:
self._company_warning(
cr, uid,
_('The default Intrastat transport mode of your company '
'is not set, please make sure to configure it first.'),
context=context)
#Check incoterm
if inv_line.invoice_id.incoterm_id:
exdeltrm = inv_line.invoice_id.incoterm_id.code
elif company.incoterm_id:
exdeltrm = company.incoterm_id.code
else:
self._company_warning(
cr, uid,
_('The default Incoterm of your company is not set, '
'please make sure to configure it first.'),
context=context)
else:
extpc = ""
exdeltrm = ""
linekey = intrastatkey(EXTRF=declcode, EXCNT=excnt,
EXTTA=extta, EXREG=exreg, EXGO=exgo,
EXTPC=extpc, EXDELTRM=exdeltrm)
#We have the key
#calculate amounts
if inv_line.price_unit and inv_line.quantity:
amount = inv_line.price_unit * inv_line.quantity
else:
amount = 0
if (not inv_line.uos_id.category_id
or not inv_line.product_id.uom_id.category_id
or inv_line.uos_id.category_id.id != inv_line.product_id.uom_id.category_id.id):
weight = inv_line.product_id.weight_net * inv_line.quantity
else:
weight = (inv_line.product_id.weight_net *
inv_line.quantity * inv_line.uos_id.factor)
if (not inv_line.uos_id.category_id or not inv_line.product_id.uom_id.category_id
or inv_line.uos_id.category_id.id != inv_line.product_id.uom_id.category_id.id):
supply_units = inv_line.quantity
else:
supply_units = inv_line.quantity * inv_line.uos_id.factor
amounts = entries.setdefault(linekey, (0, 0, 0))
amounts = (amounts[0] + amount, amounts[1] + weight, amounts[2] + supply_units)
entries[linekey] = amounts
numlgn = 0
for linekey in entries:
numlgn += 1
amounts = entries[linekey]
item = ET.SubElement(datas, 'Item')
self._set_Dim(item, 'EXSEQCODE', unicode(numlgn))
self._set_Dim(item, 'EXTRF', unicode(linekey.EXTRF))
self._set_Dim(item, 'EXCNT', unicode(linekey.EXCNT))
self._set_Dim(item, 'EXTTA', unicode(linekey.EXTTA))
self._set_Dim(item, 'EXREG', unicode(linekey.EXREG))
self._set_Dim(item, 'EXTGO', unicode(linekey.EXGO))
if extendedmode:
self._set_Dim(item, 'EXTPC', unicode(linekey.EXTPC))
self._set_Dim(item, 'EXDELTRM', unicode(linekey.EXDELTRM))
self._set_Dim(item, 'EXTXVAL', unicode(round(amounts[0], 0)).replace(".", ","))
self._set_Dim(item, 'EXWEIGHT', unicode(round(amounts[1], 0)).replace(".", ","))
self._set_Dim(item, 'EXUNITS', unicode(round(amounts[2], 0)).replace(".", ","))
if numlgn == 0:
#no datas
datas.set('action', 'nihil')
return decl
def _set_Dim(self, item, prop, value):
dim = ET.SubElement(item, 'Dim')
dim.set('prop', prop)
dim.text = value

View File

@ -39,6 +39,7 @@ class res_country(osv.osv):
class report_intrastat_code(osv.osv):
_name = "report.intrastat.code"
_description = "Intrastat code"
_translate = False
_columns = {
'name': fields.char('Intrastat Code'),
'description': fields.char('Description'),