mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
9.0 mig product harmonized system (#7)
* Backport from 10.0 to 9.0: import odoo to import openerp, <odoo> to <openerp>, bring back <data> if noupdate=1, rename __manifest__.py to __openerp__.py, downgrade version number to 9.0.1.0.0, and make module installable. * Re-add H.S.codes menu item under Sales-Product-Configuration. (it had been removed to remove the reference to product module, but I don't understand that decision since this module by nature depends on product module anyway) * Added module tests. * flake8 * Encoding lines at the beginning of python files
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
{
|
||||
'name': 'Product Harmonized System Codes',
|
||||
'version': '10.0.1.0.0',
|
||||
'version': '9.0.1.0.0',
|
||||
'category': 'Reporting',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Base module for Product Import/Export reports',
|
||||
@@ -24,5 +24,5 @@
|
||||
'demo': [
|
||||
'demo/product_demo.xml',
|
||||
],
|
||||
'installable': False,
|
||||
'installable': True,
|
||||
}
|
||||
@@ -5,8 +5,8 @@
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo noupdate="1">
|
||||
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="84715000" model="hs.code">
|
||||
<field name="local_code">84715000</field>
|
||||
@@ -77,5 +77,5 @@
|
||||
<field name="weight">3.3</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# @author Luc de Meyer <info@noviat.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class HSCode(models.Model):
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# @author Luc de Meyer <info@noviat.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class ProductCategory(models.Model):
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# @author Luc de Meyer <info@noviat.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
<openerp noupdate="1">
|
||||
<data>
|
||||
|
||||
<record id="hs_code_company_rule" model="ir.rule">
|
||||
<field name="name">HS Code Company rule</field>
|
||||
@@ -7,4 +8,5 @@
|
||||
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
3
product_harmonized_system/tests/__init__.py
Normal file
3
product_harmonized_system/tests/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_hs
|
||||
44
product_harmonized_system/tests/test_hs.py
Normal file
44
product_harmonized_system/tests/test_hs.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestHs(TransactionCase):
|
||||
"""Tests for unit of measure conversion"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestHs, self).setUp()
|
||||
self.hs_code = self.env['hs.code']
|
||||
|
||||
def test_10_all_functionality(self):
|
||||
# Create HS code
|
||||
code1 = self.hs_code.create({
|
||||
'local_code': 'TEST 6789'
|
||||
})
|
||||
# - Test whether code is correctly de-spaced and truncated
|
||||
self.assertEquals(code1.hs_code, 'TEST67')
|
||||
|
||||
# For the category 'Saleable':
|
||||
category1 = self.env.ref('product.product_category_1')
|
||||
# - Set HS code on it
|
||||
category1.hs_code_id = code1
|
||||
|
||||
# For the demo category 'Software' (child of Saleable):
|
||||
category2 = self.env.ref('product.product_category_4')
|
||||
# - Test if the HS code is null
|
||||
self.assertFalse(category2.hs_code_id)
|
||||
# - Test if the recursive HS code is the one we set on Saleable
|
||||
self.assertEquals(category2.get_hs_code_recursively(), code1)
|
||||
|
||||
# For the product 'Windows 7 Professional' (category Software)
|
||||
product1 = self.env.ref('product.product_product_40')
|
||||
# - Test if the HS code is null
|
||||
self.assertFalse(product1.hs_code_id)
|
||||
# - Test if the recursive HS code is the one we set on Saleable
|
||||
self.assertEquals(
|
||||
product1.product_tmpl_id.get_hs_code_recursively(),
|
||||
code1)
|
||||
# - Set HS code on it
|
||||
product1.hs_code_id = code1
|
||||
# - Set country to 'us'
|
||||
product1.origin_country_id = self.env.ref('base.us')
|
||||
@@ -5,7 +5,7 @@
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
<openerp>
|
||||
|
||||
<!-- Search view for H.S. code -->
|
||||
<record id="hs_code_view_search" model="ir.ui.view">
|
||||
@@ -64,9 +64,7 @@
|
||||
</record>
|
||||
|
||||
<!-- Menu entry for H.S. code -->
|
||||
<!-- TODO: find a way to put a menu entry without depending on another module ?
|
||||
<menuitem id="hs_code_menu" action="hs_code_action"
|
||||
parent="product.prod_config_main" sequence="60"/>
|
||||
-->
|
||||
|
||||
</odoo>
|
||||
</openerp>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
<openerp>
|
||||
|
||||
<!-- Product category form view -->
|
||||
<record id="product_category_form_view" model="ir.ui.view">
|
||||
@@ -21,4 +21,4 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
</openerp>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
<openerp>
|
||||
|
||||
<!-- product.template form view -->
|
||||
<record id="product_template_form_view" model="ir.ui.view">
|
||||
@@ -20,4 +20,4 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user