tryton-sao 7.0.28 → 7.0.30

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.0.30 - 2025-05-15
3
+ ---------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+
6
+
7
+ Version 7.0.29 - 2025-05-02
8
+ ---------------------------
9
+ * Bug fixes (see mercurial logs for details)
10
+
11
+
2
12
  Version 7.0.28 - 2025-04-26
3
13
  ---------------------------
4
14
  * Bug fixes (see mercurial logs for details)
@@ -3,7 +3,7 @@
3
3
 
4
4
  /* eslint-disable no-redeclare */
5
5
  var Sao = {
6
- __version__: '7.0.28',
6
+ __version__: '7.0.30',
7
7
  };
8
8
  /* eslint-enable no-redeclare */
9
9
 
@@ -5199,6 +5199,15 @@ var Sao = {
5199
5199
  if (!context) {
5200
5200
  context = {};
5201
5201
  }
5202
+ function atof(string) {
5203
+ if (!string) {
5204
+ throw("empty string");
5205
+ }
5206
+ let { format } = new Intl.NumberFormat(
5207
+ Sao.i18n.BC47(Sao.i18n.getlang()));
5208
+ let [, decimalSign] = /^0(.)1$/.exec(format(0.1));
5209
+ return Number(string.replace(decimalSign, '.'));
5210
+ }
5202
5211
  var convert_selection = function() {
5203
5212
  if (typeof value == 'string') {
5204
5213
  for (var i = 0; i < field.selection.length; i++) {
@@ -5230,8 +5239,12 @@ var Sao = {
5230
5239
  },
5231
5240
  'float': function() {
5232
5241
  var factor = Number(field.factor || 1);
5233
- var result = Number(value);
5234
- if (isNaN(result) || value === '' || value === null) {
5242
+ try {
5243
+ var result = atof(value);
5244
+ } catch (e) {
5245
+ return null;
5246
+ }
5247
+ if (isNaN(result)) {
5235
5248
  return null;
5236
5249
  } else {
5237
5250
  return result / factor;
@@ -5239,18 +5252,25 @@ var Sao = {
5239
5252
  },
5240
5253
  'integer': function() {
5241
5254
  var factor = Number(field.factor || 1, 10);
5242
- var result = parseInt(value, 10);
5255
+ try {
5256
+ var result = atof(value);
5257
+ } catch (e) {
5258
+ return null;
5259
+ }
5243
5260
  if (isNaN(result)) {
5244
5261
  return null;
5245
5262
  } else {
5246
- return result / factor;
5263
+ return parseInt(result / factor, 10);
5247
5264
  }
5248
5265
  },
5249
5266
  'numeric': function() {
5250
5267
  var factor = Number(field.factor || 1);
5251
- var result = Number(value);
5252
- if (isNaN(result.valueOf()) ||
5253
- value === '' || value === null) {
5268
+ try {
5269
+ var result = atof(value);
5270
+ } catch (e) {
5271
+ return null;
5272
+ }
5273
+ if (isNaN(result)) {
5254
5274
  return null;
5255
5275
  } else {
5256
5276
  return new Sao.Decimal(result / factor);
@@ -5305,8 +5325,7 @@ var Sao = {
5305
5325
  return '';
5306
5326
  }
5307
5327
  var digit = 0;
5308
- var factor = Number(field.factor || 1);
5309
- var string = String(value * factor);
5328
+ var string = String(value);
5310
5329
  if (string.contains('e')) {
5311
5330
  var exp = string.split('e')[1];
5312
5331
  string = string.split('e')[0];
@@ -5315,7 +5334,14 @@ var Sao = {
5315
5334
  if (string.contains('.')) {
5316
5335
  digit += string.replace(/0+$/, '').split('.')[1].length;
5317
5336
  }
5318
- return (value * factor).toFixed(digit);
5337
+ var factor = Number(field.factor || 1);
5338
+ digit -= Math.round(Math.log10(factor));
5339
+ return (value * factor).toLocaleString(
5340
+ Sao.i18n.BC47(Sao.i18n.getlang()), {
5341
+ useGrouping: true,
5342
+ minimumFractionDigits: digit,
5343
+ maximumFractionDigits: digit,
5344
+ });
5319
5345
  };
5320
5346
  var format_selection = function() {
5321
5347
  if (field.selection instanceof Array) {
@@ -10035,6 +10061,7 @@ var Sao = {
10035
10061
  }
10036
10062
 
10037
10063
  if (value && (value.add || value.update)) {
10064
+ let vals_to_set = {};
10038
10065
  // First set already added fields to prevent triggering a
10039
10066
  // second on_change call
10040
10067
  if (value.update) {
@@ -10044,9 +10071,9 @@ var Sao = {
10044
10071
  }
10045
10072
  const record2 = group.get(vals.id);
10046
10073
  if (record2) {
10047
- var vals_to_set = {};
10048
10074
  for (var key in vals) {
10049
- if (!(key in new_field_names)) {
10075
+ if (!Object.prototype.hasOwnProperty.call(
10076
+ new_field_names, key)) {
10050
10077
  vals_to_set[key] = vals[key];
10051
10078
  }
10052
10079
  }
@@ -10080,7 +10107,14 @@ var Sao = {
10080
10107
  }
10081
10108
  const record2 = group.get(vals.id);
10082
10109
  if (record2) {
10083
- record2.set_on_change(vals);
10110
+ let to_update = Object.fromEntries(
10111
+ Object.entries(vals).filter(
10112
+ ([k, v]) => {
10113
+ !Object.prototype.hasOwnProperty.call(
10114
+ vals_to_set, k)
10115
+ }
10116
+ ));
10117
+ record2.set_on_change(to_update);
10084
10118
  }
10085
10119
  }
10086
10120
  }
@@ -11317,15 +11351,20 @@ var Sao = {
11317
11351
  case 'ok':
11318
11352
  return this.save();
11319
11353
  case 'ko':
11320
- var record_id = this.screen.current_record.id;
11354
+ var record_id = null;
11355
+ if (this.screen.current_record) {
11356
+ record_id = this.screen.current_record.id;
11357
+ }
11321
11358
  return this.reload(false).then(() => {
11322
- if (record_id < 0) {
11323
- return jQuery.Deferred().reject(true);
11324
- }
11325
- else if (this.screen.current_record) {
11326
- if (record_id !=
11327
- this.screen.current_record.id) {
11328
- return jQuery.Deferred().reject();
11359
+ if (record_id !== null) {
11360
+ if (record_id < 0) {
11361
+ return jQuery.Deferred().reject(true);
11362
+ }
11363
+ else if (this.screen.current_record) {
11364
+ if (record_id !=
11365
+ this.screen.current_record.id) {
11366
+ return jQuery.Deferred().reject();
11367
+ }
11329
11368
  }
11330
11369
  }
11331
11370
  });
@@ -12833,7 +12872,7 @@ var Sao = {
12833
12872
  Sao.ScreenContainer.BetweenDates._super.init.call(this, id);
12834
12873
  this.from.change(this._from_changed.bind(this));
12835
12874
  },
12836
- _get_value: function(entry, value) {
12875
+ _get_value: function(entry) {
12837
12876
  return entry.find('input[type=text]').val();
12838
12877
  },
12839
12878
  _set_value: function(entry, value) {
@@ -12946,11 +12985,17 @@ var Sao = {
12946
12985
  'class': 'form-control input-sm',
12947
12986
  'type': 'number',
12948
12987
  'step': 'any',
12988
+ 'lang': Sao.i18n.getlang(),
12949
12989
  }).appendTo(el);
12950
12990
  return entry;
12951
12991
  },
12952
- _get_value: function(entry, value) {
12953
- return entry.val();
12992
+ _get_value: function(entry) {
12993
+ let value = entry.val();
12994
+ if (value) {
12995
+ value = Number(value).toLocaleString(
12996
+ Sao.i18n.BC47(Sao.i18n.getlang()))
12997
+ }
12998
+ return value;
12954
12999
  },
12955
13000
  _set_value: function(entry, value) {
12956
13001
  return entry.val(value);
@@ -13502,9 +13547,6 @@ var Sao = {
13502
13547
  return this.__current_record;
13503
13548
  },
13504
13549
  set current_record(record) {
13505
- if ((this.__current_record === record) && record) {
13506
- return;
13507
- }
13508
13550
  this.__current_record = record;
13509
13551
  var pos = null;
13510
13552
  var record_id = null;
@@ -16042,7 +16084,8 @@ function eval_pyson(value){
16042
16084
  class_: 'form',
16043
16085
  init: function(languages, widget) {
16044
16086
  var dialog = new Sao.Dialog(
16045
- Sao.i18n.gettext('Translate'), this.class_, 'md');
16087
+ Sao.i18n.gettext('Translate'), this.class_,
16088
+ widget.expand? 'lg' : 'md');
16046
16089
  this.languages = languages;
16047
16090
  this.read(widget, dialog);
16048
16091
  jQuery('<button/>', {
@@ -16134,10 +16177,10 @@ function eval_pyson(value){
16134
16177
  input.uniqueId();
16135
16178
  row.append(jQuery('<label/>', {
16136
16179
  'for': input.attr('id'),
16137
- 'class': 'col-sm-3 control-label',
16180
+ 'class': 'col-sm-2 control-label',
16138
16181
  }).append(' ' + lang.name));
16139
16182
  row.append(jQuery('<div/>', {
16140
- 'class': 'col-sm-9 input-group',
16183
+ 'class': 'col-sm-10 input-group',
16141
16184
  }).append(input)
16142
16185
  .append(jQuery('<span/>', {
16143
16186
  'class': 'input-group-addon',
@@ -21168,7 +21211,8 @@ function eval_pyson(value){
21168
21211
  'type': 'button',
21169
21212
  'title': Sao.i18n.gettext("More"),
21170
21213
  }).text(Sao.i18n.gettext('More')
21171
- ).click(() => {
21214
+ ).one('click', () => {
21215
+ this.tbody.find('tr.more-row').remove();
21172
21216
  var height = this.table.height();
21173
21217
  this.display_size += Sao.config.display_size;
21174
21218
  this.display();
@@ -24760,9 +24804,10 @@ function eval_pyson(value){
24760
24804
  });
24761
24805
  },
24762
24806
  clear: function() {
24763
- var kinds = this.el.children().each(
24764
- (i, el) => jQuery(el).data('kind'));
24765
- new Set(kinds).forEach(kind => {
24807
+ let kinds = new Set();
24808
+ this.el.children().each(
24809
+ (i, el) => kinds.add(jQuery(el).data('kind')));
24810
+ kinds.forEach(kind => {
24766
24811
  this.refresh(kind);
24767
24812
  });
24768
24813
  this.__messages.clear();