tryton-sao 7.0.10 → 7.0.12

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.12 - 2024-06-15
3
+ ---------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+
6
+
7
+ Version 7.0.11 - 2024-05-01
8
+ ---------------------------
9
+ * Bug fixes (see mercurial logs for details)
10
+
11
+
2
12
  Version 7.0.10 - 2024-04-17
3
13
  ---------------------------
4
14
  * Bug fixes (see mercurial logs for details)
@@ -9950,8 +9950,8 @@ img.icon {
9950
9950
  min-height: 150px;
9951
9951
  max-height: 300px;
9952
9952
  }
9953
- .form .form-text > textarea,
9954
- .form .form-richtext > textarea,
9953
+ .form .form-text textarea,
9954
+ .form .form-richtext textarea,
9955
9955
  .form .form-text .richtext,
9956
9956
  .form .form-richtext .richtext {
9957
9957
  height: 100%;
@@ -3,7 +3,7 @@
3
3
 
4
4
  /* eslint-disable no-redeclare */
5
5
  var Sao = {
6
- __version__: '7.0.10',
6
+ __version__: '7.0.12',
7
7
  };
8
8
  /* eslint-enable no-redeclare */
9
9
 
@@ -3663,10 +3663,14 @@ var Sao = {
3663
3663
  if (!refresh) {
3664
3664
  this._access = {};
3665
3665
  }
3666
- this._models = Sao.rpc({
3667
- 'method': 'model.ir.model.list_models',
3668
- 'params': [{}]
3669
- }, Sao.Session.current_session, false);
3666
+ try {
3667
+ this._models = Sao.rpc({
3668
+ 'method': 'model.ir.model.list_models',
3669
+ 'params': [{}]
3670
+ }, Sao.Session.current_session, false);
3671
+ } catch(e) {
3672
+ Sao.Logger.error("Unable to get model list.");
3673
+ }
3670
3674
  },
3671
3675
  get: function(model) {
3672
3676
  if (this._access[model] !== undefined) {
@@ -3680,10 +3684,23 @@ var Sao = {
3680
3684
  var to_load = this._models.slice(
3681
3685
  Math.max(0, idx - Math.floor(this.batchnum / 2)),
3682
3686
  idx + Math.floor(this.batchnum / 2));
3683
- var access = Sao.rpc({
3684
- 'method': 'model.ir.model.access.get_access',
3685
- 'params': [to_load, {}]
3686
- }, Sao.Session.current_session, false);
3687
+ var access;
3688
+ try {
3689
+ access = Sao.rpc({
3690
+ 'method': 'model.ir.model.access.get_access',
3691
+ 'params': [to_load, {}]
3692
+ }, Sao.Session.current_session, false);
3693
+ } catch(e) {
3694
+ Sao.Logger.error(`Unable to get access for ${model}.`);
3695
+ access = {
3696
+ model: {
3697
+ 'read': true,
3698
+ 'write': false,
3699
+ 'create': false,
3700
+ 'delete': false,
3701
+ },
3702
+ };
3703
+ }
3687
3704
  this._access = jQuery.extend(this._access, access);
3688
3705
  return this._access[model];
3689
3706
  }
@@ -7060,7 +7077,7 @@ var Sao = {
7060
7077
  });
7061
7078
  },
7062
7079
  function() {
7063
- Sao.Logger.warning(
7080
+ Sao.Logger.warn(
7064
7081
  "Unable to search for completion of %s", model);
7065
7082
  });
7066
7083
  };
@@ -13481,13 +13498,15 @@ var Sao = {
13481
13498
  },
13482
13499
  load: function(ids, set_cursor=true, modified=false, position=-1) {
13483
13500
  this.group.load(ids, modified, position);
13484
- this.current_view.reset();
13501
+ if (this.current_view) {
13502
+ this.current_view.reset();
13503
+ }
13485
13504
  this.current_record = null;
13486
13505
  return this.display(set_cursor);
13487
13506
  },
