tryton-sao 7.6.1 → 7.6.2

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,9 @@
1
1
 
2
+ Version 7.6.2 - 2025-06-04
3
+ --------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+
6
+
2
7
  Version 7.6.1 - 2025-05-15
3
8
  --------------------------
4
9
  * 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.6.0',
6
+ __version__: '7.6.2',
7
7
  };
8
8
  /* eslint-enable no-redeclare */
9
9
 
@@ -675,6 +675,7 @@ var Sao = {
675
675
  "Incompatible version of the server."),
676
676
  Sao.i18n.gettext("Version mismatch"));
677
677
  } else {
678
+ let url = window.location.hash.substr(1);
678
679
  Sao.Session.get_credentials()
679
680
  .then(function(session) {
680
681
  Sao.Session.current_session = session;
@@ -684,7 +685,7 @@ var Sao = {
684
685
  .then(function(preferences) {
685
686
  Sao.menu(preferences);
686
687
  Sao.user_menu(preferences);
687
- Sao.open_url();
688
+ Sao.open_url(url);
688
689
  Sao.Bus.listen();
689
690
  });
690
691
  }
@@ -7721,16 +7722,19 @@ var Sao = {
7721
7722
  'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D');
7722
7723
  }
7723
7724
  var type = '';
7724
- try {
7725
- var xml = data;
7726
- if (xml instanceof Uint8Array) {
7727
- xml = new TextDecoder().decode(data);
7728
- }
7729
- if (jQuery.parseXML(xml)) {
7725
+ var xml = data;
7726
+ if (xml instanceof Uint8Array) {
7727
+ xml = new TextDecoder().decode(data);
7728
+ }
7729
+ // simple test to avoid logging of parsing error
7730
+ if (/^\s*<[\s\S]+>\s*$/.test(xml.trim())) {
7731
+ let parser = new DOMParser();
7732
+ let doc = parser.parseFromString(xml, 'image/svg+xml');
7733
+ if (!doc.querySelector('parsererror')
7734
+ && (doc.documentElement.tagName.toLowerCase() === 'svg' ||
7735
+ doc.getElementsByTagName('svg').length > 0)) {
7730
7736
  type = 'image/svg+xml';
7731
7737
  }
7732
- } catch (e) {
7733
- // continue
7734
7738
  }
7735
7739
  var blob = new Blob([data], {type: type});
7736
7740
  return window.URL.createObjectURL(blob);
@@ -9529,7 +9533,6 @@ var Sao = {
9529
9533
  // XXX to remove once server domains are fixed
9530
9534
  value = null;
9531
9535
  }
9532
- var setdefault = true;
9533
9536
  var original_domain;
9534
9537
  if (!jQuery.isEmptyObject(record.group.domain)) {
9535
9538
  original_domain = inversion.merge(record.group.domain);
@@ -9537,20 +9540,12 @@ var Sao = {
9537
9540
  original_domain = inversion.merge(domain);
9538
9541
  }
9539
9542
  var domain_readonly = original_domain[0] == 'AND';
9543
+ let setdefault;
9540
9544
  if (leftpart.contains('.')) {
9541
- var recordpart = leftpart.split('.', 1)[0];
9542
- var localpart = leftpart.split('.', 1)[1];
9543
- var constraintfields = [];
9544
- if (domain_readonly) {
9545
- for (const leaf of inversion.localize_domain(
9546
- original_domain.slice(1))) {
9547
- constraintfields.push(leaf);
9548
- }
9549
- }
9550
- if ((localpart != 'id') ||
9551
- !~constraintfields.indexOf(recordpart)) {
9552
- setdefault = false;
9553
- }
9545
+ let localpart = leftpart.split('.').slice(1).join('.');
9546
+ setdefault = localpart == 'id';
9547
+ } else {
9548
+ setdefault = true;
9554
9549
  }
9555
9550
  if (setdefault && jQuery.isEmptyObject(pre_validate)) {
9556
9551
  this.set_client(record, value);
@@ -9820,12 +9815,23 @@ var Sao = {
9820
9815
  },
9821
9816
  apply_factor: function(record, value, factor) {
9822
9817
  if (value !== null) {
9818
+ // The default precision is the one used by value (before
9819
+ // applying the factor), per the ecmascript specification
9820
+ // it's the shortest representation of said value.
9821
+ // Once the factor is applied the number might become even
9822
+ // more inexact thus we should rely on the initial
9823
+ // precision + the effect factor will have
9824
+ // https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#sec-numeric-types-number-tostring
9825
+ let default_precision = (value.toString().split('.')[1] || '').length;
9826
+ default_precision += Math.ceil(Math.log10(factor));
9823
9827
  value /= factor;
9824
9828
  var digits = this.digits(record);
9825
9829
  if (digits && (digits[1] !== null)) {
9826
9830
  // Round to avoid float precision error
9827
9831
  // after the division by factor
9828
9832
  value = value.toFixed(digits[1]);
9833
+ } else {
9834
+ value = value.toFixed(default_precision);
9829
9835
  }
9830
9836
  value = this.convert(value);
9831
9837
  }
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.6.1",
5
+ "version": "7.6.2",
6
6
  "homepage": "https://www.tryton.org/",
7
7
  "author": {
8
8
  "name": "Tryton"
package/src/common.js CHANGED
@@ -4389,16 +4389,19 @@
4389
4389
  'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D');
4390
4390
  }
4391
4391
  var type = '';
4392
- try {
4393
- var xml = data;
4394
- if (xml instanceof Uint8Array) {
4395
- xml = new TextDecoder().decode(data);
4396
- }
4397
- if (jQuery.parseXML(xml)) {
4392
+ var xml = data;
4393
+ if (xml instanceof Uint8Array) {
4394
+ xml = new TextDecoder().decode(data);
4395
+ }
4396
+ // simple test to avoid logging of parsing error
4397
+ if (/^\s*<[\s\S]+>\s*$/.test(xml.trim())) {
4398
+ let parser = new DOMParser();
4399
+ let doc = parser.parseFromString(xml, 'image/svg+xml');
4400
+ if (!doc.querySelector('parsererror')
4401
+ && (doc.documentElement.tagName.toLowerCase() === 'svg' ||
4402
+ doc.getElementsByTagName('svg').length > 0)) {
4398
4403
  type = 'image/svg+xml';
4399
4404
  }
4400
- } catch (e) {
4401
- // continue
4402
4405
  }
4403
4406
  var blob = new Blob([data], {type: type});
4404
4407
  return window.URL.createObjectURL(blob);
package/src/model.js CHANGED
@@ -1771,7 +1771,6 @@
1771
1771
  // XXX to remove once server domains are fixed
1772
1772
  value = null;
1773
1773
  }
1774
- var setdefault = true;
1775
1774
  var original_domain;
1776
1775
  if (!jQuery.isEmptyObject(record.group.domain)) {
1777
1776
  original_domain = inversion.merge(record.group.domain);
@@ -1779,20 +1778,12 @@
1779
1778
  original_domain = inversion.merge(domain);
1780
1779
  }
1781
1780
  var domain_readonly = original_domain[0] == 'AND';
1781
+ let setdefault;
1782
1782
  if (leftpart.contains('.')) {
1783
- var recordpart = leftpart.split('.', 1)[0];
1784
- var localpart = leftpart.split('.', 1)[1];
1785
- var constraintfields = [];
1786
- if (domain_readonly) {
1787
- for (const leaf of inversion.localize_domain(
1788
- original_domain.slice(1))) {
1789
- constraintfields.push(leaf);
1790
- }
1791
- }
1792
- if ((localpart != 'id') ||
1793
- !~constraintfields.indexOf(recordpart)) {
1794
- setdefault = false;
1795
- }
1783
+ let localpart = leftpart.split('.').slice(1).join('.');
1784
+ setdefault = localpart == 'id';
1785
+ } else {
1786
+ setdefault = true;
1796
1787
  }
1797
1788
  if (setdefault && jQuery.isEmptyObject(pre_validate)) {
1798
1789
  this.set_client(record, value);
@@ -2062,12 +2053,23 @@
2062
2053
  },
2063
2054
  apply_factor: function(record, value, factor) {
2064
2055
  if (value !== null) {
2056
+ // The default precision is the one used by value (before
2057
+ // applying the factor), per the ecmascript specification
2058
+ // it's the shortest representation of said value.
2059
+ // Once the factor is applied the number might become even
2060
+ // more inexact thus we should rely on the initial
2061
+ // precision + the effect factor will have
2062
+ // https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#sec-numeric-types-number-tostring
2063
+ let default_precision = (value.toString().split('.')[1] || '').length;
2064
+ default_precision += Math.ceil(Math.log10(factor));
2065
2065
  value /= factor;
2066
2066
  var digits = this.digits(record);
2067
2067
  if (digits && (digits[1] !== null)) {
2068
2068
  // Round to avoid float precision error
2069
2069
  // after the division by factor
2070
2070
  value = value.toFixed(digits[1]);
2071
+ } else {
2072
+ value = value.toFixed(default_precision);
2071
2073
  }
2072
2074
  value = this.convert(value);
2073
2075
  }
package/src/sao.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  /* eslint-disable no-redeclare */
5
5
  var Sao = {
6
- __version__: '7.6.0',
6
+ __version__: '7.6.2',
7
7
  };
8
8
  /* eslint-enable no-redeclare */
9
9
 
@@ -675,6 +675,7 @@ var Sao = {
675
675
  "Incompatible version of the server."),
676
676
  Sao.i18n.gettext("Version mismatch"));
677
677
  } else {
678
+ let url = window.location.hash.substr(1);
678
679
  Sao.Session.get_credentials()
679
680
  .then(function(session) {
680
681
  Sao.Session.current_session = session;
@@ -684,7 +685,7 @@ var Sao = {
684
685
  .then(function(preferences) {
685
686
  Sao.menu(preferences);
686
687
  Sao.user_menu(preferences);
687
- Sao.open_url();
688
+ Sao.open_url(url);
688
689
  Sao.Bus.listen();
689
690
  });
690
691
  }