[MERGE] forward port branch saas-12.2 up to c9f832d9f0

closes odoo/odoo#31790

Signed-off-by: Christophe Simonis <chs@odoo.com>
This commit is contained in:
Christophe Simonis
2019-03-13 14:24:51 +00:00
281 changed files with 5134 additions and 3440 deletions
@@ -1409,45 +1409,79 @@ QUnit.module('basic_fields', {
list.destroy();
});
QUnit.module('copy_clipboard', {
beforeEach: function () {
this.data = {
partner: {
fields: {
script_external: {string: "Script External", type: "text"},
web_page: {string: "Web page link", type: "char"}
},
records: [{
id: 1,
script_external:'Random Text',
web_page: 'web page links'
},],
},
};
}
});
QUnit.module('CopyClipboard');
QUnit.test('Char & Text Fields: Copy to clipboard button', async function (assert) {
assert.expect(2);
var done = assert.async();
testUtils.createView({
var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form string="Partners">' +
'<sheet>' +
'<div>' +
'<field name="script_external" widget="CopyClipboardText"/>' +
'<field name="web_page" widget="CopyClipboardChar"/>' +
'<field name="txt" widget="CopyClipboardText"/>' +
'<field name="foo" widget="CopyClipboardChar"/>' +
'</div>' +
'</sheet>' +
'</form>',
}).then(function (form) {
assert.containsOnce(form, '.o_clipboard_button.o_btn_text_copy',"Should have copy button on text type field");
assert.containsOnce(form, '.o_clipboard_button.o_btn_char_copy',"Should have copy button on char type field");
form.destroy();
done();
res_id: 1,
});
assert.containsOnce(form, '.o_clipboard_button.o_btn_text_copy',"Should have copy button on text type field");
assert.containsOnce(form, '.o_clipboard_button.o_btn_char_copy',"Should have copy button on char type field");
form.destroy();
});
QUnit.test('CopyClipboard widget on unset field', async function (assert) {
assert.expect(1);
this.data.partner.records[0].foo = false;
var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form>' +
'<sheet>' +
'<group>' +
'<field name="foo" widget="CopyClipboardChar" />' +
'</group>' +
'</sheet>' +
'</form>',
res_id: 1,
});
assert.containsNone(form, '.o_field_copy[name="foo"] .o_clipboard_button',
"foo (unset) should not contain a button");
form.destroy();
});
QUnit.test('CopyClipboard widget on readonly unset fields in create mode', async function (assert) {
assert.expect(1);
this.data.partner.fields.display_name.readonly = true;
var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form>' +
'<sheet>' +
'<group>' +
'<field name="display_name" widget="CopyClipboardChar" />' +
'</group>' +
'</sheet>' +
'</form>',
});
assert.containsNone(form, '.o_field_copy[name="display_name"] .o_clipboard_button',
"the readonly unset field should not contain a button");
form.destroy();
});
QUnit.module('FieldText');