Commit Graph
52 Commits
Author SHA1 Message Date
Gorash 774a3fad0e [REF] base,all: Update modifier syntax: view migration
Apply of the migration script to update all view modifiers.

Part-of: odoo/odoo#104741
2023-08-18 09:49:13 +02:00
Jorge Pinna Puissant e338487028 [REF] *: remove owl="1" from the templates
As all the templates are now imported in the owl app, there is not need
anymore to specify the owl="1" attribute in the templates.

Part of task~3443861

Part-of: odoo/odoo#130467
2023-08-11 14:32:30 +02:00
Michael (mcm) 9d6b380a24 [REF] *: adapt patches after new patch function
In the commit [1], the patch has been refactored to support the
native keyword `super`. The current commit just adapts the codebase
to that change.

task 3410198

[1]: 19ea1ac08043e22a811630968e44715cc3bfc495

Part-of: odoo/odoo#125716
2023-08-02 17:29:05 +02:00
Xavier Luyckx (xlu)andvlst <vlst@odoo.com>, Pedram (pebr) c087603d0b [REF] pos*: introduce bootstrap
pos*: point_of_sale,pos_discount,pos_hr,pos_loyalty,
pos_restaurant,pos_sale,pos_sale_product_configurator,pos_six

Prior to this commit, the point_of_sale module relied on custom CSS.

To enhance user experience, increase flexibility, and simplify maintenance,
most of the custom css was replaced in this PR with Bootstrap utility classes.

Task: 3354582
Authored-by:  Xavier Luyckx (xlu) <xlu@odoo.com>
Part-of: odoo/odoo#129544
Co-authored-by:  vlst <vlst@odoo.com>,  Pedram (pebr)
2023-07-28 16:28:45 +02:00
vlst 83b45b3be9 [REF] pos*: adapt imports
pos*: l10n_ae_pos,l10n_co_pos,l10n_fr_pos_cert,l10n_gcc_pos,
l10n_in_pos,l10n_sa_pos,pos_adyen,pos_discount,
pos_epson_printer,pos_hr,pos_hr_restaurant,pos_loyalty,
pos_mercury,pos_restaurant,pos_restaurant_adyen,pos_restaurant_stripe,
pos_sale,pos_sale_loyalty,pos_sale_product_configurator,pos_six,
pos_stripe

In the previous commit, we moved and renamed files such that they
better follow certain guidelines.

In this commit, we adapt imports accordingly.

