tryton-sao 6.0.40 → 6.0.42

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.42 - 2024-06-15
3
+ ---------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+
6
+
7
+ Version 6.0.41 - 2024-05-01
8
+ ---------------------------
9
+ * Bug fixes (see mercurial logs for details)
10
+
11
+
2
12
  Version 6.0.40 - 2024-04-17
3
13
  ---------------------------
4
14
  * Bug fixes (see mercurial logs for details)
@@ -9882,8 +9882,8 @@ img.icon {
9882
9882
  min-height: 150px;
9883
9883
  max-height: 300px;
9884
9884
  }
9885
- .form .form-text > textarea,
9886
- .form .form-richtext > textarea,
9885
+ .form .form-text textarea,
9886
+ .form .form-richtext textarea,
9887
9887
  .form .form-text .richtext,
9888
9888
  .form .form-richtext .richtext {
9889
9889
  height: 100%;
@@ -3409,10 +3409,14 @@ var Sao = {};
3409
3409
  if (!refresh) {
3410
3410
  this._access = {};
3411
3411
  }
3412
- this._models = Sao.rpc({
3413
- 'method': 'model.ir.model.list_models',
3414
- 'params': [{}]
3415
- }, Sao.Session.current_session, false);
3412
+ try {
3413
+ this._models = Sao.rpc({
3414
+ 'method': 'model.ir.model.list_models',
3415
+ 'params': [{}]
3416
+ }, Sao.Session.current_session, false);
3417
+ } catch(e) {
3418
+ Sao.Logger.error("Unable to get model list.");
3419
+ }
3416
3420
  },
3417
3421
  get: function(model) {
3418
3422
  if (this._access[model] !== undefined) {
@@ -3426,10 +3430,23 @@ var Sao = {};
3426
3430
  var to_load = this._models.slice(
3427
3431
  Math.max(0, idx - Math.floor(this.batchnum / 2)),
3428
3432
  idx + Math.floor(this.batchnum / 2));
3429
- var access = Sao.rpc({
3430
- 'method': 'model.ir.model.access.get_access',
3431
- 'params': [to_load, {}]
3432
- }, Sao.Session.current_session, false);
3433
+ var access;
3434
+ try {
3435
+ access = Sao.rpc({
3436
+ 'method': 'model.ir.model.access.get_access',
3437
+ 'params': [to_load, {}]
3438
+ }, Sao.Session.current_session, false);
3439
+ } catch(e) {
3440
+ Sao.Logger.error(`Unable to get access for ${model}.`);
3441
+ access = {
3442
+ model: {
3443
+ 'read': true,
3444
+ 'write': false,
3445
+ 'create': false,
3446
+ 'delete': false,
3447
+ },
3448
+ };
3449
+ }
3433
3450
  this._access = jQuery.extend(this._access, access);
3434
3451
  return this._access[model];
3435
3452
  }
@@ -12931,8 +12948,12 @@ var Sao = {};
12931
12948
  set_cursor = true;
12932
12949
  }
12933
12950
  this.group.load(ids, modified);
