summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorMartin Geubelle <mge@odoo.com>2017-10-19 18:05:17 +0200
committerMartin Geubelle <mge@odoo.com>2017-10-20 11:25:32 +0200
commit2455350c40df86266eabd614ceab451159d67be3 (patch)
treea08b76d02a4413633d8280ccc447496f3c38059d /addons/web/static/tests/fields/basic_fields_tests.js
parent1312ee72cf35e3887721ac56472f1188f636ec61 (diff)
[FIX] web: deal with `date` widget on datetime
This use case was not correctly managed as the function evaluating if the value has changed compares datetime and date. This triggered an issue if the widget `date` was set on the field `date_order` on a purchase order for example ; it was not possible to create a record as the datapoint was set `dirty`. This rev. ensures that a `field_changed` is not triggered if the day is the same on a date widget. This rev. also adds support of `datetime` fields on date widget, which appears to be a valid use case. Fixes https://github.com/odoo/odoo/issues/20311
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js33
1 files changed, 33 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 1e3233128d6..f05d7abf08e 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -1823,6 +1823,39 @@ QUnit.module('basic_fields', {
form.destroy();
});
+ QUnit.test('do not trigger a field_changed for datetime field with date widget', function (assert) {
+ assert.expect(3);
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch:'<form string="Partners"><field name="datetime" widget="date"/></form>',
+ translateParameters: { // Avoid issues due to localization formats
+ date_format: '%m/%d/%Y',
+ time_format: '%H:%M:%S',
+ },
+ res_id: 1,
+ viewOptions: {
+ mode: 'edit',
+ },
+ mockRPC: function (route, args) {
+ assert.step(args.method);
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ assert.strictEqual(form.$('.o_datepicker_input').val(), '02/08/2017',
+ 'the date should be correct');
+
+ form.$('input[name="datetime"]').val('02/08/2017').trigger('input').trigger('change');
+ form.$buttons.find('.o_form_button_save').click();
+
+ assert.verifySteps(['read']); // should not have save as nothing changed
+
+ form.destroy();
+ });
+
QUnit.module('FieldDatetime');
QUnit.test('datetime field in form view', function (assert) {