From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/purchase_product_matrix/tests/__init__.py | 4 +++ .../tests/test_purchase_matrix.py | 34 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 addons/purchase_product_matrix/tests/__init__.py create mode 100644 addons/purchase_product_matrix/tests/test_purchase_matrix.py (limited to 'addons/purchase_product_matrix/tests') diff --git a/addons/purchase_product_matrix/tests/__init__.py b/addons/purchase_product_matrix/tests/__init__.py new file mode 100644 index 00000000..8c943843 --- /dev/null +++ b/addons/purchase_product_matrix/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import test_purchase_matrix diff --git a/addons/purchase_product_matrix/tests/test_purchase_matrix.py b/addons/purchase_product_matrix/tests/test_purchase_matrix.py new file mode 100644 index 00000000..aafa4f53 --- /dev/null +++ b/addons/purchase_product_matrix/tests/test_purchase_matrix.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import odoo.tests +from odoo.addons.product_matrix.tests.common import TestMatrixCommon + + +@odoo.tests.tagged('post_install', '-at_install') +class TestPurchaseMatrixUi(TestMatrixCommon): + + def test_purchase_matrix_ui(self): + self.start_tour("/web", 'purchase_matrix_tour', login="admin") + + # Ensures some dynamic create variants have been created by the matrix + # Ensures a PO has been created with exactly x lines ... + + self.assertEqual(len(self.matrix_template.product_variant_ids), 8) + self.assertEqual(len(self.matrix_template.product_variant_ids.product_template_attribute_value_ids), 6) + self.assertEqual(len(self.matrix_template.attribute_line_ids.product_template_value_ids), 8) + self.env['purchase.order.line'].search([('product_id', 'in', self.matrix_template.product_variant_ids.ids)]).order_id.button_confirm() + + self.matrix_template.flush() + self.assertEqual(round(self.matrix_template.purchased_product_qty, 2), 56.8) + for variant in self.matrix_template.product_variant_ids: + # 5 and 9.2 because of no variant attributes + self.assertIn(round(variant.purchased_product_qty, 2), [5, 9.2]) + + # Ensure no duplicate line has been created on the PO. + # NB: the *2 is because the no_variant attribute doesn't create a variant + # but still gives different order lines. + self.assertEqual( + len(self.env['purchase.order.line'].search([('product_id', 'in', self.matrix_template.product_variant_ids.ids)])), + len(self.matrix_template.product_variant_ids)*2 + ) -- cgit v1.2.3