12934
- this.current_view.reset();
12935
- if (ids.length && this.current_view.view_type != 'calendar') {
12951
+ if (this.current_view) {
12952
+ this.current_view.reset();
12953
+ }
12954
+ if (ids.length &&
12955
+ this.current_view &&
12956
+ this.current_view.view_type != 'calendar') {
12936
12957
  this.current_record = this.group.get(ids[0]);
12937
12958
  } else {
12938
12959
  this.current_record = null;
@@ -12953,7 +12974,7 @@ var Sao = {};
12953
12974
  } else {
12954
12975
  this.current_record = null;
12955
12976
  }
12956
- if (this.views) {
12977
+ if (this.views && this.current_view) {
12957
12978
  var search_prm = this.search_active(
12958
12979
  ~['tree', 'graph', 'calendar'].indexOf(
12959
12980
  this.current_view.view_type));
@@ -12992,7 +13013,8 @@ var Sao = {};
12992
13013
  var view = this.current_view;
12993
13014
  view.set_value();
12994
13015
  this.set_cursor(false, false);
12995
- if (~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13016
+ if (view &&
13017
+ ~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
12996
13018
  this.current_record && this.current_record.group) {
12997
13019
  var group = this.current_record.group;
12998
13020
  var record = this.current_record;
@@ -13019,9 +13041,12 @@ var Sao = {};
13019
13041
  },
13020
13042
  display_previous: function() {
13021
13043
  var view = this.current_view;
13022
- view.set_value();
13044
+ if (view) {
13045
+ view.set_value();
13046
+ }
13023
13047
  this.set_cursor(false, false);
13024
- if (~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13048
+ if (view &&
13049
+ ~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13025
13050
  this.current_record && this.current_record.group) {
13026
13051
  var group = this.current_record.group;
13027
13052
  var record = this.current_record;
@@ -13044,7 +13069,7 @@ var Sao = {};
13044
13069
  this.current_record = this.group[0];
13045
13070
  }
13046
13071
  this.set_cursor(false, false);
13047
- return view.display();
13072
+ return view ? view.display() : jQuery.when();
13048
13073
  },
13049
13074
  get selected_records() {
13050
13075
  if (this.current_view) {
@@ -13080,7 +13105,8 @@ var Sao = {};
13080
13105
  });
13081
13106
  },
13082
13107
  default_row_activate: function() {
13083
- if ((this.current_view.view_type == 'tree') &&
13108
+ if (this.current_view &&
13109
+ (this.current_view.view_type == 'tree') &&
13084
13110
  (this.current_view.attributes.keyword_open == 1)) {
13085
13111
  var id = this.get_id();
13086
13112
  if (id) {
@@ -13107,7 +13133,8 @@ var Sao = {};
13107
13133
  default_ = true;
13108
13134
  }
13109
13135
  var prm = jQuery.when();
13110
- if (this.current_view.view_type == 'calendar') {
13136
+ if (this.current_view &&
13137
+ this.current_view.view_type == 'calendar') {
13111
13138
  var selected_date = this.current_view.get_selected_date();
13112
13139
  prm = this.switch_view('form', undefined, false);
13113
13140
  }
@@ -13118,7 +13145,7 @@ var Sao = {};
13118
13145
  prm = this.switch_view('form', undefined, false);
13119
13146
  }
13120
13147
  return prm.then(function() {
13121
- if (!this.current_view.editable) {
13148
+ if (!this.current_view || !this.current_view.editable) {
13122
13149
  return;
13123
13150
  }
13124
13151
  var group;
@@ -13199,19 +13226,22 @@ var Sao = {};
13199
13226
  save_current: function() {
13200
13227
  var current_record = this.current_record;
13201
13228
  if (!current_record) {
13202
- if ((this.current_view.view_type == 'tree') &&
13203
- this.group && this.group.length) {
13229
+ if (this.current_view &&
13230
+ (this.current_view.view_type == 'tree') &&
13231
+ this.group && this.group.length) {
13204
13232
  this.current_record = this.group[0];
13205
13233
  current_record = this.current_record;
13206
13234
  } else {
13207
13235
  return jQuery.when();
13208
13236
  }
13209
13237
  }
13210
- this.current_view.set_value();
13211
- var fields = this.current_view.get_fields();
13238
+ if (this.current_view) {
13239
+ this.current_view.set_value();
13240
+ var fields = this.current_view.get_fields();
13241
+ }
13212
13242
  var path = current_record.get_path(this.group);
13213
13243
  var prm = jQuery.Deferred();
13214
- if (this.current_view.view_type == 'tree') {
13244
+ if (this.current_view && (this.current_view.view_type == 'tree')) {
13215
13245
  prm = this.group.save().then(function() {
13216
13246
  return this.current_record;
13217
13247
  }.bind(this));
@@ -13219,7 +13249,7 @@ var Sao = {};
13219
13249
  prm = current_record.save().then(function() {
13220
13250
  return current_record;
13221
13251
  });
13222
- } else {
13252
+ } else if (this.current_view) {
13223
13253
  return this.current_view.display().then(function() {
13224
13254
  this.set_cursor();
13225
13255
  return jQuery.Deferred().reject();
@@ -13255,7 +13285,7 @@ var Sao = {};
13255
13285
  var test = function(record) {
13256
13286
  return (record.has_changed() || record.id < 0);
13257
13287
  };
13258
- if (this.current_view.view_type != 'tree') {
13288
+ if (this.current_view && (this.current_view.view_type != 'tree')) {
13259
13289
  if (this.current_record) {
13260
13290
  if (test(this.current_record)) {
13261
13291
  return true;
@@ -13266,20 +13296,24 @@ var Sao = {};
13266
13296
  return true;
13267
13297
  }
13268
13298
  }
13269
- if (this.current_view.modified) {
13299
+ if (this.current_view && this.current_view.modified) {
13270
13300
  return true;
13271
13301
  }
13272
13302
  return false;
13273
13303
  },
13274
13304
  unremove: function() {
13275
- var records = this.current_view.selected_records;
13276
- records.forEach(function(record) {
13277
- record.group.unremove(record);
13278
- });
13305
+ if (this.current_view) {
13306
+ var records = this.current_view.selected_records;
13307
+ records.forEach(function(record) {
13308
+ record.group.unremove(record);
13309
+ });
13310
+ }
13279
13311
  },
13280
13312
  remove: function(delete_, remove, force_remove, records) {
13281
13313
  var prm = jQuery.when();
13282
- records = records || this.current_view.selected_records;
13314
+ if (!records && this.current_view) {
13315
+ records = this.current_view.selected_records;
13316
+ }
13283
13317
  if (jQuery.isEmptyObject(records)) {
13284
13318
  return prm;
13285
13319
  }
@@ -13337,7 +13371,8 @@ var Sao = {};
13337
13371
  },
13338
13372
  copy: function() {
13339
13373
  var dfd = jQuery.Deferred();
13340
- var records = this.current_view.selected_records;
13374
+ var records = (
13375
+ this.current_view ? this.current_view.selected_records : []);
13341
13376
  this.model.copy(records, this.context)
13342
13377
  .then(function(new_ids) {
13343
13378
  this.group.load(new_ids, false, this.new_position);
@@ -13522,14 +13557,18 @@ var Sao = {};
13522
13557
  if (!this.current_record) {
13523
13558
  return null;
13524
13559
  }
13525
- this.current_view.set_value();
13560
+ if (this.current_view) {
13561
+ this.current_view.set_value();
13562
+ }
13526
13563
  return this.current_record.get();
13527
13564
  },
13528
13565
  get_on_change_value: function() {
13529
13566
  if (!this.current_record) {
13530
13567
  return null;
13531
13568
  }
13532
- this.current_view.set_value();
13569
+ if (this.current_view) {
13570
+ this.current_view.set_value();
13571
+ }
13533
13572
  return this.current_record.get_on_change_value();
13534
13573
  },
13535
13574
  reload: function(ids, written) {
@@ -13542,15 +13581,17 @@ var Sao = {};
13542
13581
  promises.push(this.group.parent.root_parent.reload());
13543
13582
  }
13544
13583
  return jQuery.when.apply(jQuery, promises).then(function() {
13545
- this.display();
13584
+ return this.display();
13546
13585
  }.bind(this));
13547
13586
  },
13548
13587
  get_buttons: function() {
13549
- var selected_records = this.current_view.selected_records;
13588
+ var selected_records = (
13589
+ this.current_view ? this.current_view.selected_records : []);
13550
13590
  if (jQuery.isEmptyObject(selected_records)) {
13551
13591
  return [];
13552
13592
  }
13553
- var buttons = this.current_view.get_buttons();
13593
+ var buttons = (
13594
+ this.current_view ? this.current_view.get_buttons() : []);
13554
13595
  selected_records.forEach(function(record) {
13555
13596
  buttons = buttons.filter(function(button) {
13556
13597
  if (button.attributes.type === 'instance') {
@@ -13580,9 +13621,11 @@ var Sao = {};
13580
13621
  }.bind(this));
13581
13622
  };
13582
13623
 
13583
- var selected_records = this.current_view.selected_records;
13584
- this.current_view.set_value();
13585
- var fields = this.current_view.get_fields();
13624
+ if (this.current_view) {
13625
+ var selected_records = this.current_view.selected_records;
13626
+ this.current_view.set_value();
13627
+ var fields = this.current_view.get_fields();
13628
+ }
13586
13629
 
13587
13630
  var prms = [];
13588
13631
  var reset_state = function(record) {
@@ -13681,7 +13724,8 @@ var Sao = {};
13681
13724
  } else if (action.startsWith('switch')) {
13682
13725
  this.switch_view.apply(this, action.split(' ', 3).slice(1));
13683
13726
  } else if (action == 'reload') {
13684
- if (~['tree', 'graph', 'calendar'].indexOf(this.current_view.view_type) &&
13727
+ if (this.current_view &&
13728
+ ~['tree', 'graph', 'calendar'].indexOf(this.current_view.view_type) &&
13685
13729
  !this.group.parent) {
13686
13730
  this.search_filter();
13687
13731
  }
@@ -13720,7 +13764,7 @@ var Sao = {};
13720
13764
  var path = ['model', this.model_name];
13721
13765
  var view_ids = this.views.map(
13722
13766
  function(v) {return v.view_id;}).concat(this.view_ids);
13723
- if (this.current_view.view_type != 'form') {
13767
+ if (this.current_view && (this.current_view.view_type != 'form')) {
13724
13768
  var search_value;
13725
13769
  if (this.attributes.search_value) {
13726
13770
  search_value = this.attributes.search_value;
@@ -13733,8 +13777,10 @@ var Sao = {};
13733
13777
  }
13734
13778
  } else if (this.current_record && (this.current_record.id > -1)) {
13735
13779
  path.push(this.current_record.id);
13736
- var i = view_ids.indexOf(this.current_view.view_id);
13737
- view_ids = view_ids.slice(i).concat(view_ids.slice(0, i));
13780
+ if (this.current_view) {
13781
+ var i = view_ids.indexOf(this.current_view.view_id);
13782
+ view_ids = view_ids.slice(i).concat(view_ids.slice(0, i));
13783
+ }
13738
13784
  }
13739
13785
  if (!jQuery.isEmptyObject(view_ids)) {
13740
13786
  query_string.push(['views', dumps(view_ids)]);
@@ -13818,6 +13864,9 @@ var Sao = {};
13818
13864
  set_tree_state: function() {
13819
13865
  var parent_, state, state_prm, tree_state_model;
13820
13866
  var view = this.current_view;
13867
+ if (!view) {
13868
+ return jQuery.when();
13869
+ }
13821
13870
  if (!~['tree', 'form'].indexOf(view.view_type)) {
13822
13871
  return jQuery.when();
13823
13872
  }
@@ -16204,10 +16253,13 @@ function eval_pyson(value){
16204
16253
  this.el = jQuery('<div/>', {
16205
16254
  'class': this.class_
16206
16255
  });
16256
+ this.group = jQuery('<div/>', {
16257
+ 'class': 'input-group',
16258
+ }).appendTo(this.el);
16207
16259
  this.input = this.labelled = jQuery('<textarea/>', {
16208
16260
  'class': 'form-control input-sm mousetrap',
16209
16261
  'name': attributes.name,
16210
- }).appendTo(this.el);
16262
+ }).appendTo(this.group);
16211
16263
  this.input.change(this.focus_out.bind(this));
16212
16264
  if (this.attributes.translate) {
16213
16265
  var button = jQuery('<button/>', {
@@ -16216,7 +16268,7 @@ function eval_pyson(value){
16216
16268
  'aria-label': Sao.i18n.gettext('Translate')
16217
16269
  }).appendTo(jQuery('<span/>', {
16218
16270
  'class': 'input-group-btn'
16219
- }).appendTo(this.el));
16271
+ }).appendTo(this.group));
16220
16272
  button.append(
16221
16273
  Sao.common.ICONFACTORY.get_icon_img('tryton-translate'));
16222
16274
  button.click(this.translate.bind(this));
@@ -16290,13 +16342,16 @@ function eval_pyson(value){
16290
16342
  'class': 'panel-heading',
16291
16343
  }).appendTo(this.el));
16292
16344
  }
16293
- this.input = this.labelled = jQuery('<div/>', {
16294
- 'class': 'richtext mousetrap',
16295
- 'contenteditable': true
16345
+ this.group = jQuery('<div/>', {
16346
+ 'class': 'input-group',
16296
16347
  }).appendTo(jQuery('<div/>', {
16297
- 'class': 'panel-body'
16348
+ 'class': 'panel-body',
16298
16349
  }).appendTo(this.el));
16299
- this.el.focusout(this.focus_out.bind(this));
16350
+ this.input = this.labelled = jQuery('<div/>', {
16351
+ 'class': 'richtext mousetrap',
16352
+ 'contenteditable': true,
16353
+ }).appendTo(this.group);
16354
+ this.group.focusout(this.focus_out.bind(this));
16300
16355
  if (this.attributes.translate) {
16301
16356
  var button = jQuery('<button/>', {
16302
16357
  'class': 'btn btn-default btn-sm form-control',
@@ -16304,7 +16359,7 @@ function eval_pyson(value){
16304
16359
  'aria-label': Sao.i18n.gettext("Translate"),
16305
16360
  }).appendTo(jQuery('<span/>', {
16306
16361
  'class': 'input-group-btn',
16307
- }).appendTo(this.el));
16362
+ }).appendTo(this.group));
16308
16363
  button.append(
16309
16364
  Sao.common.ICONFACTORY.get_icon_img('tryton-translate'));
16310
16365
  button.click(this.translate.bind(this));
@@ -16813,7 +16868,7 @@ function eval_pyson(value){
16813
16868
  _update_completion: function(text) {
16814
16869
  var record = this.record;
16815
16870
  if (!record) {
16816
- return;
16871
+ return jQuery.when();
16817
16872
  }
16818
16873
  var field = this.field;
16819
16874
  var value = field.get(record);
@@ -17598,7 +17653,7 @@ function eval_pyson(value){
17598
17653
  },
17599
17654
  _update_completion: function(text) {
17600
17655
  if (!this.record) {
17601
- return;
17656
+ return jQuery.when();
17602
17657
  }
17603
17658
  var model = this.attributes.relation;
17604
17659
  var domain = this.field.get_domain(this.record);
@@ -17915,7 +17970,7 @@ function eval_pyson(value){
17915
17970
  },
17916
17971
  _update_completion: function(text) {
17917
17972
  if (!this.record) {
17918
- return;
17973
+ return jQuery.when();
17919
17974
  }
17920
17975
  var model = this.attributes.relation;
17921
17976
  var domain = this.field.get_domain(this.record);
@@ -18804,10 +18859,10 @@ function eval_pyson(value){
18804
18859
  },
18805
18860
  _update_completion: function(text) {
18806
18861
  if (this.wid_text.prop('disabled')) {
18807
- return;
18862
+ return jQuery.when();
18808
18863
  }
18809
18864
  if (!this.record) {
18810
- return;
18865
+ return jQuery.when();
18811
18866
  }
18812
18867
  return Sao.common.update_completion(
18813
18868
  this.wid_text, this.record, this.field, this.schema_model);
@@ -20843,8 +20898,7 @@ function eval_pyson(value){
20843
20898
  collapse_children: function() {
20844
20899
  this.rows.forEach(function(row, pos, rows) {
20845
20900
  row.collapse_children();
20846
- var node = row.el[0];
20847
- node.parentNode.removeChild(node);
20901
+ row.el.remove();
20848
20902
  });
20849
20903
  this.rows = [];
20850
20904
  },
@@ -9882,8 +9882,8 @@ img.icon {
9882
9882
  min-height: 150px;
9883
9883
  max-height: 300px;
9884
9884
  }
9885
- .form .form-text > textarea,
9886
- .form .form-richtext > textarea,
9885
+ .form .form-text textarea,
9886
+ .form .form-richtext textarea,
9887
9887
  .form .form-text .richtext,
9888
9888
  .form .form-richtext .richtext {
9889
9889
  height: 100%;