-
-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] stock_packaging_calculator: Migration to 17.0
- Loading branch information
1 parent
71d6610
commit e30a8a6
Showing
12 changed files
with
87 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
- Simone Orsi \<<simahawk@gmail.com>\> | ||
- Christopher Ormaza \<<chris.ormaza@forgeflow.com>\> | ||
- Nguyen Minh Chien \<<chien@trobz.com>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +0,0 @@ | ||
TODO | ||
|
||
1. Fractional quantities (eg: 0.5 Kg) are lost when counting units | ||
2. Maybe rely on packaging_uom | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import test_packaging_calc | ||
from . import test_pkg_qty_str | ||
from . import test_product_qty_by_packaging_mixin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class TestProductQtyByPackagingMixin(models.Model): | ||
_name = "test.product.qty_by_packaging.mixin" | ||
_description = "Test ProductQtyByPackagingMixin" | ||
_inherit = ["product.qty_by_packaging.mixin"] | ||
_qty_by_pkg__qty_field_name = "quantity" | ||
|
||
product_id = fields.Many2one("product.product") | ||
quantity = fields.Float() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
stock_packaging_calculator/tests/test_product_qty_by_packaging_mixin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
from odoo_test_helper import FakeModelLoader | ||
|
||
from .common import TestCommon | ||
|
||
|
||
class TestPQPackagingMixin(TestCommon): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
# Load a test model using odoo_test_helper | ||
cls.loader = FakeModelLoader(cls.env, cls.__module__) | ||
cls.loader.backup_registry() | ||
from .models import TestProductQtyByPackagingMixin | ||
|
||
cls.loader.update_registry((TestProductQtyByPackagingMixin,)) | ||
cls.model = cls.env[TestProductQtyByPackagingMixin._name] | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
cls.loader.restore_registry() | ||
return super().tearDownClass() | ||
|
||
def test_1_quantity_packaging(self): | ||
record = self.model.create({"product_id": self.product_a.id, "quantity": 10}) | ||
self.assertEqual(record.product_qty_by_packaging_display, "10 Units") | ||
self.assertEqual( | ||
record.with_context( | ||
qty_by_pkg_only_packaging=True | ||
).product_qty_by_packaging_display, | ||
"", | ||
) | ||
record.quantity = 100 | ||
self.assertEqual(record.product_qty_by_packaging_display, "2 Box") | ||
record.quantity = 250 | ||
self.assertEqual(record.product_qty_by_packaging_display, "1 Big Box,\xa01 Box") | ||
record.quantity = 255 | ||
self.assertEqual( | ||
record.product_qty_by_packaging_display, | ||
"1 Big Box,\xa01 Box,\xa05 Units", | ||
) | ||
# only_packaging has no impact if we get not only units | ||
self.assertEqual( | ||
record.with_context( | ||
qty_by_pkg_only_packaging=True | ||
).product_qty_by_packaging_display, | ||
"1 Big Box,\xa01 Box,\xa05 Units", | ||
) | ||
|
||
def test_2_fractional_quantity(self): | ||
record = self.model.create( | ||
{"product_id": self.product_a.id, "quantity": 100.45} | ||
) | ||
self.assertEqual( | ||
record.product_qty_by_packaging_display, "2 Box,\xa00.45 Units" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
odoo_test_helper |