OCA / web

Odoo web client UI related addons
GNU Affero General Public License v3.0
945 stars 1.89k forks source link

[11.0] web_tree_dynamic_colored_field: breaks Odoo web standard tests #903

Closed oerp-odoo closed 2 years ago

oerp-odoo commented 6 years ago

If web_tree_dynamic_colored_field is installed, standard Odoo web tests start to fail. It actually somehow fails to load relevant parts of code, which then causes to fail tests (or timeout).

I get this:

2018-03-30 11:12:16,100 15106 INFO mrp_toc_6_3 odoo.tests.common.phantomjs: page.evaluate eval expr: true
2018-03-30 11:12:16,100 15106 INFO mrp_toc_6_3 odoo.tests.common.phantomjs: page.evaluate eval result: true
2018-03-30 11:12:16,101 15106 INFO mrp_toc_6_3 odoo.tests.common.phantomjs: PhantomTest.run: condition statified, executing: true
2018-03-30 11:12:16,101 15106 INFO mrp_toc_6_3 odoo.tests.common.phantomjs: PhantomTest.run: execution launched, waiting for console.log('ok')...
2018-03-30 11:12:20,110 15106 WARNING mrp_toc_6_3 odoo.tests.common.phantomjs: warning: Some modules could not be started
2018-03-30 11:12:20,111 15106 INFO mrp_toc_6_3 odoo.tests.common.phantomjs: Missing dependencies:     web.session,web.WebClient,web.basic_fields,web.view_registry,web.data_manager,web.Domain,web.pyeval,web.FormView,web.KanbanView,web.ListView,web.field_utils,web.AbstractField,web.BasicModel,web.ListRenderer,web.relational_fields,web.StandaloneFieldManagerMixin,web.AbstractView,web.field_registry,web.widget_registry,web.GraphView,web.PivotView,web.KanbanColumnProgressBar,web.KanbanRenderer,web_grid.GridView,web_gantt.GanttView,web_diagram.DiagramView,web.CalendarView,web.CalendarRenderer,web.KanbanModel,web.view_dialogs,base.settings,web.Context,web.SearchView,web.Pager,web.framework,web.data,web.DomainSelector,web.ModelFieldSelector,web.ActionManager,web_enterprise.Menu,web_mobile.rpc
2018-03-30 11:12:20,111 15106 INFO mrp_toc_6_3 odoo.tests.common.phantomjs: Non loaded modules:       web.AjaxService,web_editor.base,web_editor.ready,web_editor.ace,web.planner.common,web_tour.TourManager,web_tour.tour,web.web_client,web.test_utils,web.MockServer,web_editor.tour,web.basic_fields_tests,web.field_utils_tests,web.relational_fields_tests,web.special_fields_tests,web.abstract_view_tests,web.form_tests,web.graph_tests,web.list_tests,web.pivot_tests,web.kanban_tests,web_grid.MockServer,web_grid.grid_tests,web.gantt_tests,web_diagram.diagram_tests,web.calendar_tests,web.basic_model_tests,web.kanban_model_tests,web.view_dialogs_tests,web.base_setting_test,web.pyEval_tests,web.domain_tests,web.mixins_tests,web.search_tests,web.pager_tests,web.data_export_tests,web.domain_selector_tests,web.model_field_selector_tests,web.base_import_tests,web_enterprise.form_tests,web_enterprise.upgrade_fields_tests,web_enterprise.relational_fields_tests,web_enterprise.mobile_menu_tests,web_kanban_gauge.gauge_tests,web_mobile.tests,web_editor.web_editor_tests

It seems to be the problem specifically with this method (in web_tree_dynamic_colored_field.js):

        _renderBody: function () {
            if (this.arch.attrs.colors) {
                var colorAttr = this.arch.attrs.colors.split(';')
                    .filter(color => color.trim().startsWith('color_field'));
                if (colorAttr.length > 0) {
                    var colorField = colorAttr[0].split(':')[1].trim();
                    // validate the presence of that field in tree view
                    var fieldNames = _(this.columns).map(
                        (value) => { return value.attrs.name; }
                    );
                    if (fieldNames.indexOf(colorField) === -1) {
                        console.warn(
                            "No field named '" + colorField + "' present in view."
                        );
                    } else {
                        this.colorField = colorField;
                    }
                }
            }
            return this._super();
        },

To be exact, this part:

var colorAttr = this.arch.attrs.colors
    .filter(color => color.trim().startsWith('color_field'));

It probably has something to do with standard colors attribute being overridden. I don't know how to workaround it yet so both tests would work and this part would work. Removing this method, makes tests to pass again, but part of functionality is lost then..

P.S. I noticed this, when I added this module as dependency for my repository and then odoo.sh builds have started to fail.

Tardo commented 6 years ago

I think that you can't use "arrows" (ES6 feature)... full support will be in v12.

simahawk commented 6 years ago

Try https://underscorejs.org/#filter + http://epeli.github.io/underscore.string/#startswith-string-starts-position-gt-boolean

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.