summaryrefslogtreecommitdiff
path: root/addons/purchase_product_matrix
diff options
context:
space:
mode:
authorVictor Feyens <vfe@odoo.com>2019-11-21 14:30:02 +0000
committerVictor Feyens <vfe@odoo.com>2019-11-27 15:49:57 +0000
commitc32e9a47886a4d9b008c8c2b18172aa98907d353 (patch)
treebcef7e51df60568bbc1de401c506a772843a87bb /addons/purchase_product_matrix
parent6c800032088128d818fc970afee7cc7f1c365a6e (diff)
[ADD] (*_)_product_matrix: test tours
closes odoo/odoo#40971 X-original-commit: d729460f5fc72aa70e0a024e1dff281299eed0e3 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Diffstat (limited to 'addons/purchase_product_matrix')
-rw-r--r--addons/purchase_product_matrix/static/tests/tours/purchase_product_matrix_tour.js110
-rw-r--r--addons/purchase_product_matrix/tests/__init__.py4
-rw-r--r--addons/purchase_product_matrix/tests/test_purchase_matrix.py34
-rw-r--r--addons/purchase_product_matrix/views/assets.xml8
4 files changed, 155 insertions, 1 deletions
diff --git a/addons/purchase_product_matrix/static/tests/tours/purchase_product_matrix_tour.js b/addons/purchase_product_matrix/static/tests/tours/purchase_product_matrix_tour.js
new file mode 100644
index 00000000000..9148f888b53
--- /dev/null
+++ b/addons/purchase_product_matrix/static/tests/tours/purchase_product_matrix_tour.js
@@ -0,0 +1,110 @@
+odoo.define('purchase_product_matrix.purchase_matrix_tour', function (require) {
+"use strict";
+
+var tour = require('web_tour.tour');
+
+tour.register('purchase_matrix_tour', {
+ url: "/web",
+ test: true,
+}, [tour.STEPS.SHOW_APPS_MENU_ITEM, {
+ trigger: '.o_app[data-menu-xmlid="purchase.menu_purchase_root"]',
+}, {
+ trigger: ".o_list_button_add",
+ extra_trigger: ".o_purchase_order"
+}, {
+ trigger: "a:contains('Add a product')"
+}, {
+ trigger: 'div[name="product_template_id"] input',
+ run: function () {
+ var $input = $('div[name="product_template_id"] input');
+ $input.click();
+ $input.val('Matrix');
+ var keyDownEvent = jQuery.Event("keydown");
+ keyDownEvent.which = 42;
+ $input.trigger(keyDownEvent);
+ }
+}, {
+ trigger: 'ul.ui-autocomplete a:contains("Matrix")',
+ run: 'click'
+}, {
+ trigger: '.o_product_variant_matrix',
+ run: function () {
+ // fill the whole matrix with 1's
+ $('.o_matrix_input').val(1);
+ }
+}, {
+ trigger: 'span:contains("Confirm")',
+ run: 'click'
+}, {
+ trigger: ".o_form_editable .o_field_many2one[name='partner_id'] input",
+ extra_trigger: ".o_purchase_order",
+ run: 'text Agrolait'
+}, {
+ trigger: ".ui-menu-item > a",
+ auto: true,
+ in_modal: false,
+}, {
+ trigger: '.o_form_button_save:contains("Save")',
+ run: 'click' // SAVE Sales Order.
+},
+// Open the matrix through the pencil button next to the product in line edit mode.
+{
+ trigger: '.o_form_button_edit:contains("Edit")',
+ run: 'click' // Edit Sales Order.
+}, {
+ trigger: 'span:contains("Matrix (PAV11, PAV22, PAV31)\nPA4: PAV41")',
+ run: 'click'
+}, {
+ trigger: '.o_edit_product_configuration',
+ run: 'click' // edit the matrix
+}, {
+ trigger: '.o_product_variant_matrix',
+ run: function () {
+ // update some of the matrix values.
+ $('.o_matrix_input').slice(8, 16).val(4);
+ } // set the qty to 4 for half of the matrix products.
+}, {
+ trigger: 'span:contains("Confirm")',
+ run: 'click' // apply the matrix
+}, {
+ trigger: '.o_form_button_save:contains("Save")',
+ extra_trigger: '.o_field_cell.o_data_cell.o_list_number:contains("4.000")',
+ run: 'click' // SAVE Sales Order, after matrix has been applied (extra_trigger).
+}, {
+ trigger: '.o_form_button_edit:contains("Edit")',
+ run: 'click' // Edit Sales Order.
+},
+// Ensures the matrix is opened with the values, when adding the same product.
+{
+ trigger: "a:contains('Add a product')"
+}, {
+ trigger: 'div[name="product_template_id"] input',
+ run: function () {
+ var $input = $('div[name="product_template_id"] input');
+ $input.click();
+ $input.val('Matrix');
+ var keyDownEvent = jQuery.Event("keydown");
+ keyDownEvent.which = 42;
+ $input.trigger(keyDownEvent);
+ }
+}, {
+ trigger: 'ul.ui-autocomplete a:contains("Matrix")',
+ run: 'click'
+}, {
+ trigger: "input[value='4']",
+ run: function () {
+ // update some values of the matrix
+ $("input[value='4']").slice(0, 4).val(8.2);
+ }
+}, {
+ trigger: 'span:contains("Confirm")',
+ run: 'click' // apply the matrix
+}, {
+ trigger: '.o_form_button_save:contains("Save")',
+ extra_trigger: '.o_field_cell.o_data_cell.o_list_number:contains("8.200")',
+ run: 'click' // SAVE Sales Order, after matrix has been applied (extra_trigger).
+},
+]);
+
+
+});
diff --git a/addons/purchase_product_matrix/tests/__init__.py b/addons/purchase_product_matrix/tests/__init__.py
new file mode 100644
index 00000000000..8c94384317a
--- /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 00000000000..fccf36ce87e
--- /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 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['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 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['purchase.order.line'].search([('product_id', 'in', self.matrix_template.product_variant_ids.ids)])),
+ len(self.matrix_template.product_variant_ids)*2
+ )
diff --git a/addons/purchase_product_matrix/views/assets.xml b/addons/purchase_product_matrix/views/assets.xml
index c9aaf58fbed..ff11e9907fd 100644
--- a/addons/purchase_product_matrix/views/assets.xml
+++ b/addons/purchase_product_matrix/views/assets.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
- <template id="assets_backend_inherit_purchase" inherit_id="web.assets_backend" name="Sale Grid assets">
+ <template id="assets_backend_inherit_purchase" inherit_id="web.assets_backend" name="Purchase Grid assets">
<xpath expr="script[last()]" position="after">
<script type="text/javascript" src="/purchase_product_matrix/static/src/js/product_matrix_configurator.js"/>
</xpath>
@@ -12,4 +12,10 @@
<script type="text/javascript" src="/purchase_product_matrix/static/tests/section_and_note_widget_tests.js"></script>
</xpath>
</template>
+
+ <template id="assets_tests" name="Purchase Product Matrix Assets Tests" inherit_id="web.assets_tests">
+ <xpath expr="." position="inside">
+ <script type="text/javascript" src="/purchase_product_matrix/static/tests/tours/purchase_product_matrix_tour.js"/>
+ </xpath>
+ </template>
</odoo>