[MIG] packaging_uom, purchase_packaging, sale_packaging: Migrated to 10.0

This commit is contained in:
Laurent Mignon (ACSONE)
2017-03-09 17:07:44 +01:00
committed by Thomas Binsfeld
parent 7a368c40d3
commit 4e2dcba532
11 changed files with 158 additions and 200 deletions

View File

@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_packaging
from . import test_product_packaging

View File

@@ -1,82 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Authors: Laetitia Gangloff
# Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)
#
# 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 openerp.tests.common as common
class TestPackaging(common.TransactionCase):
def setUp(self):
super(TestPackaging, self).setUp()
def test_compute_quantity_by_package(self):
""" Create a packagings with uom product_uom_dozen on
* product_product_35 (uom is product_uom_dozen)
* product_product_34 (uom is product_uom_unit)
Result should be :
* product_product_35 -> qty by package : 1
* product_product_34 -> qty by package : 12
Create product_uom_24
Update product_product_35 to set this new uom
Result should be :
* product_product_35 -> qty by package : 0.5
Update product_package_34 to set this new uom
Result should be :
* product_product_34 -> qty by package : 24
Create product_uom 6
Update product_product_35 to set this new uom
Result should be :
* product_product_35 -> qty by package : 2
Update product_package_34 to set this new uom
Result should be :
* product_product_34 -> qty by package : 6
"""
packaging_obj = self.env['product.packaging']
product_packaging_35 = packaging_obj.create(
{'product_tmpl_id': self.env.ref('product.product_product_35'
).product_tmpl_id.id,
'uom_id': self.env.ref('product.product_uom_dozen').id})
self.assertAlmostEqual(product_packaging_35.qty, 1)
product_packaging_34 = packaging_obj.create(
{'product_tmpl_id': self.env.ref('product.product_product_34'
).product_tmpl_id.id,
'uom_id': self.env.ref('product.product_uom_dozen').id})
self.assertAlmostEqual(product_packaging_34.qty, 12)
product_uom_24 = self.env['product.uom'].create(
{'category_id': self.env.ref('product.product_uom_categ_unit').id,
'name': 'Double Dozens',
'factor_inv': 24,
'uom_type': 'bigger'
})
self.env.ref('product.product_product_35').uom_id = product_uom_24
self.assertAlmostEqual(product_packaging_35.qty, 0.5)
product_packaging_34.uom_id = product_uom_24
self.assertAlmostEqual(product_packaging_34.qty, 24)
product_uom_6 = self.env['product.uom'].create(
{'category_id': self.env.ref('product.product_uom_categ_unit').id,
'name': 'Demi Dozens',
'factor_inv': 6,
'uom_type': 'bigger'
})
self.env.ref('product.product_product_35').uom_id = product_uom_6
self.assertAlmostEqual(product_packaging_35.qty, 2)
product_packaging_34.uom_id = product_uom_6
self.assertAlmostEqual(product_packaging_34.qty, 6)

View File

@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import odoo.tests.common as common
class TestProductPackaging(common.TransactionCase):
def setUp(self):
super(TestProductPackaging, self).setUp()
self.uom_unit = self.env.ref('product.product_uom_unit')
self.uom_dozen = self.env.ref('product.product_uom_dozen')
self.product_tmpl_dozen = self.env[
'product.template'].new(
{'uom_id': self.uom_dozen})
self.product_tmpl_unit = self.env[
'product.template'].new(
{'uom_id': self.uom_unit})
def test_compute_quantity_by_package(self):
""" Create a packagings with uom product_uom_dozen on
* product_tmpl_dozen (uom is product_uom_dozen)
* product_tmpl_unit (uom is product_uom_unit)
Result should be :
* product_tmpl_dozen -> qty by package : 1
* product_tmpl_unit -> qty by package : 12
Create product_uom_24
Update product_tmpl_dozen to set this new uom
Result should be :
* product_tmpl_dozen -> qty by package : 0.5
Update product_package_unit to set this new uom
Result should be :
* product_packaging_unit -> qty by package : 24
Create product_uom 6
Update product_tmpl_dozen to set this new uom
Result should be :
* product_packaging_dozen -> qty by package : 2
Update product_packaging_unit to set this new uom
Result should be :
* product_packaging_unit -> qty by package : 6
"""
packaging_obj = self.env['product.packaging']
product_packaging_dozen = packaging_obj.new(
{'product_tmpl_id': self.product_tmpl_dozen,
'uom_id': self.uom_dozen})
self.assertAlmostEqual(product_packaging_dozen.qty, 1)
product_packaging_unit = packaging_obj.new(
{'product_tmpl_id': self.product_tmpl_unit,
'uom_id': self.uom_dozen})
self.assertAlmostEqual(product_packaging_unit.qty, 12)
product_uom_24 = self.env['product.uom'].create(
{'category_id': self.env.ref('product.product_uom_categ_unit').id,
'name': 'Double Dozens',
'factor_inv': 24,
'uom_type': 'bigger'
})
self.product_tmpl_dozen.uom_id = product_uom_24
self.assertAlmostEqual(product_packaging_dozen.qty, 0.5)
product_packaging_unit.uom_id = product_uom_24
self.assertAlmostEqual(product_packaging_unit.qty, 24)
product_uom_6 = self.env['product.uom'].create(
{'category_id': self.env.ref('product.product_uom_categ_unit').id,
'name': 'Demi Dozens',
'factor_inv': 6,
'uom_type': 'bigger'
})
self.product_tmpl_dozen.uom_id = product_uom_6
self.assertAlmostEqual(product_packaging_dozen.qty, 2)
product_packaging_unit.uom_id = product_uom_6
self.assertAlmostEqual(product_packaging_unit.qty, 6)