[IMP] web: FieldMany2one: reword and simplify dialog

This commit improves the dialog that opens when a user clicks out
of an 'un-commited' many2one. It is no longer possible to edit
the value, and the sentence has been reworded.

closes odoo/odoo#49528

Task: 2234212
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Dhruv Patel
2020-05-05 15:19:45 +00:00
committed by Aaron Bohy
parent 032dd00715
commit a599f1402e
3 changed files with 7 additions and 15 deletions
@@ -42,18 +42,14 @@ var M2ODialog = Dialog.extend({
this.name = name;
this.value = value;
this._super(parent, {
title: _.str.sprintf(_t("Create a %s"), this.name),
title: _t(`New ${this.name}`),
size: 'medium',
buttons: [{
text: _t('Create'),
classes: 'btn-primary',
close: true,
click: function () {
if (this.$("input").val() !== ''){
this.trigger_up('quick_create', { value: this.$('input').val() });
this.close(true);
} else {
this.$("input").focus();
}
this.trigger_up('quick_create', { value: this.value });
},
}, {
text: _t('Create and edit'),
@@ -62,7 +58,7 @@ var M2ODialog = Dialog.extend({
click: function () {
this.trigger_up('search_create_popup', {
view_type: 'form',
value: this.$('input').val(),
value: this.value,
});
},
}, {
@@ -71,10 +67,6 @@ var M2ODialog = Dialog.extend({
}],
});
},
start: function () {
this.$("p").text(_.str.sprintf(_t("You are creating a new %s, are you sure it does not exist yet?"), this.name));
this.$("input").val(this.value);
},
/**
* @override
* @param {boolean} isSet
+1 -2
View File
@@ -1730,8 +1730,7 @@
</t>
<t t-name="M2ODialog">
<div>
<p/>
Name: <input class="o_input" type="text"/>
Do you want to create <strong t-esc="widget.value"/> as a new <t t-esc="widget.name"/>?
</div>
</t>
<t t-name="FieldMany2ManyCheckBoxes">
@@ -2183,7 +2183,7 @@ QUnit.module('fields', {}, function () {
});
QUnit.test('quick create on a many2one', async function (assert) {
assert.expect(1);
assert.expect(2);
var form = await createView({
View: FormView,
@@ -2207,6 +2207,7 @@ QUnit.module('fields', {}, function () {
await testUtils.fields.editAndTrigger(form.$('.o_field_many2one input'),
'new partner', ['keyup', 'blur']);
await testUtils.dom.click($('.modal .modal-footer .btn-primary').first());
assert.strictEqual($('.modal .modal-body').text().trim(), "Do you want to create new partner as a new Product?");
form.destroy();
});