Поддержка нескольких сессий

`` pos_multi_session`` является модулем, который позволяет синхронизировать данные в POS в пределах одной multi_session.

Для синхронизации новых пользовательских данных Order или Orderline моделей одного POS с другими вам не нужно добавлять новый модуль `` pos_multi_session`` в `` depen`` вашего модуля, вам нужно расширить такие методы, как `` export_as_JSON , `` init_from_JSON и добавьте метод `` apply_ms_data``, который используется для совместимости с.

Рассмотрим ** Пример синхронизации для модели заказа. **

Позвольте нам иметь некоторые данные для заказа, и нам нужно синхронизировать их со всеми POS-терминалами, которые используют один и тот же мульти-сеанс:

apply_ms_data: function (data) {
  /*
  It is necessary to check the presence of the super method
  in order to be able to inherit the apply_ms_data
  without calling require('pos_multi_session')
  and without adding pos_multi_session in dependencies in the manifest.

  At the time of loading, the super method may not exist. So, if the js file is loaded
  first among all inherited, then there is no super method and it is not called.
  If the file is not the first, then the super method is already created by other modules,
  and we call super method.
  */
  if (_super_order.apply_ms_data) {
    _super_order.apply_ms_data.apply(this, arguments);
  }
  this.first_new_variable = data.first_new_variable;
  this.second_new_variable = data.second_new_variable;
  // etc ...

  /*
  Call renderElement direclty or trigger corresponding
  event if you need to rerender something after updating */
    },
    export_as_JSON: function () {
  // export new data as JSON
  var data = _super_order.export_as_JSON.apply(this, arguments);
  data.first_new_variable = this.first_new_variable;
  data.second_new_variable = this.second_new_variable;
  return data;
    },
    init_from_JSON: function (json) {
  // import new data from JSON
  this.first_new_variable = json.first_new_variable;
  this.second_new_variable = json.second_new_variable;
  return _super_order.init_from_JSON.call(this, json);
}