summaryrefslogtreecommitdiff
path: root/addons/web/static/test/fields
diff options
context:
space:
mode:
authorDavid Monjoie <dmo@odoo.com>2017-03-27 11:23:17 +0200
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit83dab2d0dcab28607b82550190ea295bd31c167e (patch)
treec4a6e8b10885e57c919221b81ffb4995de8f38cf /addons/web/static/test/fields
parentacbbdd1a7337032e673aa51ec66f3c9d209db324 (diff)
[REM] web: remove id widget
The original reason why this widget was created is because sometimes, the id is a virtual one, represented by string in the webclient. As such, the integer widget could not render it properly since it could not parse the integer from the string. This led to the following bug, which in turn led to the creation of the id widget: https://bugs.launchpad.net/openerp-web/+bug/919184 Now, virtual ids are not handled within the record data itself anymore, making it a non-issue to render the id field in the webclient since it is not given a value until a proper id is created. The virtual id management is completely out of the view scope now, rendering this widget useless.
Diffstat (limited to 'addons/web/static/test/fields')
-rw-r--r--addons/web/static/test/fields/relational_fields_tests.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/addons/web/static/test/fields/relational_fields_tests.js b/addons/web/static/test/fields/relational_fields_tests.js
index 7ac8e12afee..9b562b1a3a9 100644
--- a/addons/web/static/test/fields/relational_fields_tests.js
+++ b/addons/web/static/test/fields/relational_fields_tests.js
@@ -2173,6 +2173,83 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('one2many field with virtual ids', function (assert) {
+ assert.expect(11);
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<sheet>' +
+ '<group>' +
+ '<notebook>' +
+ '<page>' +
+ '<field name="p" mode="kanban">' +
+ '<kanban>' +
+ '<templates>' +
+ '<t t-name="kanban-box">' +
+ '<div class="oe_kanban_details">' +
+ '<div class="o_test_id">' +
+ '<field name="id"/>' +
+ '</div>' +
+ '<div class="o_test_foo">' +
+ '<field name="foo"/>' +
+ '</div>' +
+ '</div>' +
+ '</t>' +
+ '</templates>' +
+ '</kanban>' +
+ '</field>' +
+ '</page>' +
+ '</notebook>' +
+ '</group>' +
+ '</sheet>' +
+ '</form>',
+ archs: {
+ 'partner,false,form': '<form string="Associated partners">' +
+ '<field name="foo"/>' +
+ '</form>',
+ },
+ res_id: 4,
+ });
+
+ assert.strictEqual(form.$('.o_form_field .o_kanban_view').length, 1,
+ "should have one inner kanban view for the one2many field");
+ assert.strictEqual(form.$('.o_form_field .o_kanban_view .o_kanban_record:not(.o_kanban_ghost)').length, 0,
+ "should not have kanban records yet");
+
+ // // switch to edit mode and create a new kanban record
+ form.$buttons.find('.o_form_button_edit').click();
+ form.$('.o_form_field .o-kanban-button-new').click();
+
+ // save & close the modal
+ assert.strictEqual($('.modal-content input.o_form_field').val(), 'My little Foo Value',
+ "should already have the default value for field foo");
+ $('.modal-content .btn-primary').first().click();
+
+ assert.strictEqual(form.$('.o_form_field .o_kanban_view').length, 1,
+ "should have one inner kanban view for the one2many field");
+ assert.strictEqual(form.$('.o_form_field .o_kanban_view .o_kanban_record:not(.o_kanban_ghost)').length, 1,
+ "should now have one kanban record");
+ assert.strictEqual(form.$('.o_form_field .o_kanban_view .o_kanban_record:not(.o_kanban_ghost) .o_test_id').text(),
+ '', "should not have a value for the id field");
+ assert.strictEqual(form.$('.o_form_field .o_kanban_view .o_kanban_record:not(.o_kanban_ghost) .o_test_foo').text(),
+ 'My little Foo Value', "should have a value for the foo field");
+
+ // save the view to force a create of the new record in the one2many
+ form.$buttons.find('.o_form_button_save').click();
+ assert.strictEqual(form.$('.o_form_field .o_kanban_view').length, 1,
+ "should have one inner kanban view for the one2many field");
+ assert.strictEqual(form.$('.o_form_field .o_kanban_view .o_kanban_record:not(.o_kanban_ghost)').length, 1,
+ "should now have one kanban record");
+ assert.notEqual(form.$('.o_form_field .o_kanban_view .o_kanban_record:not(.o_kanban_ghost) .o_test_id').text(),
+ '', "should now have a value for the id field");
+ assert.strictEqual(form.$('.o_form_field .o_kanban_view .o_kanban_record:not(.o_kanban_ghost) .o_test_foo').text(),
+ 'My little Foo Value', "should still have a value for the foo field");
+
+ form.destroy();
+ });
QUnit.module('FieldMany2Many');