tryton-sao 6.0.65 → 6.0.67

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 6.0.67 - 2025-10-20
3
+ ---------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+ * Use sandboxed iframe to display document (issue14290)
6
+
7
+ Version 6.0.66 - 2025-10-02
8
+ ---------------------------
9
+ * Bug fixes (see mercurial logs for details)
10
+
11
+
2
12
  Version 6.0.65 - 2025-09-15
3
13
  ---------------------------
4
14
  * Bug fixes (see mercurial logs for details)
@@ -9922,19 +9922,31 @@ img.icon {
9922
9922
  width: 4em;
9923
9923
  height: 4em;
9924
9924
  }
9925
- .form .form-document object {
9925
+ .form .form-document object,
9926
+ .form .form-document img {
9926
9927
  object-fit: scale-down;
9927
9928
  object-position: center top;
9929
+ }
9930
+ .form .form-document iframe {
9931
+ border: 0;
9932
+ }
9933
+ .form .form-document object,
9934
+ .form .form-document iframe,
9935
+ .form .form-document img {
9928
9936
  width: 100%;
9929
9937
  height: 75vh;
9930
9938
  }
9931
9939
  @media screen and (max-width: 991px) {
9932
- .form .form-document object {
9940
+ .form .form-document object,
9941
+ .form .form-document iframe,
9942
+ .form .form-document img {
9933
9943
  height: 50vh;
9934
9944
  }
9935
9945
  }
9936
9946
  @media screen and (max-width: 767px) {
9937
- .form .form-document object {
9947
+ .form .form-document object,
9948
+ .form .form-document iframe,
9949
+ .form .form-document img {
9938
9950
  height: 25vh;
9939
9951
  }
9940
9952
  }
@@ -18434,15 +18434,42 @@ function eval_pyson(value){
18434
18434
  'class': this.class_,
18435
18435
  });
18436
18436
 
18437
- this.object = jQuery('<object/>', {
18437
+ this.content = this._create_content().appendTo(this.el);
18438
+ },
18439
+ _create_content: function(mimetype, url) {
18440
+ let tag_name = 'iframe';
18441
+ if (mimetype) {
18442
+ if (mimetype.startsWith('image/')) {
18443
+ tag_name = 'img';
18444
+ } else if (mimetype == 'application/pdf') {
18445
+ tag_name = 'object';
18446
+ }
18447
+ }
18448
+ let content = jQuery(`<${tag_name}/>`, {
18438
18449
  'class': 'center-block',
18439
- }).appendTo(this.el);
18440
- if (attributes.height) {
18441
- this.object.css('height', parseInt(attributes.height, 10));
18450
+ });
18451
+ if (tag_name == 'iframe') {
18452
+ content.attr('sandbox', '');
18453
+ }
18454
+ if (this.attributes.height) {
18455
+ content.css('height', parseInt(this.attributes.height, 10));
18442
18456
  }
18443
- if (attributes.width) {
18444
- this.object.css('width', parseInt(attributes.width, 10));
18457
+ if (this.attributes.width) {
18458
+ content.css('width', parseInt(this.attributes.width, 10));
18459
+ }
18460
+ if (url) {
18461
+ // set onload before data/src to be always called
18462
+ content.get().onload = function() {
18463
+ this.onload = null;
18464
+ window.URL.revokeObjectURL(url);
18465
+ };
18466
+ if (tag_name== 'object') {
18467
+ content.attr('data', url);
18468
+ } else {
18469
+ content.attr('src', url);
18470
+ }
18445
18471
  }
18472
+ return content;
18446
18473
  },
18447
18474
  display: function() {
18448
18475
  Sao.View.Form.Document._super.display.call(this);
@@ -18458,31 +18485,29 @@ function eval_pyson(value){
18458
18485
  filename = filename_field.get_client(record);
18459
18486
  }
18460
18487
  data.done(function(data) {
18461
- var url, blob;
18462
18488
  if (record !== this.record) {
18463
18489
  return;
18464
18490
  }
18491
+ let url = this.content.attr('data') ||
18492
+ this.content.attr('src');
18493
+ window.URL.revokeObjectURL(url);
18494
+ let mimetype;
18465
18495
  if (!data) {
18466
18496
  url = null;
18467
18497
  } else {
18468
- var mimetype = Sao.common.guess_mimetype(filename);
18498
+ mimetype = Sao.common.guess_mimetype(filename);
18469
18499
  if (mimetype == 'application/octet-binary') {
18470
18500
  mimetype = null;
18471
18501
  }
18472
- blob = new Blob([data], {
18502
+ let blob = new Blob([data], {
18473
18503
  'type': mimetype,
18474
18504
  });
18475
18505
  url = window.URL.createObjectURL(blob);
18476
18506
  }
18477
18507
  // duplicate object to force refresh on buggy browsers
18478
- var object = this.object.clone();
18479
- object.attr('data', url);
18480
- object.get(0).onload = function() {
18481
- window.URL.revokeObjectURL(url);
18482
- };
18483
- object.attr('data', url);
18484
- this.object.replaceWith(object);
18485
- this.object = object;
18508
+ let content = this._create_content(mimetype, url);
18509
+ this.content.replaceWith(content);
18510
+ this.content = content;
18486
18511
  }.bind(this));
18487
18512
  },
18488
18513
  });
@@ -22531,20 +22556,15 @@ function eval_pyson(value){
22531
22556
  }
22532
22557
  };
22533
22558
  }
22559
+ let keys = this._data_keys(data);
22534
22560
  var color = this.view.attributes.color || Sao.config.graph_color;
22535
22561
  var rgb = Sao.common.hex2rgb(
22536
22562
  Sao.common.COLOR_SCHEMES[color] || color);
22537
22563
  var maxcolor = Math.max.apply(null, rgb);
22538
- var keys = [];
22539
- var i, yfield;
22540
- for (i = 0; i < this.yfields.length; i++) {
22541
- yfield = this.yfields[i];
22542
- keys.push(yfield.key || yfield.name);
22543
- }
22544
22564
  var colors = Sao.common.generateColorscheme(
22545
22565
  color, keys, maxcolor / (keys.length || 1));
22546
- for (i = 0; i < this.yfields.length; i++) {
22547
- yfield = this.yfields[i];
22566
+ for (let i = 0; i < this.yfields.length; i++) {
22567
+ let yfield = this.yfields[i];
22548
22568
  if (yfield.color) {
22549
22569
  colors[yfield.key || yfield.name] = yfield.color;
22550
22570
  }
@@ -22556,6 +22576,14 @@ function eval_pyson(value){
22556
22576
  };
22557
22577
  return c3_config;
22558
22578
  },
22579
+ _data_keys: function(data) {
22580
+ let keys = [];
22581
+ for (let i = 0; i < this.yfields.length; i++) {
22582
+ let yfield = this.yfields[i];
22583
+ keys.push(yfield.key || yfield.name);
22584
+ }
22585
+ return keys;
22586
+ },
22559
22587
  action: function(data, element) {
22560
22588
  var ids = this.ids[this._action_key(data)];
22561
22589
  var ctx = jQuery.extend({}, this.view.screen.group._context);
@@ -22654,8 +22682,16 @@ function eval_pyson(value){
22654
22682
 
22655
22683
  config.data.columns = pie_columns;
22656
22684
  config.data.names = pie_names;
22685
+ config.data.order = null;
22657
22686
  return config;
22658
22687
  },
22688
+ _data_keys: function(data) {
22689
+ let keys = [];
22690
+ for (let i = 0; i < data.columns[1].length - 1; i++) {
22691
+ keys.push(i);
22692
+ }
22693
+ return keys;
22694
+ },
22659
22695
  _add_id: function(key, id) {
22660
22696
  var type = this.xfield.type;
22661
22697
  if ((type == 'date') || (type == 'datetime')) {
@@ -9922,19 +9922,31 @@ img.icon {
9922
9922
  width: 4em;
9923
9923
  height: 4em;
9924
9924
  }
9925
- .form .form-document object {
9925
+ .form .form-document object,
9926
+ .form .form-document img {
9926
9927
  object-fit: scale-down;
9927
9928
  object-position: center top;
9929
+ }
9930
+ .form .form-document iframe {
9931
+ border: 0;
9932
+ }
9933
+ .form .form-document object,
9934
+ .form .form-document iframe,
9935
+ .form .form-document img {
9928
9936
  width: 100%;
9929
9937
  height: 75vh;
9930
9938
  }
9931
9939
  @media screen and (max-width: 991px) {
9932
- .form .form-document object {
9940
+ .form .form-document object,
9941
+ .form .form-document iframe,
9942
+ .form .form-document img {
9933
9943
  height: 50vh;
9934
9944
  }
9935
9945
  }
9936
9946
  @media screen and (max-width: 767px) {
9937
- .form .form-document object {
9947
+ .form .form-document object,
9948
+ .form .form-document iframe,
9949
+ .form .form-document img {
9938
9950
  height: 25vh;
9939
9951
  }
9940
9952
  }