-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] mrp_bom_through_attributes: Code optimization + tests
- Loading branch information
1 parent
2ea7615
commit 0c2850e
Showing
4 changed files
with
83 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import test_mrp_bom_through_attribute |
45 changes: 45 additions & 0 deletions
45
mrp_bom_through_attributes/tests/test_mrp_bom_through_attribute.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,45 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp.tests import common | ||
|
||
|
||
class TestMrpBomThroughAttribute(common.TransactionCase): | ||
def setUp(self): | ||
super(TestMrpBomThroughAttribute, self).setUp() | ||
self.raw_material = self.env['product.product'].create( | ||
{'name': 'Test raw material'}) | ||
self.attribute = self.env['product.attribute'].create( | ||
{'name': 'Component'}) | ||
self.value = self.env['product.attribute.value'].create( | ||
{'name': 'Raw material', | ||
'attribute_id': self.attribute.id, | ||
'raw_product': self.raw_material.id, | ||
'raw_qty': 2.0}) | ||
self.final_template = self.env['product.template'].create( | ||
{ | ||
'name': 'Test final product with attributes', | ||
'attribute_line_ids': [ | ||
(0, 0, { | ||
'attribute_id': self.attribute.id, | ||
'value_ids': [(6, 0, self.value.ids)]})] | ||
}) | ||
self.final_product = self.final_template.product_variant_ids[0] | ||
self.bom = self.env['mrp.bom'].create( | ||
{ | ||
'product_id': self.final_template.id, | ||
'product_tmpl_id': self.final_template.id, | ||
}) | ||
|
||
def test_production_with_component_through_attributes(self): | ||
production = self.env['mrp.production'].create( | ||
{ | ||
'product_id': self.final_product.id, | ||
'product_uom': self.final_product.uom_id.id, | ||
'bom_id': self.bom.id, | ||
'product_qty': 3.0, | ||
}) | ||
production.action_compute() | ||
self.assertEqual(len(production.product_lines), 1) | ||
self.assertEqual(production.product_lines[0].product_qty, 6.0) |
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