-
- Downloads
[REF] point_of_sale,*pos*: remove Backbone.js, single loading request
This commit accomplishes multiple objectives: 1. Loading of model data for the POS UI is now done in single request (with some exemptions). 2. Backbone.js is removed and is replaced by reactivity.js authored by the js framework team. 3. Better organization of assets in the `__manifest__.py` Data Loading ------------ One request per model -- that's always been how the data is loaded in POS UI. Now, we move the aggregation of data to the backend which simplified the data loading. In the frontend, data loading is initiated in `load_server_data` which makes the single rpc call to the `load_pos_data` defined in `pos.session` model. There remains some rpc calls during loading but the number is greatly reduced. This change result to faster loading of the POS UI. However, there is no more progress bar during the loading. Notable entry points: - .js: `PosGlobalState.load_server_data` - .py: `pos.session.load_pos_data` It is possible to make customizations in the loading, but is done in several steps: 1. Override `_pos_ui_models_to_load` to include the new model to load. 2. Define `_loader_params_<model_name>` to define the `search_params` and optional `context`. 3. Define `_get_pos_ui_<model_name>` to return the data that will be included in the full `loaded_data`. Perform the organization in this method whenever necessary. 4. Override `_pos_data_process` for further post processing. The final form of `loaded_data` in this method will be sent to the frontend. Removal of Backbone.js ---------------------- POS is no longer dependent from `Backbone.js`, but it's replaced by a new dependency -- `reactivity.js`. It's invented by the js framework team which will be available in owl v2. The consequences of this change are the following: 1. The old `PosModel` is renamed to `PosGlobalState`. 2. The name of the other models are kept (except Paymentline which is renamed to Payment). 3. The name `PosModel` is now used as the base model of the data models. This is symmetric to our use of `PosComponent`. 4. The instance of `PosGlobalState` is made reactive in `Chrome` (the root component). As a result, whatever mutation made in that instance, `Chrome` will rerender. But rendering is batched so multiple mutations in a single sychronous function call will only result to a single render call. 5. `PosModel`s can be extended in the `Registries` the same way as we extend the `PosComponent`s. ```js // E.g. Registries.Component.extend(Chrome, PosResChrome); Registries.Model.extend(Order, PosResOrder); ``` Reorganization of assets declaration ------------------------------------ This is a simple change that replaced the explicit enumeration of loaded .js and .xml files. Also, we now have regions in the manifest separating: 1. Augmentations of dependencies 2. Assets for `point_of_sale.index` 3. Assets for the qunit test (soon will be improved) Other notable changes --------------------- - Automatic call to `Order.save_to_db` is batched. - Instances of `devices.DeviceProxy` (`proxy`), `devices.JobQueue` (`proxy_queue`) and `BarcodeReader` (`barcode_reader`) are moved to `point_of_sale.env`. Together with `posbus` and `posMutex` (previously `flush_mutex`). - `ActivePrograms` is now passed a props. - `cashier` is no longer saved to `localStorage`. - `pos_cache` is overhauled. - `cache` is taken out from `PosDB` to prevent infinite rendering loop whenever `cache` is mutated. It's now called `CACHE` in the `db.js` file. - reactive version of `posmodel` is exposed globally when in debug mode. This means that calling when calling a mutator, the UI will react. - Added control buttons in the `ProductScreen` is sorted during `Chrome` setup. As a result, we don't need to worry on the loading order of the control buttons components. - Model can be simply instantiated using `BaseModel.create(obj)`. This takes into account the extensions. - `pos_coupon`: rewards are now updated whenever set_order is called. - Component unit tests were removed. It wasn't useful and it just blocks the development. We'll be introducing better unit testing later. closes odoo/odoo#82461 Related: odoo/enterprise#23344 Signed-off-by:Masereel Pierre <pim@odoo.com> Co-authored-by:
Jacky (trj) <trj@odoo.com>
Showing
- addons/account/models/account_tax.py 8 additions, 0 deletionsaddons/account/models/account_tax.py
- addons/l10n_co_pos/static/src/js/pos.js 19 additions, 17 deletionsaddons/l10n_co_pos/static/src/js/pos.js
- addons/l10n_fr_pos_cert/static/src/js/NumpadWidget.js 0 additions, 20 deletionsaddons/l10n_fr_pos_cert/static/src/js/NumpadWidget.js
- addons/l10n_fr_pos_cert/static/src/js/pos.js 43 additions, 37 deletionsaddons/l10n_fr_pos_cert/static/src/js/pos.js
- addons/l10n_in_pos/models/__init__.py 1 addition, 0 deletionsaddons/l10n_in_pos/models/__init__.py
- addons/l10n_in_pos/models/pos_session.py 13 additions, 0 deletionsaddons/l10n_in_pos/models/pos_session.py
- addons/l10n_in_pos/static/src/js/receipt.js 8 additions, 8 deletionsaddons/l10n_in_pos/static/src/js/receipt.js
- addons/l10n_sa_pos/static/src/js/models.js 10 additions, 9 deletionsaddons/l10n_sa_pos/static/src/js/models.js
- addons/point_of_sale/__manifest__.py 70 additions, 120 deletionsaddons/point_of_sale/__manifest__.py
- addons/point_of_sale/controllers/main.py 2 additions, 0 deletionsaddons/point_of_sale/controllers/main.py
- addons/point_of_sale/models/account_tax.py 0 additions, 9 deletionsaddons/point_of_sale/models/account_tax.py
- addons/point_of_sale/models/pos_order.py 1 addition, 1 deletionaddons/point_of_sale/models/pos_order.py
- addons/point_of_sale/models/pos_session.py 420 additions, 0 deletionsaddons/point_of_sale/models/pos_session.py
- addons/point_of_sale/static/lib/backbone/backbone.js 0 additions, 1581 deletionsaddons/point_of_sale/static/lib/backbone/backbone.js
- addons/point_of_sale/static/src/backend/debug_manager.js 0 additions, 0 deletionsaddons/point_of_sale/static/src/backend/debug_manager.js
- addons/point_of_sale/static/src/backend/tours/point_of_sale.js 0 additions, 0 deletions...s/point_of_sale/static/src/backend/tours/point_of_sale.js
- addons/point_of_sale/static/src/backend/web_overrides/pos_config_form.js 0 additions, 0 deletions..._sale/static/src/backend/web_overrides/pos_config_form.js
- addons/point_of_sale/static/src/css/pos.css 59 additions, 4 deletionsaddons/point_of_sale/static/src/css/pos.css
- addons/point_of_sale/static/src/entry/chrome_adapter.js 30 additions, 3 deletionsaddons/point_of_sale/static/src/entry/chrome_adapter.js
- addons/point_of_sale/static/src/entry/main.js 2 additions, 1 deletionaddons/point_of_sale/static/src/entry/main.js
Loading