[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: 02eef78bbd 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>
This commit is contained in:
Mohammed Shekha
2018-11-15 09:37:22 +01:00
committed by Aaron Bohy
co-authored by Tejas Shahu
parent 94a9fc9902
commit f3f20653d3
2 changed files with 66 additions and 2 deletions
@@ -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);
+63 -1
View File
@@ -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");