tryton-sao 7.4.7 → 7.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG CHANGED
@@ -1,4 +1,14 @@
1
1
 
2
+ Version 7.4.9 - 2025-04-26
3
+ --------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+
6
+
7
+ Version 7.4.8 - 2025-04-02
8
+ --------------------------
9
+ * Bug fixes (see mercurial logs for details)
10
+
11
+
2
12
  Version 7.4.7 - 2025-03-15
3
13
  --------------------------
4
14
  * Bug fixes (see mercurial logs for details)
@@ -10547,6 +10547,9 @@ input.column-boolean {
10547
10547
  float: none;
10548
10548
  }
10549
10549
  @media screen and (max-width: 767px) {
10550
+ .form-dict-container {
10551
+ grid-template-columns: 100%;
10552
+ }
10550
10553
  .dict-row {
10551
10554
  grid-column: 1;
10552
10555
  }
@@ -3,7 +3,7 @@
3
3
 
4
4
  /* eslint-disable no-redeclare */
5
5
  var Sao = {
6
- __version__: '7.4.7',
6
+ __version__: '7.4.9',
7
7
  };
8
8
  /* eslint-enable no-redeclare */
9
9
 
@@ -4165,7 +4165,7 @@ var Sao = {
4165
4165
  });
4166
4166
  }
4167
4167
  };
4168
- this._selection_prm.done(_update_selection);
4168
+ this._selection_prm.always(_update_selection);
4169
4169
  };
