Commit Graph
132 Commits
Author SHA1 Message Date
Louis (wil) 3f6f949fa5 [I18N] export sources
closes odoo/odoo#140002

Related: odoo/enterprise#49687
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
2023-10-27 08:36:16 +00:00
vlst c12a87180e [REF] pos*: remove getSteps
pos*: l10n_es_pos, point_of_sale, pos_hr, pos_loyalty, pos_online_payment,
      pos_online_payment_self_order, pos_restaurant, pos_sale, pos_self_order

In this commit we refactor all the pos tours.

Changes:
 - Removed the `startSteps`, `getSteps` functions as they were
   no longer serving a purpose. We now simply put the tours steps
   in the array returned by the function given to `steps`. We
   apply `flat()` to this array in order to be able to provide both
   single steps and arrays containing multiple steps;
 - removed the classes from the tours. Now each helper function
   is simply exported from it's file and is consumed as `import * as myHelpers`;
 - removed the `do`, `check`, `exec` subpaths as they were not providing
   a clearer api. The functions themselves already have descriptive names.
   ( writing `ProductScreen.do.clickHomeCategory()` is not clearer than
   `ProductScreen.clickHomeCategory()` )
 - formatted all files.

closes odoo/odoo#139317

Task: 3565443
Related: odoo/enterprise#49313
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-10-25 18:11:01 +00:00
Xavier Morel 9ebbfdac73 [FIX] *: incorrect translations markings
Fixes a large number of cases where strings are translated then
formatted, instead of letting `_()` do the formatting internally,
which allows it to recover from incorrect translations (missing,
broken, or extra placeholders).

Also

- removes translation markers entirely when there's nothing to
  translate e.g. `_("%s - %s")` is not useful