13488
13507
  display: function(set_cursor) {
13489
13508
  var deferreds = [];
13490
- if (this.views) {
13509
+ if (this.views && this.current_view) {
13491
13510
  var search_prm = this.search_active(
13492
13511
  ~['tree', 'graph', 'calendar'].indexOf(
13493
13512
  this.current_view.view_type));
@@ -13523,8 +13542,9 @@ var Sao = {
13523
13542
  },
13524
13543
  _get_next_record: function() {
13525
13544
  var view = this.current_view;
13526
- if (~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13527
- this.current_record && this.current_record.group) {
13545
+ if (view &&
13546
+ ~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13547
+ this.current_record && this.current_record.group) {
13528
13548
  var group = this.current_record.group;
13529
13549
  var record = this.current_record;
13530
13550
  while (group) {
@@ -13553,16 +13573,19 @@ var Sao = {
13553
13573
  },
13554
13574
  display_next: function() {
13555
13575
  var view = this.current_view;
13556
- view.set_value();
13576
+ if (view) {
13577
+ view.set_value();
13578
+ }
13557
13579
  this.set_cursor(false, false);
13558
13580
  this.current_record = this._get_next_record();
13559
13581
  this.set_cursor(false, false);
13560
- return view.display();
13582
+ return view ? view.display() : jQuery.when();
13561
13583
  },
13562
13584
  _get_previous_record: function() {
13563
13585
  var view = this.current_view;
13564
- if (~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13565
- this.current_record && this.current_record.group) {
13586
+ if (view &&
13587
+ ~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13588
+ this.current_record && this.current_record.group) {
13566
13589
  var group = this.current_record.group;
13567
13590
  var record = this.current_record;
13568
13591
  while (group) {
@@ -13591,11 +13614,13 @@ var Sao = {
13591
13614
  },
13592
13615
  display_previous: function() {
13593
13616
  var view = this.current_view;
13594
- view.set_value();
13617
+ if (view) {
13618
+ view.set_value();
13619
+ }
13595
13620
  this.set_cursor(false, false);
13596
13621
  this.current_record = this._get_previous_record();
13597
13622
  this.set_cursor(false, false);
13598
- return view.display();
13623
+ return view ? view.display() : jQuery.when();
13599
13624
  },
13600
13625
  get selected_records() {
13601
13626
  if (this.current_view) {
@@ -13633,8 +13658,9 @@ var Sao = {
13633
13658
  });
13634
13659
  },
13635
13660
  default_row_activate: function() {
13636
- if ((this.current_view.view_type == 'tree') &&
13637
- (this.current_view.attributes.keyword_open == 1)) {
13661
+ if (this.current_view &&
13662
+ (this.current_view.view_type == 'tree') &&
13663
+ (this.current_view.attributes.keyword_open == 1)) {
13638
13664
  const id = this.get_id();
13639
13665
  if (id) {
13640
13666
  Sao.Action.exec_keyword('tree_open', {
@@ -13657,14 +13683,15 @@ var Sao = {
13657
13683
  new_: function(default_=true, defaults=null) {
13658
13684
  var previous_view = this.current_view;
13659
13685
  var prm = jQuery.when();
13660
- if (this.current_view.view_type == 'calendar') {
13686
+ if (this.current_view &&
13687
+ this.current_view.view_type == 'calendar') {
13661
13688
  var selected_date = this.current_view.get_selected_date();
13662
13689
  }
13663
13690
  if (this.current_view && !this.current_view.creatable) {
13664
13691
  prm = this.switch_view('form', undefined, true, false);
13665
13692
  }
13666
13693
  return prm.then(() => {
13667
- if (!this.current_view.editable) {
13694
+ if (!this.current_view || !this.current_view.editable) {
13668
13695
  return;
13669
13696
  }
13670
13697
  var group;
@@ -13745,23 +13772,26 @@ var Sao = {
13745
13772
  save_current: function() {
13746
13773
  var current_record = this.current_record;
13747
13774
  if (!current_record) {
13748
- if ((this.current_view.view_type == 'tree') &&
13749
- this.group && this.group.length) {
13775
+ if (this.current_view &&
13776
+ (this.current_view.view_type == 'tree') &&
13777
+ this.group && this.group.length) {
13750
13778
  this.current_record = this.group[0];
13751
13779
  current_record = this.current_record;
13752
13780
  } else {
13753
13781
  return jQuery.when();
13754
13782
  }
13755
13783
  }
13756
- this.current_view.set_value();
13757
- var fields = this.current_view.get_fields();
13784
+ if (this.current_view) {
13785
+ this.current_view.set_value();
13786
+ var fields = this.current_view.get_fields();
13787
+ }
13758
13788
  var path = current_record.get_path(this.group);
13759
13789
  var prm = jQuery.Deferred();
13760
- if (this.current_view.view_type == 'tree') {
13790
+ if (this.current_view && (this.current_view.view_type == 'tree')) {
13761
13791
  prm = this.group.save().then(() => this.current_record);
13762
13792
  } else if (current_record.validate(fields, null, null, true)) {
13763
13793
  prm = current_record.save().then(() => current_record);
13764
- } else {
13794
+ } else if (this.current_view) {
13765
13795
  return this.current_view.display().then(() => {
13766
13796
  this.set_cursor();
13767
13797
  return jQuery.Deferred().reject();
@@ -13795,7 +13825,7 @@ var Sao = {
13795
13825
  var test = function(record) {
13796
13826
  return (record.modified || record.id < 0);
13797
13827
  };
13798
- if (this.current_view.view_type != 'tree') {
13828
+ if (this.current_view && (this.current_view.view_type != 'tree')) {
13799
13829
  if (this.current_record) {
13800
13830
  if (test(this.current_record)) {
13801
13831
  return true;
@@ -13806,20 +13836,24 @@ var Sao = {
13806
13836
  return true;
13807
13837
  }
13808
13838
  }
13809
- if (this.current_view.modified) {
13839
+ if (this.current_view && this.current_view.modified) {
13810
13840
  return true;
13811
13841
  }
13812
13842
  return false;
13813
13843
  },
13814
13844
  unremove: function() {
13815
- var records = this.current_view.selected_records;
13816
- for (const record of records) {
13817
- record.group.unremove(record);
13845
+ if (this.current_view) {
13846
+ var records = this.current_view.selected_records;
13847
+ for (const record of records) {
13848
+ record.group.unremove(record);
13849
+ }
13818
13850
  }
13819
13851
  },
13820
13852
  remove: function(delete_, remove, force_remove, records) {
13821
13853
  var prm = jQuery.when();
13822
- records = records || this.current_view.selected_records;
13854
+ if (!records && this.current_view) {
13855
+ records = this.current_view.selected_records;
13856
+ }
13823
13857
  if (jQuery.isEmptyObject(records)) {
13824
13858
  return prm;
13825
13859
  }
@@ -13860,7 +13894,8 @@ var Sao = {
13860
13894
  },
13861
13895
  copy: function() {
13862
13896
  var dfd = jQuery.Deferred();
13863
- var records = this.current_view.selected_records;
13897
+ var records = (
13898
+ this.current_view ? this.current_view.selected_records : []);
13864
13899
  this.model.copy(records, this.context)
13865
13900
  .then(new_ids => {
13866
13901
  this.group.load(new_ids, false, this.new_position);
@@ -14041,14 +14076,18 @@ var Sao = {
14041
14076
  if (!this.current_record) {
14042
14077
  return null;
14043
14078
  }
14044
- this.current_view.set_value();
14079
+ if (this.current_view) {
14080
+ this.current_view.set_value();
14081
+ }
14045
14082
  return this.current_record.get();
14046
14083
  },
14047
14084
  get_on_change_value: function() {
14048
14085
  if (!this.current_record) {
14049
14086
  return null;
14050
14087
  }
14051
- this.current_view.set_value();
14088
+ if (this.current_view) {
14089
+ this.current_view.set_value();
14090
+ }
14052
14091
  return this.current_record.get_on_change_value();
14053
14092
  },
14054
14093
  reload: function(ids, written) {
@@ -14061,15 +14100,17 @@ var Sao = {
14061
14100
  promises.push(this.group.parent.root_parent.reload());
14062
14101
  }
14063
14102
  return jQuery.when.apply(jQuery, promises).then(() => {
14064
- this.display();
14103
+ return this.display();
14065
14104
  });
14066
14105
  },
14067
14106
  get_buttons: function() {
14068
- var selected_records = this.current_view.selected_records;
14107
+ var selected_records = (
14108
+ this.current_view ? this.current_view.selected_records : []);
14069
14109
  if (jQuery.isEmptyObject(selected_records)) {
14070
14110
  return [];
14071
14111
  }
14072
- var buttons = this.current_view.get_buttons();
14112
+ var buttons = (
14113
+ this.current_view ? this.current_view.get_buttons() : []);
14073
14114
  for (const record of selected_records) {
14074
14115
  buttons = buttons.filter(function(button) {
14075
14116
  if (button.attributes.type === 'instance') {
@@ -14096,12 +14137,15 @@ var Sao = {
14096
14137
  ids: ids
14097
14138
  }, null, this.context, true);
14098
14139
  }
14140
+ this.record_saved();
14099
14141
  });
14100
14142
  };
14101
14143
 
14102
- var selected_records = this.current_view.selected_records;
14103
- this.current_view.set_value();
14104
- var fields = this.current_view.get_fields();
14144
+ if (this.current_view) {
14145
+ var selected_records = this.current_view.selected_records;
14146
+ this.current_view.set_value();
14147
+ var fields = this.current_view.get_fields();
14148
+ }
14105
14149
 
14106
14150
  var prms = [];
14107
14151
  const reset_state = record => {
@@ -14193,7 +14237,8 @@ var Sao = {
14193
14237
  } else if (action.startsWith('switch')) {
14194
14238
  this.switch_view.apply(this, action.split(' ', 3).slice(1));
14195
14239
  } else if (action == 'reload') {
14196
- if (~['tree', 'graph', 'calendar'].indexOf(this.current_view.view_type) &&
14240
+ if (this.current_view &&
14241
+ ~['tree', 'graph', 'calendar'].indexOf(this.current_view.view_type) &&
14197
14242
  !this.group.parent) {
14198
14243
  this.search_filter();
14199
14244
  }
@@ -14232,7 +14277,7 @@ var Sao = {
14232
14277
  var path = ['model', this.model_name];
14233
14278
  var view_ids = this.views.map(
14234
14279
  function(v) {return v.view_id;}).concat(this.view_ids);
14235
- if (this.current_view.view_type != 'form') {
14280
+ if (this.current_view && (this.current_view.view_type != 'form')) {
14236
14281
  var search_value;
14237
14282
  if (this.attributes.search_value) {
14238
14283
  search_value = this.attributes.search_value;
@@ -14245,8 +14290,10 @@ var Sao = {
14245
14290
  }
14246
14291
  } else if (this.current_record && (this.current_record.id > -1)) {
14247
14292
  path.push(this.current_record.id);
14248
- var i = view_ids.indexOf(this.current_view.view_id);
14249
- view_ids = view_ids.slice(i).concat(view_ids.slice(0, i));
14293
+ if (this.current_view) {
14294
+ var i = view_ids.indexOf(this.current_view.view_id);
14295
+ view_ids = view_ids.slice(i).concat(view_ids.slice(0, i));
14296
+ }
14250
14297
  }
14251
14298
  if (!jQuery.isEmptyObject(view_ids)) {
14252
14299
  query_string.push(['views', dumps(view_ids)]);
@@ -14340,6 +14387,9 @@ var Sao = {
14340
14387
  set_tree_state: function() {
14341
14388
  var parent_, state, state_prm, tree_state_model;
14342
14389
  var view = this.current_view;
14390
+ if (!view) {
14391
+ return jQuery.when();
14392
+ }
14343
14393
  if (!~['tree', 'form', 'list-form'].indexOf(view.view_type)) {
14344
14394
  return jQuery.when();
14345
14395
  }
@@ -16863,10 +16913,13 @@ function eval_pyson(value){
16863
16913
  this.el = jQuery('<div/>', {
16864
16914
  'class': this.class_
16865
16915
  });
16916
+ this.group = jQuery('<div/>', {
16917
+ 'class': 'input-group',
16918
+ }).appendTo(this.el);
16866
16919
  this.input = this.labelled = jQuery('<textarea/>', {
16867
16920
  'class': 'form-control input-sm mousetrap',
16868
16921
  'name': attributes.name,
16869
- }).appendTo(this.el);
16922
+ }).appendTo(this.group);
16870
16923
  this.input.change(this.focus_out.bind(this));
16871
16924
  this.input.on('keydown', this.send_modified.bind(this));
16872
16925
  if (this.attributes.translate) {
@@ -16877,7 +16930,7 @@ function eval_pyson(value){
16877
16930
  'title': Sao.i18n.gettext("Translate"),
16878
16931
  }).appendTo(jQuery('<span/>', {
16879
16932
  'class': 'input-group-btn'
16880
- }).appendTo(this.el));
16933
+ }).appendTo(this.group));
16881
16934
  button.append(
16882
16935
  Sao.common.ICONFACTORY.get_icon_img('tryton-translate'));
16883
16936
  button.click(this.translate.bind(this));
@@ -16953,13 +17006,16 @@ function eval_pyson(value){
16953
17006
  'class': 'panel-heading',
16954
17007
  }).appendTo(this.el));
16955
17008
  }
16956
- this.input = this.labelled = jQuery('<div/>', {
16957
- 'class': 'richtext mousetrap',
16958
- 'contenteditable': true
17009
+ this.group = jQuery('<div/>', {
17010
+ 'class': 'input-group',
16959
17011
  }).appendTo(jQuery('<div/>', {
16960
- 'class': 'panel-body'
17012
+ 'class': 'panel-body',
16961
17013
  }).appendTo(this.el));
16962
- this.el.focusout(this.focus_out.bind(this));
17014
+ this.input = this.labelled = jQuery('<div/>', {
17015
+ 'class': 'richtext mousetrap',
17016
+ 'contenteditable': true,
17017
+ }).appendTo(this.group);
17018
+ this.group.focusout(this.focus_out.bind(this));
16963
17019
  if (this.attributes.translate) {
16964
17020
  var button = jQuery('<button/>', {
16965
17021
  'class': 'btn btn-default btn-sm form-control',
@@ -16968,7 +17024,7 @@ function eval_pyson(value){
16968
17024
  'title': Sao.i18n.gettext("Translate"),
16969
17025
  }).appendTo(jQuery('<span/>', {
16970
17026
  'class': 'input-group-btn',
16971
- }).appendTo(this.el));
17027
+ }).appendTo(this.group));
16972
17028
  button.append(
16973
17029
  Sao.common.ICONFACTORY.get_icon_img('tryton-translate'));
16974
17030
  button.click(this.translate.bind(this));
@@ -17481,7 +17537,7 @@ function eval_pyson(value){
17481
17537
  _update_completion: function(text) {
17482
17538
  var record = this.record;
17483
17539
  if (!record) {
17484
- return;
17540
+ return jQuery.when();
17485
17541
  }
17486
17542
  var field = this.field;
17487
17543
  var value = field.get(record);
@@ -18335,7 +18391,7 @@ function eval_pyson(value){
18335
18391
  },
18336
18392
  _update_completion: function(text) {
18337
18393
  if (!this.record) {
18338
- return;
18394
+ return jQuery.when();
18339
18395
  }
18340
18396
  var model = this.attributes.relation;
18341
18397
  var domain = this.field.get_domain(this.record);
@@ -18702,7 +18758,7 @@ function eval_pyson(value){
18702
18758
  },
18703
18759
  _update_completion: function(text) {
18704
18760
  if (!this.record) {
18705
- return;
18761
+ return jQuery.when();
18706
18762
  }
18707
18763
  var model = this.attributes.relation;
18708
18764
  var domain = this.field.get_domain(this.record);
@@ -19605,10 +19661,10 @@ function eval_pyson(value){
19605
19661
  },
19606
19662
  _update_completion: function(text) {
19607
19663
  if (this.wid_text.prop('disabled')) {
19608
- return;
19664
+ return jQuery.when();
19609
19665
  }
19610
19666
  if (!this.record) {
19611
- return;
19667
+ return jQuery.when();
19612
19668
  }
19613
19669
  return Sao.common.update_completion(
19614
19670
  this.wid_text, this.record, this.field, this.schema_model);
@@ -21893,8 +21949,7 @@ function eval_pyson(value){
21893
21949
  collapse_children: function() {
21894
21950
  for (const row of this.rows) {
21895
21951
  row.collapse_children();
21896
- var node = row.el[0];
21897
- node.parentNode.removeChild(node);
21952
+ row.el.remove();
21898
21953
  }
21899
21954
  this.rows = [];
21900
21955
  },
@@ -9950,8 +9950,8 @@ img.icon {
9950
9950
  min-height: 150px;
9951
9951
  max-height: 300px;
9952
9952
  }
9953
- .form .form-text > textarea,
9954
- .form .form-richtext > textarea,
9953
+ .form .form-text textarea,
9954
+ .form .form-richtext textarea,
9955
9955
  .form .form-text .richtext,
9956
9956
  .form .form-richtext .richtext {
9957
9957
  height: 100%;