diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-08-24 14:37:13 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-08-25 15:54:56 +0200 |
| commit | c73233d2489e3d074d4d13d1c782a97734e29e32 (patch) | |
| tree | 80e05efac56b44067a77b4e757ba54c334a0464e /addons/barcodes/static | |
| parent | dec1bdb44d2ee2bf1874f0a5051bdd7720cbb4d7 (diff) | |
[FIX] barcodes: don't warn if action unavailable
Before this rev. a warning was displayed when a barcode mapping an
invisible button was scanned. It shouldn't, for the following
reason. In the stock.picking form view, two buttons with
barcode_trigger='validate' are in the page ('Start Inventory' and
'Validate'), and there is always at least one of them that is
invisible. So when scanning the 'validate' barcode, we don't want
a warning to be displayed, as there is potentially another button
that is able to handle the request.
Diffstat (limited to 'addons/barcodes/static')
| -rw-r--r-- | addons/barcodes/static/src/js/barcode_form_view.js | 2 | ||||
| -rw-r--r-- | addons/barcodes/static/tests/barcode_tests.js | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/addons/barcodes/static/src/js/barcode_form_view.js b/addons/barcodes/static/src/js/barcode_form_view.js index 08872f8084a..c238df4da59 100644 --- a/addons/barcodes/static/src/js/barcode_form_view.js +++ b/addons/barcodes/static/src/js/barcode_form_view.js @@ -350,8 +350,6 @@ FormRenderer.include({ commands['O-BTN.' + node.attrs.barcode_trigger] = function () { if (!$button.hasClass('o_invisible_modifier')) { $button.click(); - } else { - this.do_warn(_t('Action currently unavailable')); } return $.when(); }; diff --git a/addons/barcodes/static/tests/barcode_tests.js b/addons/barcodes/static/tests/barcode_tests.js index ac9ff367d45..e6c87cdaaad 100644 --- a/addons/barcodes/static/tests/barcode_tests.js +++ b/addons/barcodes/static/tests/barcode_tests.js @@ -28,7 +28,7 @@ QUnit.module('Barcodes', { }); QUnit.test('Button with barcode_trigger', function (assert) { - assert.expect(1); + assert.expect(2); var form = createView({ View: FormView, @@ -37,6 +37,7 @@ QUnit.test('Button with barcode_trigger', function (assert) { arch: '<form>' + '<header>' + '<button name="do_something" string="Validate" type="object" barcode_trigger="doit"/>' + + '<button name="do_something_else" string="Validate" type="object" invisible="1" barcode_trigger="dothat"/>' + '</header>' + '</form>', res_id: 2, @@ -45,11 +46,18 @@ QUnit.test('Button with barcode_trigger', function (assert) { assert.strictEqual(event.data.action_data.name, 'do_something', "do_something method call verified"); }, + warning: function () { + assert.step('warn'); + }, }, }); // O-BTN.doit _.each(['O','-','B','T','N','.','d','o','i','t','Enter'], triggerKeypressEvent); + // O-BTN.dothat (should not call execute_action as the button isn't visible) + _.each(['O','-','B','T','N','.','d','o','t','h','a','t','Enter'], triggerKeypressEvent); + + assert.verifySteps([], "no warning should be displayed"); form.destroy(); }); |
