summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2018-11-16 13:25:24 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2018-11-19 15:38:22 +0000
commit596af12c21ae1df4679bfc526c6724e9b5453e0b (patch)
tree3c342b5f781980bb542ecd99d0f8b4c6c77cc65f /addons/web/static/tests/fields/basic_fields_tests.js
parent5eb2fbdec3e58c6b545cd7e96dc9a24adcd12b84 (diff)
[FIX] web: dateField datepicker don't propagate field options
In a form view (account.invoice), have a date field as: <field name="date" options="{\'datepicker\': {\'warn_future\': true}}"/> Open a record with the field set to a value Click Edit, click save Click create Before this commit, the value of the field of the new record took the one of the previous record On account invoices, it resulted on having the popup "The record has been modified etc...." And it was not possible to create an invoice from another one this was because we passed the same reference object for the datepicker After this commit, there is no popup as the field do not take a value from the framework OPW 1906085 closes odoo/odoo#28759
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index f1640b06c82..eaa4a53e5db 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -2776,6 +2776,42 @@ QUnit.module('basic_fields', {
form.destroy();
});
+ QUnit.test('date field with warn_future option: do not overwrite datepicker option', function (assert) {
+ assert.expect(2);
+
+ // Making sure we don't have a legit default value
+ // or any onchange that would set the value
+ this.data.partner.fields.date.default = undefined;
+ this.data.partner.onchanges = {};
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch:'<form string="Partners">' +
+ '<field name="foo" />' + // Do not let the date field get the focus in the first place
+ '<field name="date" options="{\'datepicker\': {\'warn_future\': true}}"/>' +
+ '</form>',
+ res_id: 1,
+ });
+
+ // switch to edit mode
+ form.$buttons.find('.o_form_button_edit').click();
+ assert.strictEqual(form.$('input[name="date"]').val(), '02/03/2017',
+ 'The existing record should have a value for the date field');
+
+ // save with no changes
+ form.$buttons.find('.o_form_button_save').click();
+
+ //Create a new record
+ form.$buttons.find('.o_form_button_create').click();
+
+ assert.notOk(form.$('input[name="date"]').val(),
+ 'The new record should not have a value that the framework would have set');
+
+ form.destroy();
+ });
+
QUnit.test('date field in editable list view', function (assert) {
assert.expect(8);