summaryrefslogtreecommitdiff
path: root/addons/sale_product_matrix/tests
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/sale_product_matrix/tests
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/sale_product_matrix/tests')
-rw-r--r--addons/sale_product_matrix/tests/__init__.py4
-rw-r--r--addons/sale_product_matrix/tests/test_sale_matrix.py41
2 files changed, 45 insertions, 0 deletions
diff --git a/addons/sale_product_matrix/tests/__init__.py b/addons/sale_product_matrix/tests/__init__.py
new file mode 100644
index 00000000..943bad6e
--- /dev/null
+++ b/addons/sale_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_sale_matrix
diff --git a/addons/sale_product_matrix/tests/test_sale_matrix.py b/addons/sale_product_matrix/tests/test_sale_matrix.py
new file mode 100644
index 00000000..513c6742
--- /dev/null
+++ b/addons/sale_product_matrix/tests/test_sale_matrix.py
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+import odoo.tests
+from odoo.addons.product_matrix.tests import common
+
+
+@odoo.tests.tagged('post_install', '-at_install')
+class TestSaleMatrixUi(common.TestMatrixCommon):
+
+ """
+ This test needs sale_management module to work.
+ """
+
+ def test_sale_matrix_ui(self):
+ # Set the template as configurable by matrix.
+ self.matrix_template.product_add_mode = "matrix"
+
+ self.start_tour("/web", 'sale_matrix_tour', login="admin")
+
+ # Ensures some dynamic create variants have been created by the matrix
+ # Ensures a SO 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['sale.order.line'].search([('product_id', 'in', self.matrix_template.product_variant_ids.ids)]).order_id.action_confirm()
+
+ self.matrix_template.flush()
+ self.assertEqual(round(self.matrix_template.sales_count, 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.sales_count, 2), [5, 9.2])
+
+ # Ensure no duplicate line has been created on the SO.
+ # 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['sale.order.line'].search([('product_id', 'in', self.matrix_template.product_variant_ids.ids)])),
+ len(self.matrix_template.product_variant_ids)*2
+ )