diff options
| author | ThanhDodeurOdoo <tso@odoo.com> | 2018-12-06 07:43:00 +0000 |
|---|---|---|
| committer | ThanhDodeurOdoo <tso@odoo.com> | 2018-12-06 19:09:34 +0000 |
| commit | 20cbb6dc0ba20c165f2ff1e6f1bcd418729ed186 (patch) | |
| tree | 3407919d53253e691af7a2b8acba963bde12a4fd /addons | |
| parent | 7d85ab1eac6dbf33d56c6a1f8bf7e9e12bb8008e (diff) | |
Revert "[FIX] document: JS feature disabled"
This reverts commit 1dbb555a
Bring the sidebar attachment dropdown feature back.
This feature was removed due to be considered as useless,
but since some models can have attachement without a mail_thread,
this feature is still necessary.
task: #1908896
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/document/static/src/js/document.js | 5 | ||||
| -rw-r--r-- | addons/document/static/tests/document_tests.js | 6 | ||||
| -rw-r--r-- | addons/web/static/tests/views/form_tests.js | 57 |
3 files changed, 55 insertions, 13 deletions
diff --git a/addons/document/static/src/js/document.js b/addons/document/static/src/js/document.js index 0461f67255a..b8437d70417 100644 --- a/addons/document/static/src/js/document.js +++ b/addons/document/static/src/js/document.js @@ -1,10 +1,5 @@ odoo.define('document.document', function (require) { "use strict"; -/** - * The feature is disabled as it was replaced by another feature - * while still holding unfixed bugs and doing unnecessary rpc. - */ -return; var core = require('web.core'); var Dialog = require('web.Dialog'); diff --git a/addons/document/static/tests/document_tests.js b/addons/document/static/tests/document_tests.js index 8aebe4894e0..33c081a28ac 100644 --- a/addons/document/static/tests/document_tests.js +++ b/addons/document/static/tests/document_tests.js @@ -1,10 +1,5 @@ odoo.define('document.tests', function (require) { "use strict"; - /** - * The feature tested here is disabled as it was replaced by another feature - * while still holding unfixed bugs and doing unnecessary rpc. - */ - return; var testUtils = require('web.test_utils'); var FormView = require('web.FormView'); @@ -78,6 +73,7 @@ odoo.define('document.tests', function (require) { }); assert.containsN(form.sidebar, '.o_sidebar_delete_attachment', 2, "there should be two attachments"); + testUtils.dom.click(form.sidebar.$('.o_dropdown_toggler_btn:contains("Attachment")')); testUtils.dom.click(form.sidebar.$('.o_sidebar_delete_attachment:eq(0)')); testUtils.dom.click($('.modal-footer .btn-primary')); assert.containsOnce(form.sidebar, '.o_sidebar_delete_attachment', "there should be only one attachment"); diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index b73a1438f13..58373d4fd32 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -1563,6 +1563,12 @@ QUnit.module('Views', { '</form>', viewOptions: {hasSidebar: true}, res_id: 1, + mockRPC: function (route, args) { + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } + return this._super.apply(this, arguments); + }, }); assert.isVisible(form.sidebar); @@ -1703,6 +1709,12 @@ QUnit.module('Views', { '</form>', res_id: 1, viewOptions: {hasSidebar: true}, + mockRPC: function (route, args) { + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } + return this._super.apply(this, arguments); + }, }); assert.strictEqual(form.get('title'), 'first record', @@ -1737,6 +1749,9 @@ QUnit.module('Views', { assert.strictEqual(args.kwargs.context.hey, 'hoy', "should have send the correct context"); } + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } return this._super.apply(this, arguments); }, }); @@ -1759,6 +1774,12 @@ QUnit.module('Views', { '</form>', res_id: 1, viewOptions: {hasSidebar: true}, + mockRPC: function (route, args) { + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } + return this._super.apply(this, arguments); + }, }); assert.strictEqual(form.get('title'), 'first record', @@ -2310,6 +2331,12 @@ QUnit.module('Views', { arch: '<form string="Partners"><field name="foo"></field></form>', res_id: 1, viewOptions: {hasSidebar: true}, + mockRPC: function (route, args) { + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } + return this._super.apply(this, arguments); + }, }); testUtils.form.clickEdit(form); testUtils.fields.editInput(form.$('input[name=foo]'), 'tralala'); @@ -2639,6 +2666,12 @@ QUnit.module('Views', { hasSidebar: true, }, res_id: 1, + mockRPC: function (route, args) { + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } + return this._super.apply(this, arguments); + }, }); assert.strictEqual(form.pager.$('.o_pager_value').text(), "1", 'pager value should be 1'); @@ -2678,6 +2711,9 @@ QUnit.module('Views', { }, res_id: 1, mockRPC: function (route, args) { + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } assert.step(args.method); return this._super.apply(this, arguments); } @@ -4844,6 +4880,9 @@ QUnit.module('Views', { "the active_ids should be an array with 1 inside."); return $.when({}); } + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } return this._super.apply(this, arguments); }, }); @@ -4852,8 +4891,14 @@ QUnit.module('Views', { // if not only 2 dropdowns are displayed. var $dropdowns = $('.o_web_client .o_control_panel .btn-group .o_dropdown_toggler_btn'); var $actions = $('.o_web_client .o_control_panel .btn-group .dropdown-menu')[1].children; - assert.strictEqual($dropdowns.length, 2, - "there should be 2 dropdowns (print, action) in the toolbar."); + if ('document.document' in odoo.__DEBUG__.services) { + assert.strictEqual($dropdowns.length, 3, + "there should be 3 dropdowns (print, attachment, action) in the toolbar."); + $actions = $('.o_web_client .o_control_panel .btn-group .dropdown-menu')[2].children; + } else { + assert.strictEqual($dropdowns.length, 2, + "there should be 2 dropdowns (print, action) in the toolbar."); + } assert.strictEqual($actions.length, 3, "there should be 3 actions"); var $customAction = $('.o_web_client .o_control_panel .btn-group .dropdown-menu:last .dropdown-item:nth(2)'); @@ -4866,7 +4911,7 @@ QUnit.module('Views', { assert.deepEqual(context.active_ids, [1], "the active_ids should be an array with 1 inside."); }); - testUtils.dom.click($dropdowns); + testUtils.dom.click($dropdowns.last()); testUtils.dom.click($customAction); form.destroy(); @@ -6121,6 +6166,9 @@ QUnit.module('Views', { res_id: 1, viewOptions: {hasSidebar: true}, mockRPC: function (route, args) { + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } var result = this._super.apply(this, arguments); if (args.method === 'copy') { return result.then(function (id) { @@ -6770,6 +6818,9 @@ QUnit.module('Views', { if (args.method === 'unlink') { assert.step('unlink'); } + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } return this._super.apply(this, arguments); }, res_id: 1, |
