summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorMohammed Shekha <msh@openerp.com>2018-07-02 17:56:42 +0530
committerAaron Bohy <aab@odoo.com>2018-11-15 09:37:22 +0100
commitf3f20653d34bf307ea4aeb36830a378e85c02bf6 (patch)
tree8f61d9bf97b3de5340ef5bb1ad70b5de607c8f2d /addons
parent94a9fc990212667e1893104eeaa5bd95d4b2ebaa (diff)
[FIX] web: update renderer when _callButtonAction failed
Before this rev., the following scenario didn't work: Open manufacturing order and click on Produce button (note that bom product should have Serial number enabled) then add quantity in Done field in o2m and press Record Production button in wizard, it will produce UserError and after then if you change Lot number field in wizard's o2m then the many2one value doesn't get selected. This occured because the renderer wasn't updated after the RPC fail and thus still got an outdated version of the state. The issue raised after commit: 02eef78bbd3 which was done to remove useless rpc call, it's OK to remove rpc call but let's keep updating renderer. Related to task ID: #1852715 Co-authored-by: Tejas Shahu <tsh@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/web/static/src/js/views/basic/basic_controller.js4
-rw-r--r--addons/web/static/tests/views/form_tests.js64
2 files changed, 66 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js
index 5767969d15c..edf345b41f2 100644
--- a/addons/web/static/src/js/views/basic/basic_controller.js
+++ b/addons/web/static/src/js/views/basic/basic_controller.js
@@ -261,7 +261,9 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
resIDs: record.res_ids,
},
on_success: def.resolve.bind(def),
- on_fail: def.reject.bind(def),
+ on_fail: function () {
+ self.update({}, {reload: false}).always(def.reject.bind(def));
+ },
on_closed: reload,
});
return this.alive(def);
diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js
index a6176ab4328..53a46b2a558 100644
--- a/addons/web/static/tests/views/form_tests.js
+++ b/addons/web/static/tests/views/form_tests.js
@@ -6892,6 +6892,69 @@ QUnit.module('Views', {
form.destroy();
});
+ QUnit.test('keep editing after call_button fail', function (assert) {
+ assert.expect(4);
+
+ var values;
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch:'<form>' +
+ '<button name="post" class="p" string="Raise Error" type="object"/>' +
+ '<field name="p">' +
+ '<tree editable="top">' +
+ '<field name="display_name"/>' +
+ '<field name="product_id"/>' +
+ '</tree>' +
+ '</field>' +
+ '</form>',
+ res_id: 1,
+ intercepts: {
+ execute_action: function (ev) {
+ assert.ok(true, 'the action is correctly executed');
+ ev.data.on_fail();
+ },
+ },
+ mockRPC: function (route, args) {
+ if (args.method === 'write') {
+ assert.deepEqual(args.args[1].p[0][2], values);
+ }
+ return this._super.apply(this, arguments);
+ },
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ // add a row and partially fill it
+ form.$('.o_field_x2many_list_row_add a').click();
+ form.$('input:nth(0)').val('abc').trigger('input');
+
+ // click button which will trigger_up 'execute_action' (this will save)
+ values = {
+ display_name: 'abc',
+ product_id: false,
+ };
+ form.$('button.p').click();
+
+ // edit the new row again and set a many2one value
+ form.$('.o_form_view .o_field_one2many .o_data_row .o_data_cell').click();
+ var $dropdown = form.$('.o_field_many2one input').autocomplete('widget');
+ form.$('.o_field_many2one input').click();
+ $dropdown.find('li:first()').click();
+
+ assert.strictEqual(form.$('.o_field_many2one input').val(), 'xphone',
+ "value of the m2o should have been correctly updated");
+
+ values = {
+ product_id: 37,
+ };
+ form.$buttons.find('.o_form_button_save').click();
+
+ form.destroy();
+ });
+
QUnit.module('FormViewTABMainButtons');
@@ -7057,7 +7120,6 @@ QUnit.module('Views', {
'</sheet>' +
'</form>',
res_id: 2,
- //debug:1,
});
assert.strictEqual(form.$buttons.find('.o_form_button_edit')[0],document.activeElement,
"in read mode, when there are no primary buttons on the form, the default button with the focus should be edit");