[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

X-original-commit: 4d43a301fd10cfeb498d9bf6b614779e26e12d16
This commit is contained in:
Martin Trigaux
2020-09-04 16:21:41 +00:00
parent beb308dad6
commit d823b90220
6 changed files with 49 additions and 1 deletions
@@ -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',
},
]);
});
+1
View File
@@ -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
+19
View File
@@ -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)
+1 -1
View File
@@ -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>
+1
View File
@@ -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"/>
@@ -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):