major update intrastat V3 modules

This commit is contained in:
luc-demeyer
2015-10-20 20:26:19 +02:00
committed by Kumar Aberer
parent 91a59dea05
commit e428d7a9a7
11 changed files with 133 additions and 67 deletions

View File

@@ -1,6 +1,9 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
============================================
Harmonized System Codes (and National Codes)
============================================
@@ -12,11 +15,13 @@ You will also be able to configure the country of origin of a product, which is
This module should be usefull for all companies that export physical goods abroad. This module is also used by the Intrastat modules for the European Union, cf the *intrastat_product* module.
Installation
============
This module is NOT compatible with the *report_intrastat* module from the official addons.
Usage
=====
@@ -24,15 +29,32 @@ To create H.S. codes, go to the menu *Sales > Configuration > Product Categories
Then you will be able to set the H.S. code on an product (under the *Information* tab) or on a product category. On the product form, you will also be able to set the *Country of Origin* of a product (for example, if the product is *made in China*, select *China* as *Country of Origin*).
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/91/8.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/
account-financial-reporting/issues/new?body=module:%20
product_harmonized_system%0Aversion:%20
8.0.0.2%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Author
-------
Contributors
------------
* Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
* Luc De Meyer, Noviat <info@noviat.com>
Maintainer
----------
.. image:: http://odoo-community.org/logo.png

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
from . import hs
from . import product
from . import models

View File

@@ -2,7 +2,7 @@
##############################################################################
#
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2015 Noviat (http://www.noviat.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
@@ -23,7 +23,7 @@
{
'name': 'Product Harmonized System Codes',
'version': '0.1',
'version': '0.2',
'category': 'Reporting',
'license': 'AGPL-3',
'summary': 'Base module for Product Import/Export reports',
@@ -31,11 +31,14 @@
'depends': ['product'],
'conflicts': ['report_intrastat'],
'data': [
'product_view.xml',
'hs_view.xml',
'security/product_hs_security.xml',
'security/ir.model.access.csv',
'views/hs_code.xml',
'views/product_category.xml',
'views/product_template.xml',
],
'demo': [
'demo/product_demo.xml',
],
'demo': ['product_demo.xml'],
'installable': True,
}

View File

@@ -0,0 +1,5 @@
# -*- encoding: utf-8 -*-
from . import hs_code
from . import product_category
from . import product_template

View File

@@ -2,7 +2,7 @@
##############################################################################
#
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2015 Noviat (http://www.noviat.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
@@ -30,23 +30,8 @@ class HSCode(models.Model):
_order = "local_code"
_rec_name = "display_name"
@api.one
@api.depends('local_code')
def _get_hs_code(self):
self.hs_code = self.local_code and self.local_code[:6]
@api.one
@api.depends('local_code', 'description')
def _compute_display_name(self):
display_name = self.local_code
if self.description:
display_name += ' ' + self.description
self.display_name = len(display_name) > 55 \
and display_name[:55] + '...' \
or display_name
hs_code = fields.Char(
string='H.S. Code', compute='_get_hs_code', readonly=True,
string='H.S. Code', compute='_compute_hs_code', readonly=True,
help="Harmonized System code (6 digits). Full list is "
"available from the World Customs Organisation, see "
"http://www.wcoomd.org")
@@ -67,6 +52,21 @@ class HSCode(models.Model):
default=lambda self: self.env['res.company']._company_default_get(
'hs.code'))
@api.one
@api.depends('local_code')
def _compute_hs_code(self):
self.hs_code = self.local_code and self.local_code[:6]
@api.one
@api.depends('local_code', 'description')
def _compute_display_name(self):
display_name = self.local_code
if self.description:
display_name += ' ' + self.description
self.display_name = len(display_name) > 55 \
and display_name[:55] + '...' \
or display_name
_sql_constraints = [
('local_code_company_uniq', 'unique(local_code, company_id)',
'This code already exists for this company !'),

View File

@@ -0,0 +1,46 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api
class ProductCategory(models.Model):
_inherit = "product.category"
hs_code_id = fields.Many2one(
'hs.code', string='H.S. Code',
company_dependent=True, ondelete='restrict',
help="Harmonised System Code. If this code is not "
"set on the product itself, it will be read here, on the "
"related product category.")
@api.multi
def get_hs_code_recursively(self):
self.ensure_one()
if self.hs_code_id:
res = self.hs_code_id
elif self.parent_id:
res = self.parent_id.get_hs_code_recursively()
else:
res = None
return res

View File

@@ -2,7 +2,7 @@
##############################################################################
#
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2015 Noviat (http://www.noviat.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
@@ -49,25 +49,3 @@ class ProductTemplate(models.Model):
else:
res = None
return res
class ProductCategory(models.Model):
_inherit = "product.category"
hs_code_id = fields.Many2one(
'hs.code', string='H.S. Code',
company_dependent=True, ondelete='restrict',
help="Harmonised System Code. If this code is not "
"set on the product itself, it will be read here, on the "
"related product category.")
@api.multi
def get_hs_code_recursively(self):
self.ensure_one()
if self.hs_code_id:
res = self.hs_code_id
elif self.parent_id:
res = self.parent_id.get_hs_code_recursively()
else:
res = None
return res

View File

@@ -10,7 +10,7 @@
<data>
<!-- Search view for H.S. code -->
<record id="hs_code_search" model="ir.ui.view">
<record id="hs_code_view_search" model="ir.ui.view">
<field name="name">hs.code.search</field>
<field name="model">hs.code</field>
<field name="arch" type="xml">
@@ -22,7 +22,7 @@
</record>
<!-- Tree view for H.S. code -->
<record id="hs_code_tree" model="ir.ui.view">
<record id="hs_code_view_tree" model="ir.ui.view">
<field name="name">hs.code.tree</field>
<field name="model">hs.code</field>
<field name="arch" type="xml">
@@ -36,7 +36,7 @@
</record>
<!-- Form view for H.S. code -->
<record id="hs_code_form" model="ir.ui.view">
<record id="hs_code_view_form" model="ir.ui.view">
<field name="name">hs.code.form</field>
<field name="model">hs.code</field>
<field name="arch" type="xml">

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010-2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<!-- Product category form view -->
<record id="product_category_form_view" model="ir.ui.view">
<field name="name">hs_code.product.category.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 name="hs_code" string="Import/Export Properties" colspan="2">
<field name="hs_code_id"/>
</group>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@@ -22,19 +22,5 @@
</field>
</record>
<!-- Product category form view -->
<record id="product_category_form_view" model="ir.ui.view">
<field name="name">hs_code.product.category.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 name="hs_code" string="Import/Export Properties" colspan="2">
<field name="hs_code_id"/>
</group>
</xpath>
</field>
</record>
</data>
</openerp>