summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2020-09-01 12:08:17 +0000
committerMartin Trigaux <mat@odoo.com>2020-09-04 09:44:02 +0000
commit4d43a301fd10cfeb498d9bf6b614779e26e12d16 (patch)
treef623f943325421605228d08ec0b1244f330537db
parent177d5e833989a40726eff040ec1cc25bdef48c06 (diff)
[FIX] base: add fake fields
Values for "context" and "data" key were injected into the action dictionnary by report_action to be used by the /report controller later Courtesy of William Henrotin (whe) for the test
-rw-r--r--addons/stock/static/tests/tours/stock_report_tests.js23
-rw-r--r--addons/stock/tests/__init__.py1
-rw-r--r--addons/stock/tests/test_report_tours.py19
-rw-r--r--addons/stock/views/product_views.xml2
-rw-r--r--addons/stock/views/stock_template.xml1
-rw-r--r--odoo/addons/base/models/ir_actions_report.py4
6 files changed, 49 insertions, 1 deletions
diff --git a/addons/stock/static/tests/tours/stock_report_tests.js b/addons/stock/static/tests/tours/stock_report_tests.js
new file mode 100644
index 00000000000..c757390fa51
--- /dev/null
+++ b/addons/stock/static/tests/tours/stock_report_tests.js
@@ -0,0 +1,23 @@
+odoo.define('stock.reports.setup.tour', function (require) {
+ "use strict";
+
+ const tour = require('web_tour.tour');
+
+ tour.register('test_stock_route_diagram_report', {
+ test: true,
+ }, [
+ {
+ trigger: '.o_kanban_record',
+ extra_trigger:'.breadcrumb',
+ },
+ {
+ trigger: '.nav-item > a:contains("Inventory")',
+ },
+ {
+ trigger: '.btn[id="stock.view_diagram_button"]',
+ },
+ {
+ trigger: 'iframe .o_report_stock_rule',
+ },
+ ]);
+});
diff --git a/addons/stock/tests/__init__.py b/addons/stock/tests/__init__.py
index 6cd4cf7805c..d94033cd6b6 100644
--- a/addons/stock/tests/__init__.py
+++ b/addons/stock/tests/__init__.py
@@ -17,3 +17,4 @@ from . import test_packing_neg
from . import test_proc_rule
from . import test_wise_operator
from . import test_report
+from . import test_report_tours
diff --git a/addons/stock/tests/test_report_tours.py b/addons/stock/tests/test_report_tours.py
new file mode 100644
index 00000000000..0958ed55c26
--- /dev/null
+++ b/addons/stock/tests/test_report_tours.py
@@ -0,0 +1,19 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+import odoo
+from odoo.tests import Form, HttpCase, tagged
+
+
+@tagged('-at_install', 'post_install')
+class TestStockReportTour(HttpCase):
+ def setUp(self):
+ super().setUp()
+
+ def _get_report_url(self):
+ return '/web#&model=product.template&action=stock.product_template_action_product'
+
+
+ def test_stock_route_diagram_report(self):
+ """ Open the route diagram report."""
+ url = self._get_report_url()
+
+ self.start_tour(url, 'test_stock_route_diagram_report', login='admin', timeout=180)
diff --git a/addons/stock/views/product_views.xml b/addons/stock/views/product_views.xml
index 9de6159e0a0..6dce4b0eb6f 100644
--- a/addons/stock/views/product_views.xml
+++ b/addons/stock/views/product_views.xml
@@ -111,7 +111,7 @@
<label for="route_ids" attrs="{'invisible': [('type', 'in', ['service', 'digital'])]}"/>
<div>
<field name="route_ids" class="mb-0" widget="many2many_checkboxes" attrs="{'invisible': ['|', ('has_available_route_ids', '=', False), ('type', 'in', ['service', 'digital'])]}"/>
- <button string="View Diagram" type="action" name="%(action_open_routes)d" icon="fa-arrow-right"
+ <button id="stock.view_diagram_button" string="View Diagram" type="action" name="%(action_open_routes)d" icon="fa-arrow-right"
attrs="{'invisible':[('type', 'not in', ['product', 'consu'])]}"
class="btn btn-link pt-0" context="{'default_product_tmpl_id': id}"/>
</div>
diff --git a/addons/stock/views/stock_template.xml b/addons/stock/views/stock_template.xml
index 2d6515717cb..58a4a56e18b 100644
--- a/addons/stock/views/stock_template.xml
+++ b/addons/stock/views/stock_template.xml
@@ -19,6 +19,7 @@
<script type="text/javascript" src="/stock/static/src/js/forecast_widget.js"></script>
<script type="text/javascript" src="/stock/static/src/js/basic_model.js"></script>
<script type="text/javascript" src="/stock/static/src/js/stock_rescheduling_popover.js"></script>
+ <script type="text/javascript" src="/stock/static/tests/tours/stock_report_tests.js"></script>
<link rel="stylesheet" type="text/scss" href="/stock/static/src/scss/forecast_widget.scss"/>
<link rel="stylesheet" type="text/scss" href="/stock/static/src/scss/stock_traceability_report.scss"/>
<link rel="stylesheet" type="text/scss" href="/stock/static/src/scss/stock_empty_screen.scss"/>
diff --git a/odoo/addons/base/models/ir_actions_report.py b/odoo/addons/base/models/ir_actions_report.py
index 77441abd33d..9770089aba5 100644
--- a/odoo/addons/base/models/ir_actions_report.py
+++ b/odoo/addons/base/models/ir_actions_report.py
@@ -146,6 +146,10 @@ class IrActionsReport(models.Model):
def _get_readable_fields(self):
return super()._get_readable_fields() | {
"report_name", "report_type", "target",
+ # these two are not real fields of ir.actions.report but are
+ # expected in the route /report/<converter>/<reportname> and must
+ # not be removed by clean_action
+ "context", "data",
}
def associated_view(self):