In order to efficiently accomplish this task, i used the following [script](https://github.com/vlst-odoo/tools/blob/main/fixImports.py)

Task: 3394192
Part-of: odoo/odoo#127056
2023-07-25 08:18:58 +02:00
vlst bd1331f81e [REF] pos*: structure static files
pos*: l10n_ae_pos,l10n_co_pos,l10n_gcc_pos,l10n_in_pos,
l10n_sa_pos,pos_adyen,pos_discount,pos_epson_printer,
pos_hr,pos_hr_restaurant,pos_loyalty,pos_mercury,
pos_restaurant,pos_restaurant_adyen,pos_restaurant_stripe,pos_sale,
pos_sale_loyalty,pos_sale_product_configurator,pos_six,pos_stripe,

The POS has a large number of add-on modules. As such, it is
important that they all respect strict guidelines when it comes
to file structures.

Before, each module had more or less it's own rules when it came to
this, apart from the fact that code was mostly organised into
`js` and `xml` folders.

In this PR, we move to a much more structured approach,
in which each module follows the following pattern:

src/
|-- app/  <-- the module's own new logic
|-- overrides/
|   |-- components
|	|   |-- overridden_component_a
|	|	|   |-- overridden_component_a.js
|	|	|   |-- overridden_component_a.xml
|	|	|   |-- overridden_component_a.css
|   |-- models
|	|   |-- overridden_model.js

Apart from the structural changes, this PR introduces changes
to file names, such that they respect the default pattern of
snake_case naming.

In this commit, we move the files. In the following one we
make the needed changes in the code, such as adapting imports.

In order to efficiently accomplish this task, i used the following [script](https://github.com/vlst-odoo/tools/blob/main/rename.py)

Task: 3394192
Part-of: odoo/odoo#127056
2023-07-25 08:18:57 +02:00
Loan (LSE) bbe22683b5 [FIX] pos_six: missing "Send balance" button
To reproduce (16.1 and >):
 1. Install PoS and enable Six payment method
 2. Create a payment method using Six
 (the IP can be set randomly, it does not matter here to have the
 terminal connected)
 3. Add the Six payment method to the PoS configuration
 4. Open the PoS session
-> The "Send balance" button of the navbar is totally missing

For now, the manifest try to load the assets at:
`pos_six/static/src/app/**/*`
But, since 16.1 the file location for the XML and JS is misplaced in
`/static/app` instead of `/static/src/app`,
as such, the template file is missing.

opw-3422166

closes odoo/odoo#128813

X-original-commit: 859390a42cb8b2b10b017dca2ea5734cd8915c49
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
Signed-off-by: Loan Sens (lse) <lse@odoo.com>
2023-07-18 11:42:47 +02:00
vlst bfca1f4e8a [IMP] point_of_sale, pos*: reference env in models
pos*: pos_loyalty, pos_restaurant, pos_sale,
pos_adyen, pos_six, pos_stripe

At the moment, the `pos` models don't have access to the `env` variable.
This makes using `env` inside a model rather awkward.

This PR makes it so all the pos models have access directly to `env`.

closes odoo/odoo#124320

Task: 3358456
Related: odoo/enterprise#42209
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-06-27 16:26:45 +02:00
vlst 1f655ffcc7 [REF] pos*: merge PosStore and PosGlobalState
*: l10n_ae_pos, l10n_co_pos, l10n_fr_pos_cert, l10n_gcc_pos, l10n_in_pos, point_of_sale,
pos_adyen, pos_discount, pos_epson_printer, pos_hr, pos_loyalty, pos_mercury,
pos_restaurant, pos_sale, pos_sale_product_configurator, pos_six, pos_stripe

After the architectural refactor of the PoS App, there are two classes that make sense to merge.
In this refactoring task, we're merging them.

closes odoo/odoo#124477

Task: 3358550
Related: odoo/enterprise#42257
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-06-19 10:40:43 +02:00
Samuel Degueldre fcdd2acc5a [REF] pos*: namespace component templates, remove useless super calls
pos*: l10n_ae_pos, l10n_co_pos, l10n_fr_pos_cert, l10n_in_pos,
point_of_sale, pos_discount, pos_epson_printer, pos_hr, pos_loyalty,
pos_mercury, pos_restaurant, pos_sale, pos_sale_product_configurator,
pos_six

Previously, none of the templates of the pos were namespaced, this means
that depending on context, you have to access them differently: in xpath
the module prefix is necessary even if the template name itself isn't
namespace, but in owl components you cannot use the namespaced version
because owl doesn't have the notion of modules.

This commit namespaces the component templates of all the pos modules so
that it's consistent with the rest of the code base. It also removes
some extraneous calls to super.setup() that were leftover and are not
necessary for components extending directly owl's base Component.

closes odoo/odoo#124069

Related: odoo/enterprise#42094
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-06-08 14:32:34 +02:00
Samuel Degueldre cb2a53d573 [REF] point_of_sale, pos*: adapt import to moved files
pos*: l10n_co_pos, l10n_fr_pos_cert, l10n_gcc_pos, l10n_in_pos,
l10n_sa_pos, pos_adyen, pos_discount, pos_epson_printer, pos_hr,
pos_hr_restaurant, pos_loyalty, pos_mercury, pos_restaurant, pos_sale,
pos_sale_loyalty, pos_sale_product_configurator, pos_six, pos_stripe

The previous commit reorganizes the files in the pos, this commit
renames all of the imports of those files to match their new location.
This is done in a separate commit to allow git to better keep track of
the changes and apply forward-ports more seamlessly.

Part-of: odoo/odoo#123498
2023-06-05 17:51:06 +02:00
Martin Trigaux 2afdda2576 [I18N] *: export saas-16.3 source terms
closes odoo/odoo#123046

X-original-commit: 137f5ca0cb703ee953cb01db525362f7a778e6bd
Related: odoo/enterprise#41703
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-06-01 11:43:51 +02:00
Samuel Degueldre 6f18cffb60 [REF] point_of_sale, pos*: remove BackendButton component
pos*: point_of_sale, pos_hr, pos_restaurant, pos_sale

This component is purely presentational and contains no code, it's also
only used once (it was actually used a second time in pos_hr only
because the way the xpath was written would replace the existing
instance with a new one with an added t-if, we can just use an attribute
xpath instead).

Existing xpaths have been adapted such that the burger menu's dropdown
structure is better semantically (an unordered list containing list
items, instead of containing list elements inside of random divs)

Part-of: odoo/odoo#122035
2023-05-24 14:27:59 +02:00
Pulinckx Pierre (PIPU) f4f0f78318 [REF] *: Replace underscore.js function by native JS
Before this commit : The library underscore.js and
underscore.string.js were used in the ODOO solution.
After this commit : Every usages of a function from
underscore.js lib has been replaced with native javascript.
The goal is to remove all usages of underscore.js and to
not use anymore this library in ODOO.
---
TaskId : 3246238

closes odoo/odoo#120437

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-05-15 09:37:48 +02:00
Samuel Degueldre 3fb24aa05e [REF] pos*: use fine grained reactivity instead of deep renders
*: l10n_ae_pos, l10n_co_pos, l10n_fr_pos_cert, l10n_gcc_pos,
l10n_in_pos, point_of_sale, pos_discount, pos_hr, pos_loyalty,
pos_mercury, pos_restaurant, pos_sale, pos_six

The code of the pos was one of the first adopters of owl 1, as such, the
code was not initially written to take full advantage of the owl
reactivity system that would eventually make its way into owl 2. In
order to convert the code quickly when migrating to owl 2, a big
shortcut was taken: whenever something in the state of the pos changed,
the entire UI would be rerendered. While this works decently well in
practice, it can create confusing situations because the mental model
needed to understand how components work in the pos is different from
the rest of the code base.

This commit changes the existing code to use the typical fine-grained
reactivity model used everywhere else: components individually subscribe
to the pieces of state that they use and will rerender on their own when
this state changes. In order to achieve this, the pos global state has
been removed from the environment and should now be access through the
use of the custom hook `usePos` which will subscribe the component to
the state that it reads. This also has some minor performance benefits
as we only render the parts of the UI that actually need to update
whenever there is a state mutation, instead of the entire UI which can
be expensive in some cases (eg, the product screen will filter all
products during rendering to find only the products that match the
search, which is expensive when there are a lot of loaded products)

closes odoo/odoo#120992

Related: odoo/enterprise#40873
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-05-12 19:54:57 +02:00
Samuel Degueldre c313f5912f [REF] *: stop using assets_backend in the pos
*: l10n_ae_pos, l10n_co_pos, l10n_fr_pos_cert, l10n_gcc_pos,
l10n_in_pos, l10n_sa_pos, point_of_sale, pos_adyen, pos_discount,
pos_epson_printer, pos_epson_printer_restaurant, pos_hr,
pos_hr_restaurant, pos_loyalty, pos_mercury, pos_restaurant,
pos_restaurant_adyen, pos_restaurant_stripe, pos_sale, pos_sale_loyalty,
pos_sale_product_configurator, pos_six, pos_stripe, web

Previously, the pos assets included almost the entirety of the
assets_backend. Most of the contents of the assets_backend is completely
useless in the PoS, meaning that the PoS will load slower because it
loads much more JS than it needs. It also means that it gets all the
side effects of this bundle (global event listeners, among other things)
that we don't want.

This commit removes the dependency of the pos assets on the
assets_backend to solve these issues. The pos assets are now their own
bundle with only what is needed in the PoS.

As for the unit testing bundle, the same logic applies but
unfortunately, because the unit testing code from web that we want to
use (eg automatic cleanups, cleaning of registries, etc) depends on the
legacy code, we need to include a lot more files than would otherwise be
needed. This situation will probably be improved as legacy code is
removed from web, but in the mean time, it is not very important for
this bundle to be lean, as it's a test bundle and loading speed is less
important.

Linked to: odoo/enterprise#40502

closes odoo/odoo#120070

Related: odoo/upgrade#4626
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-05-05 17:06:38 +02:00
Joseph Caburnay 8d50daeefa [REF] point_of_sale,*: minimize the use of legacy web modules
*: l10n_fr_pos_cert,portal_rating,pos_adyen,pos_epson_printer,pos_loyalty,
   pos_mercury,pos_restaurant,pos_restaurant_adyen,pos_restaurant_stripe,
   pos_sale,pos_six,pos_stripe,web

This is part of the continuous effort of refactoring pos addons towards using
more modern modules and programming patterns (such as services). After this
commit, point_of_sale addons are now left with the use of the legacy
`web.concurrency` module because of the `MutexedDropPrevious`. It's okay to keep
it because it's relatively an independent module compared to other legacy web
module.

The following summarizes the changes in this commit.

- import `_t` from `@web/core/l10n/translation`.

- convert `PosDB` to js native class

- remove use of `format` in `TicketScreen`
  - To determine the cached orders are up-to-date, we now deserialize the dates
    coming from the server using web's `deserializeDateTime` function. Then,
    instead of initiating `cacheDate` as native js Date, we use the luxon's
    `DateTime` which is supported by the web date utility methods.
  - There is no need for the `format` function from `web.utils` legacy module.

- convert `PaymentInterface` to native class

- remove use of `web.config` module

- remove use of `web.time` module
  - use `serializeDateTime` from web.

- remove use of `web.rpc`

- remove use of `web.utils` module
  - introduce simple check for email address input
  - Replace use of `web.utils.Markup` with `@odoo/owl.markup`.
  - 'web.utils'.{round_decimals,round_precision,float_is_zero} copied to
    '@web/core/utils/numbers'.{roundDecimals,roundPrecision,floatIsZero}.
    - These helper functions are not removed from the web addon because they
      are also used from other addons that are not linked to pos.
    - `floatIsZero` is now computed by directly comparing the result of
      `roundDecimals` to zero. This works because rounding a decimal number
      which will result to zero will exactly give zero.

- remove use of `web.field_utils`
  - Replace `web.field_utils.parse.float` with
    `@web/views/fields/parsers.parseFloat`.
  - Replace `web.field_utils.format.float` with
    `@web/views/fields/formatters.formatFloat`.
  - Replace `web.field_utils.format.date` with
    `@web/core/l10n/dates.formatDate`.
  - Replace `web.field_utils.format.datetime` with
    `@web/core/l10n/dates.formatDateTime`.

- convert `PrinterMixin` and dependents to native class
  - `PrinterMixin` is converted to `BasePrinter`.
  - `Printer` is converted to `HWPrinter` (extending `BasePrinter`).
  - `EpsonPrinter` retained its name and is converted to extend `BasePrinter`.
  - Moreover, we also removed the convoluted `PrintResultGenerator`, replaced by
    simply creating object with the following signature:
    ```js
    { successful: boolean; message?: { title: string, body?: string } }
    ```

- remove use of `web.Session`

- replace use of `qweb.render`
  - We use `renderToElement` as replacement to templates that produces valid
    html.
  - Note that `renderToElement` is introduced in `@web/core/utils/render` module
    which is extracted from the original `renderToString` method.
  - For the epson printer template, we kept the xml layout and manually add
    required xml element to contruct the xml that will be sent to the epson in
    making print requests.

- use `Mutex` from `@web/core/utils/concurrency`

- remove use of `Markup` when rendering receipt info (`ticket`) in order to
  render new lines.

- Remove use of `jquery` in `htmlToImg`.

closes odoo/odoo#117231

Related: odoo/enterprise#39078
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-04-25 14:07:09 +02:00
Adrien Guilliams (adgu) 6cabcd7f1c [IMP] pos: New FloorScreen kanban view and more
Currently, there is only 1 plan view that is unreadable on mobile
and sometimes also complicated in some cases.
This commit  adds a new "Kanban" view used by default on mobile
and available in desktop too. This commit also changes the edit bar
of the FloorScreen: the design is changed and some features are added
like the multiple selection of the tables or the adding and removing
of floors directly from the frontend. It also changes the navbar
of the PoS, moving the buttons in a navigation menu accessible
thanks to a button.

Task-id: 3212032
2023-04-12 15:42:27 +02:00
Pulinckx Pierre (PIPU) 29d55e4403 [REF] *: Replace underscore functions by native JS
Replace _.last, _find, _.extend, _.some, _.every

Taskid 3246238

closes odoo/odoo#117319

Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2023-04-05 12:50:43 +02:00
Samuel Degueldre 25cbd9c4e7 [REF] point_of_sale, pos*: convert ProxyDevice to ES6 class and service
*: pos_epson_printer, pos_restaurant, pos_six

This commit continues the work of reducing the reliance of the pos
modules on legacy features from the JS framework, such as core.Class and
mixins, by converting the ProxyDevice class to ES6 (and renaming it
HardwareProxy, to avoid confusion with DeviceProxy from iot). It also
makes it available as a service in the new environment so that we can
hopefully get rid of the legacy environment in the near future.

closes odoo/odoo#114821

Related: odoo/enterprise#37991
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-03-30 15:09:14 +02:00
Jacky (trj) ba8bba2add [FIX] point_of_sale, pos_*: improve Markup
pos_*: pos_adyen, pos_six

The use of the Markup was meant to keep the formatting (mostly the line breaks) of the data
given by the payment terminals. The data was stored on the `ticket` attribute of the `Payment`
model. A security issue arose from the fact that it is possible to import orders from a file
via the debug widget.
The `ticket` attribute was initialized in the `init_from_json` method and could be injected
with some malicious code.

Solution:
Instead of replacing all line breaks by the `<br/>` tag whenever terminal data is retrieved,
we can simply store this as it is in the `ticket` attribute. We then escape the value before
replacing the line breaks when exporting the data as a Markup. With this, only our `<br/>` tags
are trusted.

closes odoo/odoo#114770

X-original-commit: 7194506648c3512dc6a80d4a92a986643e60c5d2
Related: odoo/enterprise#37962
Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2023-03-09 15:54:58 +01:00
David Monnom (moda) c7fbae7a34 [REF] point_of_sale, pos_*: remove usage of useListener
*:point_of_sale,pos_ayden,pos_discount,pos_hr,pos_loyalty,pos_mercury,
pos_restaurant,pos_sale,pos_six

Previously, the point of sale and related modules made heavy usage of
`useListener`. This is because the pos was converted early to owl, and
in owl 1, using events to communicate between components was encouraged.

In owl 2, the decision was made to stop encouraging this way of
communicating between components, because it encourages communication
accross many layers of components, and is also hard to debug. In
addition, in owl 2, because components can have 0 or more than node,
including non HTMLElement nodes like text or comment nodes, owl removed
the implementation of useListener, as useListener relies on the presence
and unicity of a root HTMLElement per component on which we can attach
event listeners.

Another problem is that events rely on the fact that the components are
in the DOM so that the event can propagate, which can lead to issues in
some cases and in particular, in the PoS, if you load the point of sale
and switch tabs, some things will be broken because we are triggering
events, but there have not been any animation frame fired in the tab
because it's not focussed, and so owl has not mounted the component yet.

When migrating odoo to owl 2, we introduced a shim for this.el and
useListener in LegacyComponent, with the hope to remove it as soon as
possible.

This commit removes all usage of useListener from the pos modules for
those reasons. In some cases, useListener was incorrectly used intstead
of t-on, and the event was triggered and handled by the same component,
in other cases, a simple callback could be passed to a child component.
In a few cases, a method had to be implemented on the store as we wanted
this method to be available everywhere.

closes odoo/odoo#112219

Related: odoo/enterprise#36888
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-02-27 09:37:12 +01:00
Samuel Degueldre 6d8ebdf829 [REF] point_of_sale, pos*: remove PosComponent
*: pos_discount, pos_hr, pos_loyalty, pos_restaurant, pos_sale, pos_six

Previously, all components in the pos and related apps would inherit
from the PosComponent base component, this component contained a bunch
of methods that were as such available on every component in the pos
passively. In previous commits, a bunch of these methods have been moved
either to the pos store or to their own services, so that component
dependencies are explicit instead of every component having a clobbered
namespace and having access to everything implictly.

This commit factors out the last method of the PosComponent,
`setSyncStatus` and as such the PosComponent is now empty and can be
removed completely, as can the Gui singleton utility which was used to
access these methods from outside of components.

Components in the pos modules now inherit from LegacyComponent which
PosComponent extended. The end goal is to remove the use of
LegacyComponent as well, but currently it is still needed as components
in the pos modules make extensive use of `useListener` which requires
the shim for `this.el` provided by LegacyComponent. This is nonetheless
a first step in that direction.

This commit also removes some components that were used in the navbar as
they were very small and it made more sense to just have the behaviour
they implement directly in the navbar component or elsewhere. Most of
the CashMoveButton was moved to the CashMovePopup, the TicketButton has
so little behaviour that moving that behaviour to the navbar itself
makes sense.

closes odoo/odoo#112295

Related: odoo/enterprise#36860
Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
2023-02-09 18:07:23 +01:00
Samuel Degueldre 0d537e58a9 [REF] pos*: move show(Temp)Screen, make number_buffer and popup services
*: l10n_fr_pos_cert, point_of_sale, pos_discount, pos_hr,
pos_hr_restaurant, pos_loyalty, pos_mercury, pos_restaurant, pos_sale,
pos_sale_product_configurator, pos_six, pos_stripe

Continuing to move things out of the Chrome god component, this commit
does the following things:

 - moves the showScreen and showTempScreen methods and the corresponding
closing methods into the pos store so that components that need them can
access them through the pos service in a more explicit way. To that end,
these methods have been removed from PosComponent and Gui.

 - introduces a popup service instead of using a bus in the env, this is
mechanically very similar but closer to what's done in web and hopefully
a first step to using the dialog service instead. It also removes the
showPopup method from the PosComponent and Gui, to make components
depending on the popup service explicit.

 - makes the number buffer into a service instead of being a directly
imported singleton, which will enable it to be used with hooks instead
at a later point, and allows easier dependency injection in tests.

 - removes showNotification from the PosComponent and Gui, the
notification system was already converted to a service in a previous
commit for the same reasons as showPopup and the end goal is to use the
notification service from web to reduce duplication.

closes odoo/odoo#111844

Related: odoo/enterprise#36668
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-02-07 16:38:34 +01:00
Rahul PrajapatiandSamuel Degueldre b119cca37b [REF] point_of_sale, *: remove class and component registries
*: l10n_co_pos, l10n_fr_pos_cert, l10n_gcc_pos, l10n_in_pos,
l10n_sa_pos, pos_adyen, pos_discount, pos_epson_printer,
pos_epson_printer_restaurant, pos_hr, pos_hr_restaurant, pos_loyalty,
pos_mercury, pos_restaurant, pos_sale, pos_sale, pos_sale, pos_sale,
pos_sale, pos_sale, pos_sale_loyalty, pos_sale_product_configurator,
pos_six, pos_six, pos_six, pos_six, pos_stripe, pos_stripe

Previously, the point of sale module used a custom inheritance system
for models and components. This system being non-standard, it makes it
hard for newcomers to understand how to use it or for people with
experience in the pos code base to understand how things are done
elsewhere. This commit removes the "registries" system from the pos
modules and adapts existing code to use standard inheritance mechanisms,
ie extending classes directly, and using patch to modify behaviour in
place.

task-3119628

closes odoo/odoo#109928

Related: odoo/enterprise#35795
Signed-off-by: Samuel Degueldre <sad@odoo.com>
Co-authored-by: Samuel Degueldre <sad@odoo.com>
2023-01-23 16:01:27 +01:00
Samuel Degueldre 43529c8573 [REF] point_of_sale, *: extract navbar and remove ChromeAdapter
*: pos_hr, pos_restaurant, pos_six

The Chrome component a bloated "god component" that coordinates entirely
too many things which makes it hard to reason about, navigate, and
debug.

This commit extracts the navbar section of the chrome component into its
own component, and makes the sound player into its own self-contained
service.

This commit also merges the ChromeAdapter component into the Chrome
component, there is no reason for these to be two separate components.

Part-of: odoo/odoo#108891
2023-01-05 14:32:47 +01:00
Samuel Degueldre 990b10aece [REF] point_of_sale, *: convert legacy modules to ES odoo modules
*: l10n_co_pos, l10n_fr_pos_cert, l10n_gcc_pos, l10n_in_pos,
l10n_sa_pos, pos_adyen, pos_discount, pos_epson_printer,
pos_epson_printer_restaurant, pos_hr, pos_loyalty, pos_mercury,
pos_restaurant, pos_restaurant_adyen, pos_restaurant_stripe, pos_sale,
pos_sale_product_configurator, pos_six, pos_stripe

We are about to refactor most of the Javasript code base of the point of
sale and related modules. In doing so, we will move a lot of files and
modernize the entire code-base. In order to avoid diffcult rebases,
their conversion to odoo-modules is done as a first step to avoid
getting lots of conflicts on files that were unindented, which marks the
entire file as being in conflict. Conflicts will occur during forward
ports but they will be easier to manage as the changes will be much
smaller in scope, and the author will have the context of the change
that causes the conflict in mind when dealing with it.

closes odoo/odoo#107621

Related: odoo/enterprise#34910
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2022-12-14 11:41:52 +01:00
lejeune quentin 0055e3cda0 [FIX] pos_six: Fix the use_strict in the timapi.js library
In V16.0 it is currently no longer possible to use the POS
if the pos_six module is installed
This bug is a combination of 3 factors

1. the new assets: a single file contains all the JS files, concatenated.

2. one of these files contains the instruction "use strict",
which stiffens the code of the function in which this is mentioned,
and which prevents certain syntactic approximations
(like calling a variable without seeing it declared, this case)

3. We added Sha1, in its file of course, but not in its own function,
the use strict then applies to the entire asset file

This reverts commit e08858e5ed02fe74160dabd6a91e1de88640956f.

closes odoo/odoo#105582

X-original-commit: 2426c26a0fbbb2d5e50203922cb64f9001ac73e0
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2022-11-13 21:54:40 +01:00
lejeune quentin 2ea245d11e [FIX] pos_six: Declare variable into minified timapi.js
In the new version of Odoo you have to declare the
variables in the minified files

closes odoo/odoo#103789

X-original-commit: e08858e5ed02fe74160dabd6a91e1de88640956f
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2022-10-25 11:07:08 +02:00
Gorash 39ea7a1fab [IMP] web/all: XML templates are now declared into the python manifest.
Adapt all manifest, split some XML file and update JavaScript files.

Part-of: odoo/odoo#95500
2022-09-14 20:25:01 +02:00
Victor Feyens 42bad1a6d2 [IMP] *: remove useless keys from manifests
Remove most values uselessly specified because giving the same value as 
the default one (see _DEFAULT_MANIFEST in odoo/modules/module.py)

* auto_install is Falsy by default
* author is Odoo SA by default
* summary & description are empty strings by default
* application is False by default
* test, demo, depends and data are empty lists by default

This will reduce noise/inconsistencies between manifests specifications, 
simplify analysis of manifests content, ...

closes odoo/odoo#90209

Related: odoo/enterprise#26807
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-05-03 13:31:16 +02:00
Adrien Widart 62f329d72f [FIX] pos_six: use same web socket
When a user cancels a six payment method, he won't be able to select
another six payment method

To reproduce the issue:
(Use demo data. Install l10n_be so your company is in EUR)
1. Create two Payment Methods PM01, PM02 that use the same payment
terminal (a Six one)
2. Add the methods to the POS
3. Start a POS session
4. Select a product and go to payment page
5. Select PM01, send it then remove the line
6. Select PM02, send

Error: Nothing happens (the terminal doesn't receive the instructions).
After several seconds, an error message is displayed "Transaction was
not processed correctly: apiConnectionLostTerminal"

When starting the POS, because there are two payments methods, both are
instanced, each one with its own instance of `PaymentSix`. However, in
the above case, both payment methods use the same terminal. Therefore,
when sending the transaction with the second method (step 6), the API
creates a second WebSocket (for the second instance of `PaymentSix`)
between the POS and the terminal while such a `WebSocket` already exists
(first instance of `PaymentSix`)

OPW-2679181

closes odoo/odoo#85791

X-original-commit: 2912e0d116ceece51bb1274633cbd22e09735232
Signed-off-by: Masereel Pierre <pim@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-03-04 10:08:42 +00:00
Martin Trigaux 9fbf706ba8 [I18N] *: export saas-15.2 translations
closes odoo/odoo#84475

X-original-commit: 8ea2605fbfec6277d7a01b6e73548a9585866c61
Related: odoo/enterprise#24289
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-02-14 10:44:50 +00:00
Joseph CaburnayandJacky 8fb53c53c3 [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>
2022-01-27 21:50:25 +00:00
lejeune quentin 74e185cfe1 [IMP] point_of_sale: Authorizes the uses of POS in HTTPS with direct devices
To avoid the use of certificates when using direct devices
POS was redirected in HTTP

With new Chrome or Edge security measures this is no longer possible.

We add here the possibility to choose to redirect
the POS in https by adding a specific key in the parameters

closes odoo/odoo#78247

X-original-commit: 9cecb3bdbf5679b6d1d18dc2a250c86118bca6ce
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2021-10-12 17:03:41 +00:00
Xavier-Do 288595f558 [FIX] *: add explicit license to all manifest
The license is missing in most enterprise manifest so
the decision was taken to make it explicit in all cases.
When not defined, a warning will be triggered starting from
14.0 when falling back on the default LGPL-3.

closes odoo/odoo#74245

Related: odoo/design-themes#48
Related: odoo/enterprise#19862
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2021-07-26 13:09:57 +00:00
Martin Trigaux 6758868731 [I18N] *: export saas-14.4 source terms
Without demo data

closes odoo/odoo#73560

X-original-commit: 802e46541117573e028b711ea33dad9df9075a39
Related: odoo/enterprise#19602
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-07-12 10:57:37 +00:00
Jorge Pinna PuissantandSamuel Degueldre 9a76719893 [FIX] *: undeclared variables and restricted globals
closes odoo/odoo#69988

Related: odoo/enterprise#17991
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Co-authored-by: Samuel Degueldre <sad@odoo.com>
2021-05-04 13:32:49 +00:00
Jorge Pinna PuissantandSamuel Degueldre f43a0814ae [IMP]*: configuration of ESLint for specific files
This commit will add the needed ESLint configurations on the JS files.
These configurations are added if the JS file uses a different
environment (serviceworker, node, etc) or if it uses a specific global
(google, ace, etc).

Co-authored-by: Samuel Degueldre <sad@odoo.com>
2021-05-04 13:32:49 +00:00
Julien MougenotandSimon Genin 03641610c2 [REF] *: convert all modules to new asset system
Conversion of all modules to the new manifest assets declaration.

Part of task: 2352566

Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Simon Genin <ges@odoo.com>
2021-03-31 13:57:18 +02:00
Martin Trigaux e79531c136 [I18N] *: export 14.0 source terms
Including demo data this time

closes odoo/odoo#58862

X-original-commit: 575abde110acb3d12b25f177a863374becef0894
Related: odoo/enterprise#13705
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-09-29 17:52:02 +00:00
Antoine Prieels b17d943d98 [FIX] pos_six: Prepare for the certification
- The balance operation is performed automatically at the end of the
day but it doesn't print any receipt. We add the possibility to perform
the balance manually to get a receipt showing all the transactions of
the day.

- By default, DCC is set to true, but it requires a different
implementation. As we don't support it, Six asked us to changed the
variable to False, to make it clearer in case of debugging.

closes odoo/odoo#58360

X-original-commit: bc5ea7e3d3b694bbe88b14c10cd5cc80ca617e48
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
2020-09-23 14:28:45 +00:00
Antoine Prieels 74d8c9649b [FIX] pos_six: 0.01€ difference in Six transactions
Some payments were 0.01€ lower on the payment terminal compared to the
amount showing in the POS.

closes odoo/odoo#57547

X-original-commit: 3fd0822f42c1a9dbe5b786a3a767da969431ddaa
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
2020-09-11 13:57:11 +00:00
Martin Trigaux 81e1f89225 [I18N] export 14.0 source terms
Currently on branch saas-13.5
Without demo data

closes odoo/odoo#57168

X-original-commit: 32f752b486053b19a8c6167efb5ca0813f2bf3f8
Related: odoo/enterprise#12997
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-09-07 10:21:46 +00:00
Antoine Prieels 3f138b9d3c [IMP] point_of_sale, pos_*: Enable HTTPS in POS
HTTPS had been disabled on SaaS to allow the use of the IoT Box that
had no valid SSL certificate. As of V13.0, IoT Boxes connected to
Enterprise DBs have a valid certificate. POS can then use HTTPS.

Nginx is configured to redirect all requests to `/pos/web` to HTTP,
so we change the POS URL to `/pos/ui`, except when using a Six
payment terminal as it only works in HTTP.

closes odoo/odoo#56933

Taskid: 2191878
X-original-commit: 8aee4992778fee5e2f146c4cff8b35e83c7f56b3
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
2020-09-02 10:53:34 +00:00
Martin Trigaux 90d85eb9c5 [I18N] export saas-13.5 source terms
Without demo data

closes odoo/odoo#56869

X-original-commit: 33f251b6489455cd7221f2c62dee0400a69784b8
Related: odoo/enterprise#12836
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-09-01 11:18:00 +00:00
Antoine Prieels 703178f09b [FIX] pos_six: Wrong amount sent to terminal
The Six TIM API considers all round amounts to be in minor units while
decimal amounts are considered actual amounts.

In #df01c71, we changed all payments to minor units, but we still had
problems with floating point precision.

E.g. Starting a payment of 4.60€ was converted to 460 in minor units
but due to floating point precision, the actual amount sent to TIM
was 460.00000000005. The terminal then started a payment of 460€
instead of 4.60€.

closes odoo/odoo#56495

X-original-commit: 00cc3ce75dd2efa60ad93b6ad6535020fa517781
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
2020-08-25 10:35:14 +00:00
Antoine Prieels e8dfbbd1c4 [FIX] pos_six: timapi.wasm file not loaded correctly
The timapi.wasm file was not loaded correctly in debug != assets
because the library tried to fetch /web/content/XXX-XXX/timapi.wasm,
which returned the full JS bundle.

We set the full path of the file in the library:
'/pos_six/static/lib/six_tim/timapi.wasm'

closes odoo/odoo#53739

X-original-commit: b21859a1550df08ac96719c16eb380cc71d81cee
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
2020-06-26 13:09:51 +00:00
Antoine Prieels 3a2d698480 [IMP] pos_six: Upgrade TIM JavaScript SDK
Upgrade the TIM JavaScript SDK to the latest version (4.6.0).
The version Six gave us initially (3.8.1) didn't return any error
message. We now have some (ugly) error messages that could at least
help the cashier understand where the problem comes from (e.g.
"timCommunicationFailure", "cardholderStop", etc.).

closes odoo/odoo#52181

Taskid: 2267818
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2020-05-29 14:05:38 +00:00
Antoine Prieels 98d1c55090 [FIX] pos_six: Manual cancel and minor units
This commit fixes two bugs with pos_six:

- When the cashier manually clicked on "Cancel" or switched order,
the payment was correctly canceled, but the POS still showed the
error popup saying that the transaction was not processed
correctly.

- The TIM API manages differently rounds amounts and amounts with
decimals. Sending an amount of 1 was considered as 0.01€, while an
amount of 1.01 was considered as 1.01€. To fix this, we always sent
the amount in minor units.

closes odoo/odoo#52102

X-original-commit: a5125b92c11bd9dbf1b536e1eb1b467be446718f
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2020-05-28 13:59:30 +00:00