4170
4170
  Sao.common.selection_mixin.filter_selection = function(
4171
4171
  domain, record, field) {
@@ -7703,7 +7703,7 @@ var Sao = {
7703
7703
  'use strict';
7704
7704
 
7705
7705
  function get_x2m_sub_fields(f_attrs, prefix) {
7706
- if (f_attrs.visible && f_attrs.views) {
7706
+ if (f_attrs.visible && !jQuery.isEmptyObject(f_attrs.views)) {
7707
7707
  // There's only one key but we don't know its value
7708
7708
  const [[, view],] = Object.entries(f_attrs.views);
7709
7709
 
@@ -8285,6 +8285,7 @@ var Sao = {
8285
8285
  this.autocompletion = {};
8286
8286
  this.exception = false;
8287
8287
  this.destroyed = false;
8288
+ this._save_prm = jQuery.when();
8288
8289
  },
8289
8290
  get modified() {
8290
8291
  if (!jQuery.isEmptyObject(this.modified_fields)) {
@@ -8298,33 +8299,28 @@ var Sao = {
8298
8299
  },
8299
8300
  save: function(force_reload=false) {
8300
8301
  var context = this.get_context();
8302
+ if (this._save_prm.state() == 'pending') {
8303
+ return this._save_prm.then(() => this.save(force_reload));
8304
+ }
8301
8305
  var prm = jQuery.when();
8302
8306
  if ((this.id < 0) || this.modified) {
8303
8307
  var values = this.get();
8304
- try {
8305
- // synchronous call to avoid multiple creation or save
8306
- if (this.id < 0) {
8307
- this.id = this.model.execute(
8308
- 'create', [[values]], context, false)[0];
8309
-
8310
- } else {
8311
- if (!jQuery.isEmptyObject(values)) {
8312
- context._timestamp = this.get_timestamp();
8313
- this.model.execute(
8314
- 'write', [[this.id], values], context, false);
8315
- }
8316
- }
8317
- } catch (e) {
8318
- if (e.promise) {
8319
- return e.then(() => this.save(force_reload));
8320
- } else {
8321
- return jQuery.Deferred().reject();
8308
+ if (this.id < 0) {
8309
+ prm = this.model.execute('create', [[values]], context)
8310
+ .then(ids => this.id = ids[0]);
8311
+ } else {
8312
+ if (!jQuery.isEmptyObject(values)) {
8313
+ context._timestamp = this.get_timestamp();
8314
+ prm = this.model.execute(
8315
+ 'write', [[this.id], values], context);
8322
8316
  }
8323
8317
  }
8324
- this.cancel();
8325
- if (force_reload) {
8326
- return this.reload();
8327
- }
8318
+ prm = prm.then(() => {
8319
+ this.cancel();
8320
+ if (force_reload) {
8321
+ return this.reload();
8322
+ }
8323
+ });
8328
8324
  if (this.group) {
8329
8325
  prm = prm.then(() => this.group.written(this.id));
8330
8326
  }
@@ -8333,6 +8329,7 @@ var Sao = {
8333
8329
  delete this.group.parent.modified_fields[this.group.child_name];
8334
8330
  prm = prm.then(() => this.group.parent.save(force_reload));
8335
8331
  }
8332
+ this._save_prm = prm;
8336
8333
  return prm;
8337
8334
  },
8338
8335
  reload: function(fields, async=true) {
@@ -14015,7 +14012,6 @@ var Sao = {
14015
14012
  },
14016
14013
  save_current: function() {
14017
14014
  var current_record = this.current_record;
14018
- let new_record = current_record.id < 0;
14019
14015
  if (!current_record) {
14020
14016
  if (this.current_view &&
14021
14017
  (this.current_view.view_type == 'tree') &&
@@ -14026,6 +14022,7 @@ var Sao = {
14026
14022
  return jQuery.when();
14027
14023
  }
14028
14024
  }
14025
+ let new_record = current_record.id < 0;
14029
14026
  if (this.current_view) {
14030
14027
  this.current_view.set_value();
14031
14028
  var fields = this.current_view.get_fields();
@@ -14696,7 +14693,8 @@ var Sao = {
14696
14693
  return view.display(selected_nodes);
14697
14694
  } else {
14698
14695
  var record;
14699
- if (!jQuery.isEmptyObject(selected_nodes)) {
14696
+ if (!jQuery.isEmptyObject(selected_nodes) &&
14697
+ !this.current_record) {
14700
14698
  for (const id of selected_nodes[0]) {
14701
14699
  const new_record = this.group.get(id);
14702
14700
  if (!new_record) {
@@ -20518,7 +20516,6 @@ function eval_pyson(value){
20518
20516
  _parse: Sao.common.parse_date,
20519
20517
  create_widget: function() {
20520
20518
  Sao.View.Form.Dict.Date._super.create_widget.call(this);
20521
- var group = this.input.parent().find('.input-group-btn');
20522
20519
  this.input_date = jQuery('<input/>', {
20523
20520
  'type': this._input,
20524
20521
  'role': 'button',
@@ -20539,12 +20536,15 @@ function eval_pyson(value){
20539
20536
  }
20540
20537
  });
20541
20538
  if (this.input_date[0].type == this._input) {
20542
- var icon = jQuery('<button/>', {
20543
- 'class': 'btn btn-default',
20544
- 'type': 'button',
20539
+ var group = jQuery('<div/>', {
20540
+ 'class': 'input-icon input-icon-secondary',
20541
+ }).prependTo(this.input.parent());
20542
+ this.input.appendTo(group);
20543
+ var icon = jQuery('<div/>', {
20544
+ 'class': 'icon-input icon-secondary',
20545
20545
  'aria-label': Sao.i18n.gettext("Open the calendar"),
20546
20546
  'title': Sao.i18n.gettext("Open the calendar"),
20547
- }).prependTo(group);
20547
+ }).appendTo(group);
20548
20548
  this.input_date.appendTo(icon);
20549
20549
  Sao.common.ICONFACTORY.get_icon_img('tryton-date')
20550
20550
  .appendTo(icon);
@@ -20574,8 +20574,7 @@ function eval_pyson(value){
20574
20574
  return this._parse(this.format, this.input.val());
20575
20575
  },
20576
20576
  set_value: function(value) {
20577
- if ((value instanceof Sao.DateTime) ||
20578
- (value instanceof Sao.Date)) {
20577
+ if (value && (value.isDate || value.isDateTime)) {
20579
20578
  value = this._format(this.format, value);
20580
20579
  } else {
20581
20580
  value = '';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "tryton-sao",
3
3
  "title": "sao",
4
4
  "description": "Tryton webclient",
5
- "version": "7.4.7",
5
+ "version": "7.4.9",
6
6
  "homepage": "https://www.tryton.org/",
7
7
  "author": {
8
8
  "name": "Tryton"
package/src/common.js CHANGED
@@ -833,7 +833,7 @@
833
833
  });
834
834
  }
835
835
  };
836
- this._selection_prm.done(_update_selection);
836
+ this._selection_prm.always(_update_selection);
837
837
  };
838
838
  Sao.common.selection_mixin.filter_selection = function(
839
839
  domain, record, field) {
package/src/model.js CHANGED
@@ -4,7 +4,7 @@
4
4
  'use strict';
5
5
 
6
6
  function get_x2m_sub_fields(f_attrs, prefix) {
7
- if (f_attrs.visible && f_attrs.views) {
7
+ if (f_attrs.visible && !jQuery.isEmptyObject(f_attrs.views)) {
8
8
  // There's only one key but we don't know its value
9
9
  const [[, view],] = Object.entries(f_attrs.views);
10
10
 
@@ -586,6 +586,7 @@
586
586
  this.autocompletion = {};
587
587
  this.exception = false;
588
588
  this.destroyed = false;
589
+ this._save_prm = jQuery.when();
589
590
  },
590
591
  get modified() {
591
592
  if (!jQuery.isEmptyObject(this.modified_fields)) {
@@ -599,33 +600,28 @@
599
600
  },
600
601
  save: function(force_reload=false) {
601
602
  var context = this.get_context();
603
+ if (this._save_prm.state() == 'pending') {
604
+ return this._save_prm.then(() => this.save(force_reload));
605
+ }
602
606
  var prm = jQuery.when();
603
607
  if ((this.id < 0) || this.modified) {
604
608
  var values = this.get();
605
- try {
606
- // synchronous call to avoid multiple creation or save
607
- if (this.id < 0) {
608
- this.id = this.model.execute(
609
- 'create', [[values]], context, false)[0];
610
-
611
- } else {
612
- if (!jQuery.isEmptyObject(values)) {
613
- context._timestamp = this.get_timestamp();
614
- this.model.execute(
615
- 'write', [[this.id], values], context, false);
616
- }
617
- }
618
- } catch (e) {
619
- if (e.promise) {
620
- return e.then(() => this.save(force_reload));
621
- } else {
622
- return jQuery.Deferred().reject();
609
+ if (this.id < 0) {
610
+ prm = this.model.execute('create', [[values]], context)
611
+ .then(ids => this.id = ids[0]);
612
+ } else {
613
+ if (!jQuery.isEmptyObject(values)) {
614
+ context._timestamp = this.get_timestamp();
615
+ prm = this.model.execute(
616
+ 'write', [[this.id], values], context);
623
617
  }
624
618
  }
625
- this.cancel();
626
- if (force_reload) {
627
- return this.reload();
628
- }
619
+ prm = prm.then(() => {
620
+ this.cancel();
621
+ if (force_reload) {
622
+ return this.reload();
623
+ }
624
+ });
629
625
  if (this.group) {
630
626
  prm = prm.then(() => this.group.written(this.id));
631
627
  }
@@ -634,6 +630,7 @@
634
630
  delete this.group.parent.modified_fields[this.group.child_name];
635
631
  prm = prm.then(() => this.group.parent.save(force_reload));
636
632
  }
633
+ this._save_prm = prm;
637
634
  return prm;
638
635
  },
639
636
  reload: function(fields, async=true) {
package/src/sao.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  /* eslint-disable no-redeclare */
5
5
  var Sao = {
6
- __version__: '7.4.7',
6
+ __version__: '7.4.9',
7
7
  };
8
8
  /* eslint-enable no-redeclare */
9
9
 
package/src/sao.less CHANGED
@@ -1194,6 +1194,9 @@ input.column-boolean {
1194
1194
  }
1195
1195
 
1196
1196
  @media screen and (max-width: @screen-xs-max) {
1197
+ .form-dict-container {
1198
+ grid-template-columns: 100%;
1199
+ }
1197
1200
  .dict-row {
1198
1201
  grid-column: 1;
1199
1202
  }
package/src/screen.js CHANGED
@@ -1606,7 +1606,6 @@
1606
1606
  },
1607
1607
  save_current: function() {
1608
1608
  var current_record = this.current_record;
1609
- let new_record = current_record.id < 0;
1610
1609
  if (!current_record) {
1611
1610
  if (this.current_view &&
1612
1611
  (this.current_view.view_type == 'tree') &&
@@ -1617,6 +1616,7 @@
1617
1616
  return jQuery.when();
1618
1617
  }
1619
1618
  }
1619
+ let new_record = current_record.id < 0;
1620
1620
  if (this.current_view) {
1621
1621
  this.current_view.set_value();
1622
1622
  var fields = this.current_view.get_fields();
@@ -2287,7 +2287,8 @@
2287
2287
  return view.display(selected_nodes);
2288
2288
  } else {
2289
2289
  var record;
2290
- if (!jQuery.isEmptyObject(selected_nodes)) {
2290
+ if (!jQuery.isEmptyObject(selected_nodes) &&
2291
+ !this.current_record) {
2291
2292
  for (const id of selected_nodes[0]) {
2292
2293
  const new_record = this.group.get(id);
2293
2294
  if (!new_record) {
package/src/view/form.js CHANGED
@@ -5631,7 +5631,6 @@ function eval_pyson(value){
5631
5631
  _parse: Sao.common.parse_date,
5632
5632
  create_widget: function() {
5633
5633
  Sao.View.Form.Dict.Date._super.create_widget.call(this);
5634
- var group = this.input.parent().find('.input-group-btn');
5635
5634
  this.input_date = jQuery('<input/>', {
5636
5635
  'type': this._input,
5637
5636
  'role': 'button',
@@ -5652,12 +5651,15 @@ function eval_pyson(value){
5652
5651
  }
5653
5652
  });
5654
5653
  if (this.input_date[0].type == this._input) {
5655
- var icon = jQuery('<button/>', {
5656
- 'class': 'btn btn-default',
5657
- 'type': 'button',
5654
+ var group = jQuery('<div/>', {
5655
+ 'class': 'input-icon input-icon-secondary',
5656
+ }).prependTo(this.input.parent());
5657
+ this.input.appendTo(group);
5658
+ var icon = jQuery('<div/>', {
5659
+ 'class': 'icon-input icon-secondary',
5658
5660
  'aria-label': Sao.i18n.gettext("Open the calendar"),
5659
5661
  'title': Sao.i18n.gettext("Open the calendar"),
5660
- }).prependTo(group);
5662
+ }).appendTo(group);
5661
5663
  this.input_date.appendTo(icon);
5662
5664
  Sao.common.ICONFACTORY.get_icon_img('tryton-date')
5663
5665
  .appendTo(icon);
@@ -5687,8 +5689,7 @@ function eval_pyson(value){
5687
5689
  return this._parse(this.format, this.input.val());
5688
5690
  },
5689
5691
  set_value: function(value) {
5690
- if ((value instanceof Sao.DateTime) ||
5691
- (value instanceof Sao.Date)) {
5692
+ if (value && (value.isDate || value.isDateTime)) {
5692
5693
  value = this._format(this.format, value);
5693
5694
  } else {
5694
5695
  value = '';