tryton-sao 7.0.2 → 7.0.3

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.0.3 - 2023-12-16
3
+ --------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+
6
+
2
7
  Version 7.0.2 - 2023-12-01
3
8
  --------------------------
4
9
  * Bug fixes (see mercurial logs for details)
@@ -1,7 +1,7 @@
1
1
  /* This file is part of Tryton. The COPYRIGHT file at the top level of
2
2
  this repository contains the full copyright notices and license terms. */
3
3
  var Sao = {
4
- __version__: '7.0.2',
4
+ __version__: '7.0.3',
5
5
  };
6
6
 
7
7
  (function() {
@@ -3256,12 +3256,14 @@ var Sao = {
3256
3256
 
3257
3257
  Sao.common.scrollIntoViewIfNeeded = function(element) {
3258
3258
  element = element[0];
3259
- var rect = element.getBoundingClientRect();
3260
- if (rect.bottom > window.innerHeight) {
3261
- element.scrollIntoView(false);
3262
- }
3263
- if (rect.top < 0) {
3264
- element.scrollIntoView();
3259
+ if (element) {
3260
+ var rect = element.getBoundingClientRect();
3261
+ if (rect.bottom > window.innerHeight) {
3262
+ element.scrollIntoView(false);
3263
+ }
3264
+ if (rect.top < 0) {
3265
+ element.scrollIntoView();
3266
+ }
3265
3267
  }
3266
3268
  };
3267
3269
 
@@ -4106,9 +4108,7 @@ var Sao = {
4106
4108
  } else {
4107
4109
  this.el.show();
4108
4110
  }
4109
- this.el.prop(
4110
- 'disabled',
4111
- (record? record.readonly : false) || Boolean(states.readonly));
4111
+ this.el.prop('disabled', Boolean(states.readonly));
4112
4112
  this.set_icon(states.icon || this.attributes.icon);
4113
4113
 
4114
4114
  if (this.attributes.rule) {
@@ -5927,12 +5927,12 @@ var Sao = {
5927
5927
  }
5928
5928
  return this.simplify(this.merge(result));
5929
5929
  },
5930
- unique_value: function(domain) {
5930
+ unique_value: function(domain, single_value=true) {
5931
5931
  if ((domain instanceof Array) &&
5932
5932
  (domain.length == 1)) {
5933
5933
  let [name, operator, value, ...model] = domain[0];
5934
5934
  if (operator == '=' ||
5935
- (operator == 'in' && value.length == 1)) {
5935
+ (single_value && operator == 'in' && value.length == 1)) {
5936
5936
  value = operator == '=' ? value : value[0];
5937
5937
  var count = 0;
5938
5938
  if (model.length && name.endsWith('.id')) {
@@ -8375,6 +8375,7 @@ var Sao = {
8375
8375
  }
8376
8376
  if (this.model.fields[name] instanceof Sao.field.One2Many) {
8377
8377
  later[name] = value;
8378
+ continue;
8378
8379
  }
8379
8380
  const field = this.model.fields[name];
8380
8381
  var related;
@@ -8399,6 +8400,7 @@ var Sao = {
8399
8400
  value = later[name];
8400
8401
  this.model.fields[name].set(this, value);
8401
8402
  this._loaded[name] = true;
8403
+ fieldnames.push(name);
8402
8404
  }
8403
8405
  if (validate) {
8404
8406
  this.validate(fieldnames, true, false, false);
@@ -9095,6 +9097,7 @@ var Sao = {
9095
9097
 
9096
9098
  Sao.field.Field = Sao.class_(Object, {
9097
9099
  _default: null,
9100
+ _single_value: true,
9098
9101
  init: function(description) {
9099
9102
  this.description = description;
9100
9103
  this.name = description.name;
@@ -9267,12 +9270,13 @@ var Sao = {
9267
9270
  } else {
9268
9271
  let [screen_domain, _] = this.get_domains(
9269
9272
  record, pre_validate);
9270
- var uniques = inversion.unique_value(domain);
9273
+ var uniques = inversion.unique_value(
9274
+ domain, this._single_value);
9271
9275
  var unique = uniques[0];
9272
9276
  var leftpart = uniques[1];
9273
9277
  var value = uniques[2];
9274
9278
  let unique_from_screen = inversion.unique_value(
9275
- screen_domain)[0];
9279
+ screen_domain, this._single_value)[0];
9276
9280
  if (this._is_empty(record) &&
9277
9281
  !is_required &&
9278
9282
  !is_invisible &&
@@ -9360,6 +9364,7 @@ var Sao = {
9360
9364
 
9361
9365
  Sao.field.MultiSelection = Sao.class_(Sao.field.Selection, {
9362
9366
  _default: null,
9367
+ _single_value: false,
9363
9368
  get: function(record) {
9364
9369
  var value = Sao.field.MultiSelection._super.get.call(this, record);
9365
9370
  if (jQuery.isEmptyObject(value)) {
@@ -9742,6 +9747,7 @@ var Sao = {
9742
9747
  Sao.field.One2Many._super.init.call(this, description);
9743
9748
  },
9744
9749
  _default: null,
9750
+ _single_value: false,
9745
9751
  _set_value: function(record, value, default_, modified) {
9746
9752
  this._set_default_value(record);
9747
9753
  var group = record._values[this.name];
@@ -10352,6 +10358,7 @@ var Sao = {
10352
10358
 
10353
10359
  Sao.field.Dict = Sao.class_(Sao.field.Field, {
10354
10360
  _default: {},
10361
+ _single_value: false,
10355
10362
  init: function(description) {
10356
10363
  Sao.field.Dict._super.init.call(this, description);
10357
10364
  this.schema_model = new Sao.Model(description.schema_model);
@@ -10763,8 +10770,9 @@ var Sao = {
10763
10770
  return toolbar;
10764
10771
  },
10765
10772
  show: function() {
10766
- jQuery('#tablist').find('a[href="#' + this.id + '"]')
10767
- .tab('show')[0].scrollIntoView();
10773
+ Sao.common.scrollIntoViewIfNeeded(
10774
+ jQuery('#tablist').find('a[href="#' + this.id + '"]')
10775
+ .tab('show'));
10768
10776
  },
10769
10777
  close: function() {
10770
10778
  var tabs = jQuery('#tabs');
@@ -10849,8 +10857,8 @@ var Sao = {
10849
10857
  }
10850
10858
  for (const other of Sao.Tab.tabs) {
10851
10859
  if (other.compare(attributes)) {
10852
- tablist.find('a[href="#' + other.id + '"]')
10853
- .tab('show')[0].scrollIntoView();
10860
+ Sao.common.scrollIntoViewIfNeeded(
10861
+ tablist.find('a[href="#' + other.id + '"]').tab('show'));
10854
10862
  return;
10855
10863
  }
10856
10864
  }
@@ -10907,7 +10915,7 @@ var Sao = {
10907
10915
  tab_link.on('shown.bs.tab', function(evt) {
10908
10916
  tabs.scrollTop(jQuery(evt.target).data('scrollTop') || 0);
10909
10917
  });
10910
- tab_link.tab('show')[0].scrollIntoView();
10918
+ Sao.common.scrollIntoViewIfNeeded(tab_link.tab('show'));
10911
10919
  tabs.trigger('ready');
10912
10920
  };
10913
10921
 
@@ -11507,7 +11515,6 @@ var Sao = {
11507
11515
  ['delete_', access.delete],
11508
11516
  ['copy', access.create],
11509
11517
  ['import', access.create],
11510
- ['action', access.write && !this.screen.readonly],
11511
11518
  ]);
11512
11519
  for (const [name, access] of accesses) {
11513
11520
  if (this.buttons[name]) {
@@ -11520,7 +11527,7 @@ var Sao = {
11520
11527
  }
11521
11528
  } else {
11522
11529
  for (const name of [
11523
- 'new_', 'save', 'delete_', 'copy', 'import', 'action']) {
11530
+ 'new_', 'save', 'delete_', 'copy', 'import']) {
11524
11531
  if (this.buttons[name]) {
11525
11532
  this.buttons[name].prop('disabled', true);
11526
11533
  }
@@ -11754,8 +11761,8 @@ var Sao = {
11754
11761
  preview.record_message = function(position, length) {
11755
11762
  var text = (position || '_') + '/' + length;
11756
11763
  label.text(text).attr('title', text);
11757
- but_prev.prop('disabled', !position || position <= 1);
11758
- but_next.prop('disabled', !position || position >= length);
11764
+ but_prev.prop('disabled', !screen.has_previous());
11765
+ but_next.prop('disabled', !screen.has_next());
11759
11766
  };
11760
11767
  screen.windows.push(preview);
11761
11768
 
@@ -11780,7 +11787,13 @@ var Sao = {
11780
11787
  if (!Sao.common.compare(this.attachment_screen.domain, domain) ||
11781
11788
  force) {
11782
11789
  this.attachment_screen.domain = domain;
11783
- this.attachment_screen.search_filter();
11790
+ this.attachment_screen.search_filter().then(() => {
11791
+ const group = this.attachment_screen.group;
11792
+ if (group.length) {
11793
+ this.attachment_screen.current_record = group[0];
11794
+ this.attachment_screen.display();
11795
+ }
11796
+ });
11784
11797
  }
11785
11798
  },
11786
11799
  note: function() {
@@ -14049,8 +14062,7 @@ var Sao = {
14049
14062
  var buttons = this.current_view.get_buttons();
14050
14063
  for (const record of selected_records) {
14051
14064
  buttons = buttons.filter(function(button) {
14052
- if (record.readonly ||
14053
- button.attributes.type === 'instance') {
14065
+ if (button.attributes.type === 'instance') {
14054
14066
  return false;
14055
14067
  }
14056
14068
  var states = record.expr_eval(
@@ -19155,7 +19167,7 @@ function eval_pyson(value){
19155
19167
  },
19156
19168
  set_url: function(value) {
19157
19169
  this.button.attr('href', value);
19158
- this.button.prop('disabled', !value);
19170
+ this.button.toggle(value);
19159
19171
  },
19160
19172
  set_invisible: function(invisible) {
19161
19173
  Sao.View.Form.URL._super.set_invisible.call(this, invisible);
@@ -20915,12 +20927,14 @@ function eval_pyson(value){
20915
20927
  } else if (name === this.screen.exclude_field) {
20916
20928
  visible_columns -= 1;
20917
20929
  column.set_visible(false);
20918
- } else {
20930
+ } else if (name in this.screen.model.fields) {
20931
+ const field = this.screen.model.fields[name];
20919
20932
  var inv_domain = inversion.domain_inversion(domain, name);
20920
20933
  if (typeof inv_domain != 'boolean') {
20921
20934
  inv_domain = inversion.simplify(inv_domain);
20922
20935
  }
20923
- var unique = inversion.unique_value(inv_domain)[0];
20936
+ var unique = inversion.unique_value(
20937
+ inv_domain, field._single_value)[0];
20924
20938
  if (unique && jQuery.isEmptyObject(this.children_field)) {
20925
20939
  visible_columns -= 1;
20926
20940
  column.set_visible(false);