diff --git a/intrastat_product/__openerp__.py b/intrastat_product/__openerp__.py
index 4c3496f..b9576da 100644
--- a/intrastat_product/__openerp__.py
+++ b/intrastat_product/__openerp__.py
@@ -37,6 +37,7 @@
'conflicts': ['report_intrastat'],
'data': [
'views/hs_code.xml',
+ 'views/intrastat_region.xml',
'views/intrastat_unit.xml',
'views/intrastat_transaction.xml',
'views/intrastat_transport_mode.xml',
@@ -44,6 +45,7 @@
'views/res_company.xml',
'views/account_invoice.xml',
'views/stock_picking.xml',
+ 'views/stock_warehouse.xml',
'security/intrastat_security.xml',
'security/ir.model.access.csv',
'data/intrastat_transport_mode.xml',
diff --git a/intrastat_product/models/__init__.py b/intrastat_product/models/__init__.py
index f00785c..66c0d7b 100644
--- a/intrastat_product/models/__init__.py
+++ b/intrastat_product/models/__init__.py
@@ -8,3 +8,4 @@ from . import intrastat_transport_mode
from . import intrastat_unit
from . import res_company
from . import stock_picking
+from . import stock_warehouse
diff --git a/intrastat_product/models/intrastat_product_declaration.py b/intrastat_product/models/intrastat_product_declaration.py
index 3fe3dc4..4dfc52b 100644
--- a/intrastat_product/models/intrastat_product_declaration.py
+++ b/intrastat_product/models/intrastat_product_declaration.py
@@ -520,12 +520,13 @@ class IntrastatProductDeclaration(models.Model):
@api.model
def group_line_hashcode(self, computation_line):
- hashcode = "%s-%s-%s-%s-%s" % (
+ hashcode = "%s-%s-%s-%s-%s-%s" % (
computation_line.src_dest_country_id.id or False,
computation_line.hs_code_id.id or False,
computation_line.intrastat_unit_id.id or False,
computation_line.transaction_id.id or False,
- computation_line.transport_id.id or False
+ computation_line.transport_id.id or False,
+ computation_line.region_id.id or False
)
return hashcode
@@ -717,7 +718,8 @@ class IntrastatProductDeclarationLine(models.Model):
transaction_id = fields.Many2one(
'intrastat.transaction',
string='Intrastat Transaction')
- # extended declaration
+ region_id = fields.Many2one(
+ 'intrastat.region', string='Intrastat Region')
# extended declaration
incoterm_id = fields.Many2one(
'stock.incoterms', string='Incoterm')
diff --git a/intrastat_product/models/stock_warehouse.py b/intrastat_product/models/stock_warehouse.py
new file mode 100644
index 0000000..d766b61
--- /dev/null
+++ b/intrastat_product/models/stock_warehouse.py
@@ -0,0 +1,42 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Odoo, Open Source Management Solution
+#
+# Copyright (c) 2009-2015 Noviat nv/sa (www.noviat.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 .
+#
+##############################################################################
+
+from openerp import models, fields
+
+
+class StockWarehouse(models.Model):
+ _inherit = 'stock.warehouse'
+
+ region_id = fields.Many2one(
+ 'intrastat.region',
+ string='Intrastat region')
+
+ def get_region_from_location(self, location):
+ locations = location.search(
+ [('parent_left', '<=', location.parent_left),
+ ('parent_right', '>=', location.parent_right)])
+ warehouses = self.search(
+ [('lot_stock_id', 'in', [x.id for x in locations]),
+ ('region_id', '!=', False)])
+ if warehouses:
+ return warehouses[0].region_id
+ return None
diff --git a/intrastat_product/security/intrastat_security.xml b/intrastat_product/security/intrastat_security.xml
index cd4f161..e483225 100644
--- a/intrastat_product/security/intrastat_security.xml
+++ b/intrastat_product/security/intrastat_security.xml
@@ -8,5 +8,11 @@
['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]
+
+ Intrastat Region Company rule
+
+ ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]
+
+
diff --git a/intrastat_product/security/ir.model.access.csv b/intrastat_product/security/ir.model.access.csv
index bd6835f..4b06ab2 100644
--- a/intrastat_product/security/ir.model.access.csv
+++ b/intrastat_product/security/ir.model.access.csv
@@ -5,6 +5,8 @@ access_intrastat_transaction_read,Read access on Intrastat Transaction Types to
access_intrastat_transaction_full,Full access on Intrastat Transaction Types to Finance manager,model_intrastat_transaction,account.group_account_manager,1,1,1,1
access_intrastat_transport_mode_read,Read access on Intrastat Transport Modes to everybody,model_intrastat_transport_mode,,1,0,0,0
access_intrastat_transport_mode_full,Full access on Intrastat Transport Modes to Finance manager,model_intrastat_transport_mode,account.group_account_manager,1,1,1,1
+access_intrastat_region_read,Read access on Intrastat Regions,model_intrastat_region,,1,0,0,0
+access_intrastat_region_full,Full access on Intrastat Regions,model_intrastat_region,account.group_account_manager,1,1,1,1
access_intrastat_product_declaration,Full access on Intrastat Product Declarations to Accountant,model_intrastat_product_declaration,account.group_account_user,1,1,1,1
access_intrastat_product_computation_line,Full access on Intrastat Product Computation Lines to Accountant,model_intrastat_product_computation_line,account.group_account_user,1,1,1,1
access_intrastat_product_declaration_line,Full access on Intrastat Product Declaration Lines to Accountant,model_intrastat_product_declaration_line,account.group_account_user,1,1,1,1
diff --git a/intrastat_product/views/intrastat_product_declaration.xml b/intrastat_product/views/intrastat_product_declaration.xml
index 860c8da..935a158 100644
--- a/intrastat_product/views/intrastat_product_declaration.xml
+++ b/intrastat_product/views/intrastat_product_declaration.xml
@@ -78,6 +78,7 @@
+
+
diff --git a/intrastat_product/views/intrastat_region.xml b/intrastat_product/views/intrastat_region.xml
new file mode 100644
index 0000000..e4580df
--- /dev/null
+++ b/intrastat_product/views/intrastat_region.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+ intrastat.region.form
+ intrastat.region
+
+
+
+
+
+
+ intrastat.region.tree
+ intrastat.region
+
+
+
+
+
+
+
+
+
+
+
+
+ Intrastat Regions
+ intrastat.region
+ tree,form
+
+
+
+
+
+
diff --git a/intrastat_product/views/stock_warehouse.xml b/intrastat_product/views/stock_warehouse.xml
new file mode 100644
index 0000000..775da73
--- /dev/null
+++ b/intrastat_product/views/stock_warehouse.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+ stock.warehouse.form
+ stock.warehouse
+
+
+
+
+
+
+
+
+
+