diff options
| author | Nasreddin (bon) <bon@odoo.com> | 2020-11-23 16:15:54 +0000 |
|---|---|---|
| committer | Nasreddin (bon) <bon@odoo.com> | 2020-11-30 08:07:04 +0000 |
| commit | d5b5e7c8490e8de9e56f16cdef640dd733163175 (patch) | |
| tree | 9dba66a4c44e435970269cf5956dedbcd2ace4fb /addons/web | |
| parent | c52a14d3efea45236369a41f5022ad0b5e022341 (diff) | |
[FIX] web: Unable to create a new record with warning message
Issue
- Install Sales
- In Sales > Configuration > Settings -> Enable "Sale Warnings"
- Go to Sales > Orders > Customers
- Pick a customer/company
- Go in Edit mode and go to "Internal Notes" tab
- Switch "Warning on the Sales Order" from "No Message" to "Warning" and add any warning message then save
- Press the "$ X Sales" smart button
- Create a new Quotation
- Validate the warning message
- Go back to the previous menu (using the breadcrumb) or save the quotation
- Create a new quotation
The quotation form editor does not appear.
Cause
If we use the breadcrumb (or save then create), it will call the `_reload` function
(instead of `load` when the form view hasn't been opened yet).
In this case, creating a new record, it will call `_makeDefaultRecord` without
setting `allowWarning` param to true (like it is done in the ref. commit bellow).
Solution
Set `allowWarning` param to true before calling `_makeDefaultRecord`.
related commit : https://github.com/odoo/odoo/commit/a41db9a2cf410bb233b021651a5633180eaddf18
opw-2374857
closes odoo/odoo#62534
X-original-commit: 5c8101102f999cfac6aec7658b98e376d4ed0596
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
Diffstat (limited to 'addons/web')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 1 | ||||
| -rw-r--r-- | addons/web/static/tests/views/form_tests.js | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 4a3a1930cb1..ca21cb6824d 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -4764,6 +4764,7 @@ var BasicModel = AbstractModel.extend({ fieldsInfo: element.fieldsInfo, fields: element.fields, viewType: element.viewType, + allowWarning: true, }; return this._makeDefaultRecord(element.model, params); } diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 510293f2bef..e0f179a4939 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -5557,6 +5557,44 @@ QUnit.module('Views', { form.destroy(); }); + QUnit.test('open new record even with warning message', async function (assert) { + assert.expect(3); + + this.data.partner.onchanges = { foo: true }; + + var form = await createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form string="Partners">' + + '<group><field name="foo"/></group>' + + '</form>', + res_id: 2, + mockRPC: function (route, args) { + if (args.method === 'onchange') { + return Promise.resolve({ + warning: { + title: "Warning", + message: "Any warning." + } + }); + } + return this._super.apply(this, arguments); + }, + + }); + await testUtils.form.clickEdit(form); + assert.strictEqual(form.$('input').val(), 'blip', 'input should contain record value'); + await testUtils.fields.editInput(form.$('input[name="foo"]'), "tralala"); + assert.strictEqual(form.$('input').val(), 'tralala', 'input should contain new value'); + + await form.reload({ currentId: false }); + assert.strictEqual(form.$('input').val(), '', + 'input should have no value after reload'); + + form.destroy(); + }); + QUnit.test('render stat button with string inline', async function (assert) { assert.expect(1); |