- fixes a few messes which lead to only partial translatability
  (DRY is generally a bad idea when translations are involved, even
  more so when you don't make the variable part translatable)
- fixes a few nearby issues noticed at the same time
- replaces a few `"%s"` by `%r`, which should automatically quote
  strings relatively appropriately
- fixes translated strings which use `\` to escape a newline (in order
  to fill-paragraph): `\` escapes only the newline, if the
  continuation string is indented this results in a bunch of spaces
  ending in the string to translate, which is pretty garbage for the
  translator, using implicit concatenation works much better

Note: some of the updates revert f-string parameters to %, because
babel (2.9) apparently has trouble with f-strings and blows up trying
to extract them.

Not in scope:

Helping translators fix translatable strings e.g. any translation
string with more than one placeholder probably should use keyword
placeholders

- Provides more context / data to the translator to make sense of the
  sentence.
- Allows reordering the translated terms, which can be necessary
  depending on the sentence and language.

closes odoo/odoo#139314

Related: odoo/enterprise#49311
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-10-23 16:45:09 +00:00
Loukas Wets (lowe) b512d5f0b6 [FIX] point_of_sale: New mobile order list display
Prior to this commit the displayed order information in the order list
was inconsistent. This commit rearranges the displayed information.

Task-3502304

closes odoo/odoo#134969

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-09-13 10:55:51 +00:00
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
Gorash 75a105f46a [REF] base/all: Update modifier syntax: remove 'states' from fields
These changes are made as a result of simplifying attrs and 'states' in
views. However, they should have remained in a separate commit. When
applying the script making the xml changes (used later for the migration
script), the script checked the definition of the python fields in order
to convert the information into a python expression. Therefore, this
commit is not applied when the script is applied to xml changes.

During this attribute deletion pre-existing errors were found. Part of
the code was using the boolean values of 'states' and another part of
the code was not. The behavior could therefore be different (in cases
where readonly on the field had the same value as the ballan in
'states').

Following the deletion of 'states' and without the application of the
view migration, the js tests (tower) were no longer functional. Tests
using the Form view suffered the same effect. There are few tests that
had to be adapted, including two tests in business accounting (updated
by the accounting team). A test for column_invisible did not work. Test
checking if the test system triggers an error if we try to write on an
invisible field. It turns out that Form was testing on the value of
invisible but not taking into account if the column was invisible. The
test system fix is applied separately because there were a lot of tests
that were incorrect.

Part-of: odoo/odoo#104741
2023-08-18 09:49:11 +02:00
vlst f2a107ff29 [FIX] pos*: various ui fixes
pos*: point_of_sale, pos_hr, pos_restaurant

In this PR we fix a number of small UI issues in the point of sale app.

Issues fixed:
- Align filter option in the TicketScreen search bar;
- Align items in the opening popup that shows the available
login options in the pos_hr module;
- Align tips column in ticket screen;
- Made it so clicking on the employee icon does not open the
selection popup if there is only one employee configured
( as it will be empty in this case );

closes odoo/odoo#131351

Task: 3458435
Related: odoo/enterprise#45526
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-08-17 10:33:05 +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
vlst 8f3971a780 [FIX] point_of_sale,pos_restaurant: ui issues
In this PR we fix a number of small issues related to the pos ui.

In addition to the specific fixes, this PR also simplifies many
of the components, most notably the `category_selector`.

In the interest of providing a cleaner API, this PR introduces
a new folder called `generic_components` whose goal is to contain
stateless components. These stateless components would allow for more
reusability, while simplifying the logic. The `category_selector` is
the first component in this folder.

Descriptions of each of the issues fixed in this PR can be found in the

closes odoo/odoo#131038

Tasks: 3457213
Related: odoo/enterprise#45600
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-08-10 17:02:03 +02:00
David Monnom (moda) 01b3a2e4c2 [REF] point_of_sale, pos_*: only use export_for_ui for serializing
*:pos_hr,pos_hr_restaurant,pos_loyalty,pos_restaurant

Before when serializing a pos.order from the server, we are using
several methods for different use cases.

- table syncing: get_table_draft_orders
- order sharing: get_draft_share_order_ids
- ticket screen: export_for_ui

All of these methods had their own logic.

Now, to improve the maintainability of point_of_sale, order
serialization is only performed via export_for_ui.

Enterprise PR: https://github.com/odoo/enterprise/pull/45151

closes odoo/odoo#130695

Taskid: 3449870
Related: odoo/enterprise#45151
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-08-08 18:40:52 +02:00
quyen 85439d383a [FIX] pos_hr: Avatar display error
If the user only has "Point of Sale" permission but not "Employees" permission, the image will not be displayed using the link "/web/image/hr.employee/${cashier.id}/avatar_128"
instead use "/web/image/hr.employee.public/${cashier.id}/avatar_128"

closes odoo/odoo#130566

X-original-commit: 152e1a360fad3de1bc5363bf476e26f48563e5c0
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-08-03 09:23:24 +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
vlstandXavier Luyckx 01ffba8695 [REF] pos*: refactor pos screens
pos*: point_of_sale,pos_hr,pos_loyalty,pos_restaurant,
pos_sale,

In this commit we refactor some parts of the pos ui with the interest
of providing a simpler and cleaner codebase.

One pattern that is heavily used in the pos ui is that in which
views are changed based on the screen size at the component level.
This means that it becomes very difficult to understand what parts
of a specific template will be seen in mobile or in desktop views.
In most cases, the pos adapts for mobile screens by using the same
main components, but in different configurations. For example, a
component that was visible in desktop mode, might become accesible
through a menu in mobile mode.

In order to improve the situation, the proposed solution is to
separate the logical parts of the ui into `owl templates` and
to inject this templates wherever the need arises.
Thus, instead of constantly using `t-if="ui.isSmall"` in all places
where there is a difference between the mobile and desktop views,
we have a main conditional branch at the root level of the component
representing a certain screen and then build 2 separate views, one for
mobile and one for desktop, each calling the needed templates.

In this commit we implement this pattern for the `payment_screen`.
This will allow us to observe this pattern over a period of time,
before implementing it on the other screens.

In this commit we also:
- add small fixes and improvements relating to
  the previous commit, in which the pos was
  refactored to bootstrap;
- replace the `<br>` tags in the numpad component
  with the bootstrap grid system;
- adapt the `cash_move_popup` to rely more on `t-model`
  and less on `t-on-change`

Part-of: odoo/odoo#129544
Co-authored-by:  vlst <vlst@odoo.com>
Co-authored-by:  Xavier Luyckx (xlu) <xlu@odoo.com>
2023-07-28 16:28:45 +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
Pierre Pulinckx (pipu) 8bfa76a842 [REF] *: Unify _t and _lt
The goal of this commit is to prepare ground to remove
lazytranslate function _lt() and keep only _t()
for a better understanding of the use of the translation function.

In this commit,

the translate function _t() has been updated to return the translation
if they are loaded. If not, it throws an error.
the lazytranslate function _lt() returns _t() function.
Corollaries :
Steps in test tours are now a function that returns an array of steps
to avoid any interpolation of _t in this ones before translations has
been loaded.

Example :

registry.category("web_tour.tours").add("example", {
    test: true,
    steps: () => [
        {...},
        {...},
    ],
});

task-3292454

closes odoo/odoo#124157

Related: odoo/enterprise#43153
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-07-19 13:13:16 +02:00
Theo VINCENT (thvi) 3fa87c8c47 [ADD] pos_online_payment, *: add online payments
*: point_of_sale, pos_adyen, pos_hr, pos_mercury, pos_restaurant

Adds online payments in Point of Sale using the payment module.
The pos_online_payment module is meant to be used by shops for paying online instead of using a physical terminal and by restaurants for paying an order either from the paying station or in the self-order process (smartphone used to order and pay online).
The module depends only on point_of_sale (and account_payment to support online payments).
The online payments support for self-order will be added in another commit.
The feature can be used by configuring a special pos.payment.method for one or many pos.config.

Operation:
The frontend session user can enter one or several online payment method lines (with or without other payment methods).
When he validates the order, if the online payment amounts are valid, a popup with a QR code is displayed on the frontend screen and on the customer display. This QR code allows the customer to open the payment page to pay online for the order.

The amount to pay for an order on the payment portal is the remaining unpaid amount or a lower amount if several online payments lines are used. Therefore, at any time, the customer will be able to pay the amount of the order that is unpaid, without requiring a staff operation to update the amount to pay.

When an online payment is done for a POS order, the generated account.payment is linked to the POS order through a pos.payment that is created with the online payment method configured for the pos.config, and the POS order paid process is triggered (it is the responsibility of the server to finalize the validation of POS orders that have at least one online payment, and not the responsibility of the POS session web client). If for any reason, there is no longer any online payment method configured for the pos.config of the order, a new one can be created automatically and exceptionnaly used to link the done payment with the POS order. This guarantees that any online payment saved by the payment module will be linked to the POS order.

The session web client is notified of successful online payments through web socket communication, to make the cashier screen automatically and quickly react to payments.

If several online payments are used for a single POS order, they are processed one after each other.

Working principles:
 - The POS session web client is not allowed to save online payments on the server. Only the Odoo server, which handles the payment, can save online payments for a POS order.
 - The POS session is only responsible for saving the order (especially other payment methods) and the next online payment amount to pay (in case of several online payments) on the server before the online payments are made by the customer, and for displaying the online payment status and the link (QR code) to open the payment page.
That means that modifications that are made after the order is fully paid are not taken into account by the server.
 - Before validating an order, the POS session checks with the server if any online payment has been made for that POS order. If the user wasn't aware of one, the validation process is aborted, notifying him.
 - The sensitive online payments data is received by the frontend user with RPC to the server when validating an order, cancelling an online payment or receiving a notification through the POS bus (web socket communication).
This data is used to update the cashier data for the specific order.
 - No sensitive information is sent through the POS bus (web socket communication).
Indeed, the bus communication is only protected by the name of the channel, and there is no mecanism to prevent several attempts. Therefore, no sensitive information is sent through it, only a notification to invite the local browser to do a safe RPC to the server to check the new state of the order.
 - Online payments for a POS order cannot be modified or removed when they succeeded. Checks ensure to never allow an online payment to make the total paid amount greater than the total amount of the POS order.
 - If the frontend user clicks on the "Cancel" button of the online payment popup, the order can potentially still be paid online. Indeed, the order will be removed from the server only if it was added only for the online payment flow, and any order that is not paid can be paid on the online payment portal (if the customer has the web link).
This behavior ensures that in a shop, starting an online payment and then cancelling it doesn't prevent the user to close the POS session. And it ensures to don't delete a draft order that is used for other flows, like in a restaurant or when there are trusted POS configs.

Payment portal features:
 - The payment portal pages of a POS order are protected with its access_token.
 - If the amount of the order has changed when the customer clicks to pay, an error is fired to notify him and give him the choice to continue or abandon the payment.
 - An exit_route argument (an URL) can be passed to allow the customer to exit the payment portal at any time (with a button), which could be used for self-order flow.
 - A button to go back to the payment page is displayed when an error occurs during a payment transaction, which allows the customer to retry a payment without needing to scan again the QR code.
 - If the customer is not logged in in the payment portal (most frequent case), it is considered as the public user partner for the payment flow to don't give him privileged access to sensitive data like payment tokens.
 - The accounting process of online payments for POS orders is made in the same way that the pos.payment.method that have split_transactions to True.
 - The POS customer of a POS order has no link with the customer making an online payment for that POS order.
 - The payment portal is made using the pos.order id and not the pos_reference because the latter is not guaranteed to be unique.

Some tests have been written, especially one that simulates a whole online payment flow starting from nothing, creating an order, requesting an online payment, faking this online payment by doing web requests to the payment portal, then finally closing the POS session to check that there is no accounting issue.

The design of the payment portal is temporary.

closes odoo/odoo#123237

Task-id: 3276404
Related: odoo/enterprise#41776
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-07-18 19:27:56 +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
David Monnom (moda) a3d530c846 [IMP] point_of_sale,pos_hr: add employee manager role
Currently, POS-allowed employees can manage cash:
- at the opening (cash control)
- on cash payment

Now, after adding the mananger role, it is possible for an employee to
open the cash register. In the settings of a `pos_config`, you can add
employees with a "basic" role and with a "manager" role, the latter
grants the same rights as a classic odoo manager user.

closes odoo/odoo#122287

Related: odoo/upgrade#4700
Signed-off-by: Guilliams Adrien (adgu) <adgu@odoo.com>
2023-06-15 17:36:08 +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
Loukas Wets (lowe) 2649dc3205 [IMP] point_of_sale: trigger cash drawer opening when cash transaction
Adding methods to trigger the cash drawer opening as well as a log in
the message to state by who and for which action the cash drawer was opened.
There is also a log now for when in an action for which the cash drawer
was opened is canceled. The action concerned are: Cash control at opening,
cash in / out, Cash control at closing.

task-3293113

closes odoo/odoo#121110

Signed-off-by: Monnom David (moda) <moda@odoo.com>
2023-06-01 17:55:09 +02:00
Adrien Guilliams (adgu) 60f41b1f83 [IMP] pos: Change waiter screen
The PoS needed improvments for the mobile use.
This commit is changing the display of some screen and popups
like the NumberPopup. It also changes the logic of the
order count badge on the table. It now displays the number
of orderline (and their quantity) to send to the printers
or preparation display if there is at least one.

closes odoo/odoo#121286

Related: odoo/enterprise#41013
Signed-off-by: Monnom David (moda) <moda@odoo.com>
2023-05-25 16:29:11 +02:00
Samuel Degueldre c7ce04a8ed [REF] point_of_sale, pos_hr: remove HeaderButton
The HeaderButton component is used once and is mostly presentational,
this commit inlines it into the navbar.

closes odoo/odoo#122035

Related: odoo/enterprise#41336
Signed-off-by: Monnom David (moda) <moda@odoo.com>
2023-05-24 14:27:59 +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
Louis Wicket (wil) 04189318cc [I18N] *: update master translations
Currently, only stable releases see their translations updated. This has
resulted in master accumulating outdated stuff for years, which can be
confusing for users testing master on runbot.

This one-shot commit resynchronizes master translations based on the
content from 16.0 and removes empty PO files (i.e. no longer containing
translations).

closes odoo/odoo#121629

Related: odoo/enterprise#41171
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-05-22 17:52:07 +02:00
Martin Trigaux 077bbd0b0b [I18N] *: export master source terms
closes odoo/odoo#121563

Related: odoo/enterprise#41140
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-05-17 10:34:00 +02:00
David Monnom (moda) cd81cc64ed [FIX] point_of_sale,pos_*: launch test with demo user
Before the PoS tours were mainly run with the `accountman` user, which
did not allow us to have a clear view of the permissions required for
each function of the Point of Sale.

Now, two users have been created for the PoS:
- `pos_user`
- `pos_admin`

The first one has no particular permission, he is a normal user of the
Point of Sale and Odoo, the second one is an administrator of the Odoo
application.

If the user `pos_user` is used and some permissions are missing in a
tour, these are added to the user with starting the test.

closes odoo/odoo#120380

Related: odoo/enterprise#40656
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-05-15 13:59:09 +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
Samuel Degueldre d11bf24dea [REF] pos*, web: make pos service start asynchronously
*: point_of_sale, pos_hr, pos_restaurant

Previously, the pos service started synchronously, but doing anything
meaningful with it needed to be done after it was "ready", meaning it
had loaded and processed the data. The reason for this is that we need
to start the services before we mount the chrome, but in the pos we want
to show the loader immediately while the data is loading. This means
that any service that depends on the pos service in a meaningful manner
has to be written in a convoluted way, where it starts as a dummy
service and then overwrites itself in the env when it's actually ready.

This commit allows to write services that depend on the pos service more
naturally, by making the pos service properly asynchronous, meaning its
dependents will only be loaded once it's actually ready. To work around
the loader issue, the loader is mounted as a separate owl appplication
with not services, this application is shown over the chrome and when
the chrome mounts, it hides the loader and destroys the loader
application after the fade-out transition.

closes odoo/odoo#119908

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-04-28 13:33:15 +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
Joseph Caburnay 73b9d48703 [REF] point_of_sale,pos_*: convert barcode_reader to service
**Notable feature changes**

- PoS app continues to load even if no nomenclature_id is configured.
  - When scanning, an error popup is shown to the user mentioning about
    the misconfiguration.
- We introduce a default error handler that shows the ErrorBarcodePopup
  when there are no registered barcode handlers via the
  `useBarcodeReader` hook.

closes odoo/odoo#115906

Related: odoo/enterprise#38444
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-03-24 03:28:42 +01:00
Joseph Caburnay 1adff226b7 [FIX] pos_hr: restore barcode scanning when multi employee is active
When refactoring the SelectCashierMixin into a hook, the "exclusive"
parameter was hardcoded to true, this makes it so that when
multi-employee per session is active, the cashier selector button in the
navbar takes exclusive control of the barcode reader and prevents
scanning products. The exclusive mode should only be active in the login
screen.

This commit fixes that by making "exclusive" configurable in the
useCashierSelector hook and making it non-exclusive in the navbar's
cashier selector.

closes odoo/odoo#116159

X-original-commit: d78e0b840a3fbcbe43bf2a4938977a63fbeec1e9
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-03-22 14:52:30 +01:00
Joseph CaburnayandJulien Mougenot 3a798039d6 [REF] web_tour,*: convert web_tour to owl
* The tours are now run by the `MacroEngine` defined in `macro.js`.
  * This is accomplished by converting (at runtime) the user-defined tours to
    `Macro`s. See `tour_compilers.js` for the step (and tour-to-macro) compilation.
* API is kept the same as much as possible. Basically, declaring tours stayed
  the same with some exceptions:
  * `allowInvisible` can be provided in a step to allow consuming the trigger
    element even if it is invisible.
  * `isCheck` can now be used to replace the no operation `run` that is
    traditionally signals the runner to only perform a check.
  * Before, multiple `run`s can be called simultaneously. Now, each `run` method
    is awaited before proceeding to the next step.
* If the trigger element is `disabled`, the tour runner will *not* proceed on
  calling the `run` method and the runner will stay on current step until the
  trigger element becomes `enabled`.
  * However, the tour runner is okay with `disabled` trigger element if the step
    has `isCheck = true`. As long as the trigger element is found for `isCheck`
    step, the tour runner will happily move to the next step.
* Some tours are adjusted to properly run with this new tour runner.
* When the tour failed:
  * The dom string is not logged anymore.
  * However, a warning message containing the relative location of the step will
    be logged. This is better in helping the author in locating the failed step.

**Some guidelines learned during the development:**

* Each step may trigger a dom mutation. It's a good practice to insert an
  intermediate step that *checks* the existence of an element that result from
  the action of the previous step.
* Refrain from using the `run` method for assertions. `run`, in principle, is
  provided to perform actions that are not offered by the helper. Use the
  `trigger` for assertions.
* During dev, find `SHOW_POINTER_DURATION` and set it to `250`. This will show
  the pointer (pointing to the trigger element) for 250ms when watching the
  tour.

closes odoo/odoo#107618

Task-id: 3082036
Related: odoo/enterprise#37560
Signed-off-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
2023-03-15 13:19:45 +01:00
Louis Wicket (wil) 9afe7c74c9 [IMP] *: remove "French spacing" 👺
According to Wiktionary, French spacing is "the archaic practice (though
still current in French) of inserting a space around colons, semicolons,
question marks, and exclamation marks". This is not standard practice in
English and most languages of the world.

The purpose of this commit is to start purging the code from this typo,
as it may reflect poorly on the software for some people.

closes odoo/odoo#114533

Related: odoo/enterprise#37853
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-03-14 15:52:10 +01:00
Adrien Guilliams (adgu) 53f9e5845f [IMP] point_of_sale, pos_restaurant: Add cross-orders feature for point_of_sale and pos_restaurant
Currently the below use-cases are hardly supportable, though quite common:

Retail: Sell product in one shop and return it in another one
Restaurant: Managing payment when having multiple checkout desks,
 and multiple waiters (only taking orders)

This because currently:

PoS orders are only known by the cashier desk (pos.config) they were created from
One floor map can only be linked to one cashier desk at a time

More over, with the Self-Service coming along the way
(where kiosk orders must be accessible from a cashier desk),
this need must be supported.

For restaurant, floor plans can be linked to multiple cashier desks,
ongoing orders are shared between trusted PoS config
(through floor plans for restaurant and according to
the setting "Trusted PoS config" for the retails),
and past orders can be accessible from any desks within a same DB.

closes odoo/odoo#109216

Related: odoo/upgrade#4393
Related: odoo/enterprise#37955
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2023-03-10 18:54:52 +01:00
David Monnom (moda) 7b14d73a5a [REF] point_of_sale,pos_*: remove legacy posbus
closes odoo/odoo#113782

Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-03-08 09:26:47 +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
roen-odoo df9bfb17da [FIX] pos_hr: correctly send back to login screen after cancelling badge
Current behavior:
When a user scans a badge, the user is prompted to enter his pin. If
you click on cancel on the pin window you would be sent directly in the
pos and no user would be logged in.

Steps to reproduce:
- setup any employee badge with number and PIN
- Enable Multi Employees per Session in POS settings
- Open a new session for this POS
- Scan the badge with barcode scanner
- At password screen, click cancel
- No employee is shown in the top right but the session can be used

opw-3110299

closes odoo/odoo#111513

X-original-commit: 79a32fca91538a179a0f546a552176b46134c403
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2023-02-01 16:39:51 +01:00
Géry Debongnie b53f78e224 [REF] web_tour,*: use the registry in collecting the tours
This is a step closer to a goal of avoiding dependence on asynchronous
modules. Starting from this commit, new tour definition should be
registered to `registry.category("web_tour.tours")` registry.

So, instead of the following:

```js
import tour from "web_tour.tour";
tour.register(name, options, steps);
```

We now do:

```js
import { registry } from "@web/core/registry";
registry.category("web_tour.tours").add(name, optionsWithSteps);
```

Notice the `options` and `steps` params are merged when registering
the tour definition. It should look something like so:

```js
registry.category("web_tour.tours").add("account_tour", {
  test: true,
  steps: [ ... ],
});
```

And if the `TourManager` instance is needed, one can get it from the
registry like so `registry.get("tourManager")`. Note however that
this instance is only available when the `TourManager` has been
instantiated -- so it's not available at top level of the module.

closes odoo/odoo#111103

Related: odoo/enterprise#36335
Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-01-27 23:17:35 +01:00
Samuel Degueldre 7c3194ef73 [FIX] pos*: add missing arguments forwarding in _super calls
*: l10n_fr_pos_cert, l10n_gcc_pos, pos_hr, pos_loyalty, pos_mercury,
pos_restaurant, pos_restaurant_adyen

In odoo/odoo#109928 the custom inheritance system of the pos was removed
and a bunch of modules were adapted. In a lot of those places, the
_super calls didn't forward the arguments to the super method, resulting
in broken methods. This commits fixes that.

closes odoo/odoo#110962

Related: odoo/enterprise#36269
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-01-25 16:37:10 +01:00
pedrambiria b260d95a56 [FIX] pos_hr: keep the validating cashier as the final cashier
Before this commit: if cashier A starts an order, and cashier B completes
the order and validates it, the order would be saved to the database as
belonging to cashier A, but cashier B will be printed on the receipt.

The problem is that `employee` has been refactored to `cashier` in this
commit:
https://github.com/odoo/odoo/commit/0e7fdbe06cce41bdea1af9a96205a2ea0cf041a6
But `employee` hadn't been changed.

The solution is to keep the cashier who validated the order as the final
cashier.

opw-3114318

closes odoo/odoo#110695

X-original-commit: a3baacb0c3a631f52ce97c0179b4c7c7888471dc
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2023-01-24 13:47:12 +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
Jacky (trj) d0f89b3478 [IMP] point_of_sale,pos_*: back to basics
Overall improvement and simplification (along with some minor re-alignment)
for the point of sale.

POS Dashboard:
- added a new check for companies that hasn't installed any chart of account,
this gives them a better understanding of the real problem.
- added a new `menuitem` in the configuration tab that list all the pos configs,
this gives the user a way to access the sub-config of a pos (and indirectly give
access to its whole settings)

Opening/closing control:
- the `MoneyDetailsPopup` is now opened through the `showPopup` method, we're
no longer using the css to show/hide.
- the details of the money (if it exists) is now given to the `MoneyDetailsPopup`
component, this allows to have a record data usable of the details and
the user doesn't have to start from scratch if he just wants to modify
one thing
- opening the `MoneyDetailsPopup` no longer resets the cash input, that way the
user can just quickly check if everything is correct again without having
to recount everything and this won't reset the outcome

Customer display:
- added "Powered by" before the Odoo logo in order to accentuate that
it's from the software used is from Odoo

Product screen:
- visual improvement of the `EditListInput` component which is mostly
used by the lot/serial number, it gives more information to the user
and better UX
- "Cash out" is now automatically selected upon opening the
`CashMovePopup`. No more minus sign (-) in the input amount. This
should give better intuitiveness and one less click to do
- no more clear search button shown if the search input is empty
- removed the hover and clickable effect on `CashierName` component
in the normal point_of_sale since nothing happens when we click on it
- increased the width of the click zone with a label in the
`ProductConfiguratorPopup` which makes it easier to select a radio input
- the `PrintBillButton`, `SplitBillButton`, `RewardButton` and
`ResetProgramsButton` are now disabled when nothing happens
- the `textarea` of the `TextAreaPopup` component has been fixed
and is no longer resizable

Partner list screen:
- fixed phone, mobile and mail icons the contact area
- increased details button size

Floor screen:
- when idle, no longer redirect to the floor screen if there's
an open error popup. An error popup is opened for a specific
reason, we shouldn't redirect while having this open or
automatically close it. Other kinds of popup will be
closed since those are issued by the user that went away.

task-2916197

closes odoo/odoo#97803

Signed-off-by: Masereel Pierre <pim@odoo.com>
2022-11-14 12:03:51 +01:00