From 9b136383c2599301413e6770cc0ff204273b589d Mon Sep 17 00:00:00 2001 From: "Hubert Van de Walle (huvw)" Date: Tue, 28 Feb 2023 06:18:56 +0000 Subject: [PATCH] [FIX] web,mrp,stock: don't call action buttons for virtual records in x2manys Steps to reproduce ================== - Make sure the "Work Orders" setting is enabled - Manufacturing > Products > Bills of Materials > New - Select a random product - In the Operations tab, add a line - Type something in the Operation field - Set the workcenter to Assembly line 1 - Save and close - Click on the "Show Instructions" action button ``` Traceback (most recent call last): File "/home/hubert/src/16.0/odoo/odoo/models.py", line 5108, in ensure_one _id, = self._ids ^^^^ ValueError: not enough values to unpack (expected 1, got 0) ``` Cause of the issue ================== The action is called without in id because the record is not yet created Solution ======== The button should display a warning in x2manys when the record is virtual. This was actually the case before Odoo 16 but there was an option on the button `options='{"warn": true}'`. With this commit, it will be the default behavior. We also remove this option from the xml since it isn't used. sentry-3950549982 closes odoo/odoo#114505 X-original-commit: 9fc0424a4450923aa8582bdb6766e1b19cb68546 Signed-off-by: Aaron Bohy (aab) Signed-off-by: Hubert Van De Walle --- addons/mrp/views/mrp_production_views.xml | 8 ++--- addons/stock/views/stock_move_views.xml | 2 +- addons/stock/views/stock_picking_views.xml | 2 +- .../static/src/views/list/list_renderer.js | 7 +++++ .../static/src/views/list/list_renderer.xml | 1 + .../src/views/view_button/view_button.js | 6 ++++ .../tests/views/form/form_view_tests.js | 30 +++++++++++++++++++ 7 files changed, 50 insertions(+), 6 deletions(-) diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index c478cdf1ad7..8b557bb6e7a 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -369,8 +369,8 @@ domain="[('product_id','=',product_id)]" /> - + + + `, + }); + + await click(target.querySelector(".o_field_one2many .o_field_x2many_list_row_add a")); + await click(target.querySelector("button.oe_stat_button[name='test_action']")); + assert.verifySteps(['danger:Please click on the "save" button first']); + } + ); + });