[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.
This commit is contained in:
committed by
Aaron Bohy
parent
acbbdd1a73
commit
83dab2d0dc
@@ -1240,14 +1240,6 @@ var FieldBooleanButton = AbstractField.extend({
|
||||
},
|
||||
});
|
||||
|
||||
var FieldID = InputField.extend({
|
||||
supportedFieldTypes: ['id'],
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this.mode = 'readonly';
|
||||
},
|
||||
});
|
||||
|
||||
var StatInfo = AbstractField.extend({
|
||||
supportedFieldTypes: ['integer', 'float'],
|
||||
_render: function () {
|
||||
@@ -1902,7 +1894,6 @@ return {
|
||||
FieldFloat: FieldFloat,
|
||||
FieldFloatTime: FieldFloatTime,
|
||||
FieldHtml: FieldHtml,
|
||||
FieldID: FieldID,
|
||||
FieldInteger: FieldInteger,
|
||||
FieldMonetary: FieldMonetary,
|
||||
FieldPercentPie: FieldPercentPie,
|
||||
|
||||
@@ -40,7 +40,6 @@ registry
|
||||
.add('label_selection', basic_fields.LabelSelection)
|
||||
.add('state_selection', basic_fields.StateSelectionWidget)
|
||||
.add('boolean_button', basic_fields.FieldBooleanButton)
|
||||
.add('id', basic_fields.FieldID)
|
||||
.add('statinfo', basic_fields.StatInfo)
|
||||
.add('percentpie', basic_fields.FieldPercentPie)
|
||||
.add('float_time', basic_fields.FieldFloatTime)
|
||||
|
||||
@@ -142,17 +142,6 @@ function formatFloatTime(value) {
|
||||
return _.str.sprintf(pattern, hour, min);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing an ID. If the value is false, then we
|
||||
* return an empty string.
|
||||
*
|
||||
* @param {integer|false} value
|
||||
* @returns {string}
|
||||
*/
|
||||
function formatID(value) {
|
||||
return value ? value.toString() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing an integer. If the value is false, then we
|
||||
* return an empty string.
|
||||
@@ -390,7 +379,6 @@ return {
|
||||
float: formatFloat,
|
||||
float_time: formatFloatTime,
|
||||
html: _.identity, // todo
|
||||
id: formatID,
|
||||
integer: formatInteger,
|
||||
many2many: formatMany2Many,
|
||||
many2one: formatMany2one,
|
||||
@@ -409,7 +397,6 @@ return {
|
||||
float: parseFloat,
|
||||
float_time: parseFloatTime,
|
||||
html: _.identity, // todo
|
||||
id: _.identity,
|
||||
integer: parseInteger,
|
||||
many2many: _.identity, // todo
|
||||
many2one: parseMany2one,
|
||||
|
||||
@@ -219,13 +219,6 @@ return core.Class.extend({
|
||||
var doc = $.parseXML(fields_view.arch).documentElement;
|
||||
fields_view.arch = utils.xml_to_json(doc, (doc.nodeName.toLowerCase() !== 'kanban'));
|
||||
|
||||
// Special case for id's
|
||||
if ('id' in fields_view.fields) {
|
||||
var id_field = fields_view.fields.id;
|
||||
id_field.original_type = id_field.type;
|
||||
id_field.type = 'id';
|
||||
}
|
||||
|
||||
// Process inner views (x2manys)
|
||||
_.each(fields_view.fields, function(field) {
|
||||
_.each(field.views || {}, function(view) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user