From 1b106718f472e3b16e8c7f09ea26f729617f671c Mon Sep 17 00:00:00 2001 From: kiplangatdan Date: Wed, 30 Nov 2016 14:12:34 +0300 Subject: [PATCH 1/7] Ported from odoo10 to odoo9, tests added --- intrastat_base/__openerp__.py | 28 +++++++++++++++ intrastat_base/demo/intrastat_demo.xml | 8 +++-- intrastat_base/models/account_tax.py | 2 +- intrastat_base/models/intrastat_common.py | 4 +-- intrastat_base/models/product_template.py | 4 +-- intrastat_base/models/res_company.py | 5 ++- intrastat_base/models/res_country.py | 2 +- intrastat_base/tests/__init__.py | 25 +++++++++++++ intrastat_base/tests/intrastat_base_tests.py | 38 ++++++++++++++++++++ intrastat_base/views/account_tax.xml | 5 ++- intrastat_base/views/intrastat.xml | 6 ++-- intrastat_base/views/product_template.xml | 4 +-- intrastat_base/views/res_company.xml | 4 +-- intrastat_base/views/res_country.xml | 4 +-- intrastat_base/views/res_partner.xml | 4 +-- 15 files changed, 117 insertions(+), 26 deletions(-) create mode 100644 intrastat_base/__openerp__.py create mode 100644 intrastat_base/tests/__init__.py create mode 100644 intrastat_base/tests/intrastat_base_tests.py diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py new file mode 100644 index 0000000..8d2c791 --- /dev/null +++ b/intrastat_base/__openerp__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# © 2011-2016 Akretion (http://www.akretion.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Intrastat Reporting Base', + 'version': '9.0.1.0.0', + 'category': 'Intrastat', + 'license': 'AGPL-3', + 'summary': 'Base module for Intrastat reporting', + 'author': 'Akretion,Odoo Community Association (OCA)', + 'website': 'http://www.akretion.com', + 'depends': ['base_vat'], + 'conflicts': ['report_intrastat'], + 'data': [ + 'data/country_data.xml', + 'views/product_template.xml', + 'views/res_partner.xml', + 'views/res_country.xml', + 'views/account_tax.xml', + 'views/res_company.xml', + 'views/intrastat.xml', + ], + 'demo': [ + 'demo/intrastat_demo.xml', + ], + 'installable': True, +} diff --git a/intrastat_base/demo/intrastat_demo.xml b/intrastat_base/demo/intrastat_demo.xml index f53d397..8834d34 100644 --- a/intrastat_base/demo/intrastat_demo.xml +++ b/intrastat_base/demo/intrastat_demo.xml @@ -4,7 +4,9 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - + + + FR58441019213 @@ -23,5 +25,7 @@ 30 True + + + - diff --git a/intrastat_base/models/account_tax.py b/intrastat_base/models/account_tax.py index f9997fc..41d7285 100644 --- a/intrastat_base/models/account_tax.py +++ b/intrastat_base/models/account_tax.py @@ -2,7 +2,7 @@ # © 2011-2016 Akretion (http://www.akretion.com). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields +from openerp import models, fields class AccountTax(models.Model): diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py index de3b04b..b32c9c8 100644 --- a/intrastat_base/models/intrastat_common.py +++ b/intrastat_base/models/intrastat_common.py @@ -2,8 +2,8 @@ # © 2010-2016 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api, tools, _ -from odoo.exceptions import UserError +from openerp import models, fields, api, tools, _ +from openerp.exceptions import UserError import logging logger = logging.getLogger(__name__) diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py index 71cb987..9a4ef20 100644 --- a/intrastat_base/models/product_template.py +++ b/intrastat_base/models/product_template.py @@ -2,8 +2,8 @@ # © 2010-2016 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api, _ -from odoo.exceptions import ValidationError +from openerp import models, fields, api, _ +from openerp.exceptions import ValidationError class ProductTemplate(models.Model): diff --git a/intrastat_base/models/res_company.py b/intrastat_base/models/res_company.py index bec99ac..dc3d435 100644 --- a/intrastat_base/models/res_company.py +++ b/intrastat_base/models/res_company.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- # © 2013-2016 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models, fields, api, _ -from odoo.exceptions import ValidationError +from openerp import models, fields, api, _ +from openerp.exceptions import ValidationError class ResCompany(models.Model): diff --git a/intrastat_base/models/res_country.py b/intrastat_base/models/res_country.py index 19f34f2..b949538 100644 --- a/intrastat_base/models/res_country.py +++ b/intrastat_base/models/res_country.py @@ -2,7 +2,7 @@ # © 2011-2014 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields +from openerp import models, fields class ResCountry(models.Model): diff --git a/intrastat_base/tests/__init__.py b/intrastat_base/tests/__init__.py new file mode 100644 index 0000000..1f8b6fc --- /dev/null +++ b/intrastat_base/tests/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module created 2014 by Sunflower IT (). +# Sponsored by FreshFilter BV (). +# +# 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 . import intrastat_base_tests + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/intrastat_base/tests/intrastat_base_tests.py b/intrastat_base/tests/intrastat_base_tests.py new file mode 100644 index 0000000..80a8d55 --- /dev/null +++ b/intrastat_base/tests/intrastat_base_tests.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +from openerp.tests.common import TransactionCase + +class TestIntrastatBase(TransactionCase): + """Tests for this module""" + + def setUp(self): + super(TestIntrastatBase, self).setUp() + self.tax_intrastat = self.env["account.tax"] + + def test_10_countries(self): + # check if only EU countries have the 'intrastat' bit set + france = self.env.ref('base.fr') + self.assertTrue(france.intrastat) + brazil = self.env.ref('base.br') + self.assertFalse(brazil.intrastat) + + def test_20_company(self): + # add 'Demo user' to intrastat_remind_user_ids + demo_user = self.env.ref('base.user_demo') + demo_company = self.env.ref('base.main_company') + demo_company.write({ + 'intrastat_remind_user_ids': [(6, False, [demo_user.id])] + }) + # then check if intrastat_email_list contains the email of the user + self.assertEquals(demo_company.intrastat_email_list, demo_user.email) + + def test_taxes_accessory_cost(self): + #Test if exclude_from_intrastat_if_present is false + accessory = self.env['account.tax'].search([('id', '=', 1)]) + for item in accessory: + self.assertFalse(item.exclude_from_intrastat_if_present) + + + + + diff --git a/intrastat_base/views/account_tax.xml b/intrastat_base/views/account_tax.xml index a1e72cd..e0d7f61 100644 --- a/intrastat_base/views/account_tax.xml +++ b/intrastat_base/views/account_tax.xml @@ -4,7 +4,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - + @@ -17,5 +17,4 @@ - - + diff --git a/intrastat_base/views/intrastat.xml b/intrastat_base/views/intrastat.xml index b7cd9d6..040274e 100644 --- a/intrastat_base/views/intrastat.xml +++ b/intrastat_base/views/intrastat.xml @@ -4,8 +4,7 @@ © 2015-2016 Noviat (http://www.noviat.com/) License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - - + - - + diff --git a/intrastat_base/views/product_template.xml b/intrastat_base/views/product_template.xml index 6440407..aa67f55 100644 --- a/intrastat_base/views/product_template.xml +++ b/intrastat_base/views/product_template.xml @@ -4,7 +4,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - + @@ -25,4 +25,4 @@ - + diff --git a/intrastat_base/views/res_company.xml b/intrastat_base/views/res_company.xml index c3d1f30..972099c 100644 --- a/intrastat_base/views/res_company.xml +++ b/intrastat_base/views/res_company.xml @@ -4,7 +4,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - + @@ -23,4 +23,4 @@ - + diff --git a/intrastat_base/views/res_country.xml b/intrastat_base/views/res_country.xml index e9dec05..de0cc65 100644 --- a/intrastat_base/views/res_country.xml +++ b/intrastat_base/views/res_country.xml @@ -4,7 +4,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - + @@ -45,4 +45,4 @@ - + diff --git a/intrastat_base/views/res_partner.xml b/intrastat_base/views/res_partner.xml index 7a9dfeb..8623d33 100644 --- a/intrastat_base/views/res_partner.xml +++ b/intrastat_base/views/res_partner.xml @@ -5,7 +5,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - + @@ -22,4 +22,4 @@ - + From ac98769d6935def69320f9bcb7ce39870c2797f5 Mon Sep 17 00:00:00 2001 From: kiplangatdan Date: Wed, 30 Nov 2016 15:03:13 +0300 Subject: [PATCH 2/7] Ported from odoo10 to odoo9 --- intrastat_base/tests/intrastat_base_tests.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/intrastat_base/tests/intrastat_base_tests.py b/intrastat_base/tests/intrastat_base_tests.py index 80a8d55..e8a0c62 100644 --- a/intrastat_base/tests/intrastat_base_tests.py +++ b/intrastat_base/tests/intrastat_base_tests.py @@ -26,11 +26,6 @@ class TestIntrastatBase(TransactionCase): # then check if intrastat_email_list contains the email of the user self.assertEquals(demo_company.intrastat_email_list, demo_user.email) - def test_taxes_accessory_cost(self): - #Test if exclude_from_intrastat_if_present is false - accessory = self.env['account.tax'].search([('id', '=', 1)]) - for item in accessory: - self.assertFalse(item.exclude_from_intrastat_if_present) From 75f135d24672ae5cf85f28cad922bdff050848c3 Mon Sep 17 00:00:00 2001 From: kiplangatdan Date: Wed, 30 Nov 2016 18:16:28 +0300 Subject: [PATCH 3/7] Ported from odoo10 to odoo9 --- intrastat_base/data/country_data.xml | 7 ++++--- intrastat_base/tests/intrastat_base_tests.py | 21 +++++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/intrastat_base/data/country_data.xml b/intrastat_base/data/country_data.xml index 3c75a3a..f4f526d 100644 --- a/intrastat_base/data/country_data.xml +++ b/intrastat_base/data/country_data.xml @@ -1,5 +1,6 @@ - + + @@ -85,5 +86,5 @@ - - + + diff --git a/intrastat_base/tests/intrastat_base_tests.py b/intrastat_base/tests/intrastat_base_tests.py index e8a0c62..861007a 100644 --- a/intrastat_base/tests/intrastat_base_tests.py +++ b/intrastat_base/tests/intrastat_base_tests.py @@ -7,7 +7,7 @@ class TestIntrastatBase(TransactionCase): def setUp(self): super(TestIntrastatBase, self).setUp() - self.tax_intrastat = self.env["account.tax"] + def test_10_countries(self): # check if only EU countries have the 'intrastat' bit set @@ -15,6 +15,10 @@ class TestIntrastatBase(TransactionCase): self.assertTrue(france.intrastat) brazil = self.env.ref('base.br') self.assertFalse(brazil.intrastat) + denmark = self.env.ref('base.dk') + self.assertTrue(denmark.intrastat) + kenya = self.env.ref('base.ke') + self.assertFalse(kenya.intrastat) def test_20_company(self): # add 'Demo user' to intrastat_remind_user_ids @@ -27,6 +31,21 @@ class TestIntrastatBase(TransactionCase): self.assertEquals(demo_company.intrastat_email_list, demo_user.email) + def test_exclude_intrastat(self): + # Test if exclude_from_intrastat_if_present is false + exclude_tax = self.env['account.tax'].search([('id', '=', 1)]) + for item in exclude_tax: + self.assertFalse(item.exclude_from_intrastat_if_present) + + def test_accessory_cost(self): + accessory_cost = self.env['product.product'].search([('id', '=', 1)]) + for test in accessory_cost: + self.assertFalse(test.is_accessory_cost) + + + + + From 7c31f90738121b40326e6f048a13fbeb2514a37a Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 2 Dec 2016 16:23:59 +0100 Subject: [PATCH 4/7] Move Intrastat menu one level up from PDF reports --- intrastat_base/views/intrastat.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intrastat_base/views/intrastat.xml b/intrastat_base/views/intrastat.xml index 040274e..d814fa5 100644 --- a/intrastat_base/views/intrastat.xml +++ b/intrastat_base/views/intrastat.xml @@ -9,7 +9,7 @@ + parent="account.menu_finance_reports"/> From f118f19a9872e413cd11862eae33daec04b70d5f Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 2 Dec 2016 17:33:04 +0100 Subject: [PATCH 5/7] Remove not very useful tests --- intrastat_base/tests/intrastat_base_tests.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/intrastat_base/tests/intrastat_base_tests.py b/intrastat_base/tests/intrastat_base_tests.py index 861007a..778b427 100644 --- a/intrastat_base/tests/intrastat_base_tests.py +++ b/intrastat_base/tests/intrastat_base_tests.py @@ -8,13 +8,8 @@ class TestIntrastatBase(TransactionCase): def setUp(self): super(TestIntrastatBase, self).setUp() - def test_10_countries(self): # check if only EU countries have the 'intrastat' bit set - france = self.env.ref('base.fr') - self.assertTrue(france.intrastat) - brazil = self.env.ref('base.br') - self.assertFalse(brazil.intrastat) denmark = self.env.ref('base.dk') self.assertTrue(denmark.intrastat) kenya = self.env.ref('base.ke') @@ -31,19 +26,6 @@ class TestIntrastatBase(TransactionCase): self.assertEquals(demo_company.intrastat_email_list, demo_user.email) - def test_exclude_intrastat(self): - # Test if exclude_from_intrastat_if_present is false - exclude_tax = self.env['account.tax'].search([('id', '=', 1)]) - for item in exclude_tax: - self.assertFalse(item.exclude_from_intrastat_if_present) - - def test_accessory_cost(self): - accessory_cost = self.env['product.product'].search([('id', '=', 1)]) - for test in accessory_cost: - self.assertFalse(test.is_accessory_cost) - - - From c0e57a569a9b003d5b4653c491f263addad2c989 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 2 Dec 2016 19:30:06 +0100 Subject: [PATCH 6/7] remove noop --- intrastat_base/tests/intrastat_base_tests.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/intrastat_base/tests/intrastat_base_tests.py b/intrastat_base/tests/intrastat_base_tests.py index 778b427..7787c28 100644 --- a/intrastat_base/tests/intrastat_base_tests.py +++ b/intrastat_base/tests/intrastat_base_tests.py @@ -5,9 +5,6 @@ from openerp.tests.common import TransactionCase class TestIntrastatBase(TransactionCase): """Tests for this module""" - def setUp(self): - super(TestIntrastatBase, self).setUp() - def test_10_countries(self): # check if only EU countries have the 'intrastat' bit set denmark = self.env.ref('base.dk') From f002abfda93ec4bfc898aaa76305a6b235b9d856 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 6 Dec 2016 17:36:27 +0100 Subject: [PATCH 7/7] Review --- intrastat_base/README.rst | 1 + intrastat_base/__init__.py | 1 + intrastat_base/data/country_data.xml | 7 +++--- intrastat_base/tests/__init__.py | 24 ++------------------ intrastat_base/tests/intrastat_base_tests.py | 10 ++------ 5 files changed, 9 insertions(+), 34 deletions(-) diff --git a/intrastat_base/README.rst b/intrastat_base/README.rst index 65531ec..09c5424 100644 --- a/intrastat_base/README.rst +++ b/intrastat_base/README.rst @@ -62,6 +62,7 @@ Contributors * Alexis de Lattre, Akretion * Luc De Meyer, Noviat +* Tom Blauwendraat, Sunflower IT Maintainer ---------- diff --git a/intrastat_base/__init__.py b/intrastat_base/__init__.py index a0fdc10..cde864b 100644 --- a/intrastat_base/__init__.py +++ b/intrastat_base/__init__.py @@ -1,2 +1,3 @@ # -*- coding: utf-8 -*- + from . import models diff --git a/intrastat_base/data/country_data.xml b/intrastat_base/data/country_data.xml index f4f526d..3c75a3a 100644 --- a/intrastat_base/data/country_data.xml +++ b/intrastat_base/data/country_data.xml @@ -1,6 +1,5 @@ - - + @@ -86,5 +85,5 @@ - - + + diff --git a/intrastat_base/tests/__init__.py b/intrastat_base/tests/__init__.py index 1f8b6fc..a2f5bfc 100644 --- a/intrastat_base/tests/__init__.py +++ b/intrastat_base/tests/__init__.py @@ -1,25 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module created 2014 by Sunflower IT (). -# Sponsored by FreshFilter BV (). -# -# 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 . -# -############################################################################## +# © 2011-2016 Akretion (http://www.akretion.com). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import intrastat_base_tests - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/intrastat_base/tests/intrastat_base_tests.py b/intrastat_base/tests/intrastat_base_tests.py index 7787c28..eb93462 100644 --- a/intrastat_base/tests/intrastat_base_tests.py +++ b/intrastat_base/tests/intrastat_base_tests.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +# © 2016 Sunflower IT (http://sunflowerweb.nl). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from openerp.tests.common import TransactionCase @@ -21,11 +23,3 @@ class TestIntrastatBase(TransactionCase): }) # then check if intrastat_email_list contains the email of the user self.assertEquals(demo_company.intrastat_email_list, demo_user.email) - - - - - - - -