Commit Graph
974 Commits
Author SHA1 Message Date
Theo VINCENT (thvi) ef05b6ef55 [FIX] pos_restaurant: fix tips after payment flow
- Fixes tips ticket printing when there are tips after payment.
 - Makes the ReceiptScreen opened after TipScreen, to show the receipt screen even when there is a tip added after payment.

closes odoo/odoo#127548

Task-id: 3394214
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-07-06 17:52:19 +02:00
Adrien Guilliams (adgu) ebbb81f2de [FIX] pos_restaurant: assertion of restaurant tour not ok
The pos_restaurant first test (test_01_pos_restaurant) has an assertion
that failed due to the fact that the deleteion of an order is
not awaited in the frontend. This led to the tour finishing very fast
after the orm call and the assertion done just after that. We add steps
in this test to see if the orm call has been done propely before ending
the tour.

Runbot Error: 22613, 22614

closes odoo/odoo#126779

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-07-03 11:02:49 +02:00
vlst deb015a069 [FIX] pos*: Fix order removal
pos*: point_of_sale, pos_restaurant

When deleting an order, the restaurant override of the deletion function
in `point_of_sale` interferes with the logic in such a way that we end up
writing the order that needs to be deleted 2 times.

This is obviously not the expected bahaviour. In this PR we remove
the `override` from `pos_restaurant`, as it is no longer needed and
we also add a mechanism that ensures that orders cannot be duplicated.

closes odoo/odoo#126442

Task: 3383043
Signed-off-by: Adrien Guilliams (adgu) <adgu@odoo.com>
2023-06-27 16:26:56 +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
Theo VINCENT (thvi) 3236c1cb50 [IMP] pos_restaurant, *: default settings and data
*: point_of_sale, pos_self_order

Changes:
 - Adds a default restaurant with some default usual settings (with tips after payment if the company is in the United States) but no floor in the Point of Sale app. Makes pos_restaurant module auto installed with point_of_sale.
 - Makes some restaurant settings enabled by default (only for restaurants).
 - Adds loadable default demonstration data for onboarding (only when no real product is available in POS), specific to a restaurant. The default demonstration data for onboarding of point_of_sale and pos_restaurant are loaded together (if pos_restaurant is installed) to make it so an user that clicks to add demo data will have demo data for the default point of sale and also for the default restaurant (and the current restaurant if it is different than the default one). Makes the load demonstration data button visible when there is no product with a positive price available, because without that condition the tips (in restaurant) and discount were preventing the display of the button.
 - Hides the Preparation Printers menu item if there is no POS config using the printers.
 - Renames some labels.

Fixes:
 - Adds checks to always set set_tip_after_payment to False if a point of sale is no longer a restaurant or if the tips are disabled. This is needed because the code of pos_restaurant seems to be written considering that set_tip_after_payment is True only when the point of sale is a restaurant with the tips enabled (which wasn't guaranteed). Without that checks, some tests like ReceiptScreenTour fail. Another solution to make the tests successful without that checks would be to add !this.env.pos.config.module_pos_restaurant in pos_restaurant/static/src/js/Screens/PaymentScreen.js:16. But because other parts of the code only check the value of set_tip_after_payment, I think it is better to opt for the additionnal checks.
 - Fixes duplication of displayed product categories when loading demonstration data.
 - Fixes products before loading demonstration data that were kept and displayed after (discount for example).
 - Fixes categories and therefore communication with the preparation display after loading demo data in a restaurant.
 - Adds a check on the server side to prevent demonstration data loading when there is at least one valid product for POS.
 - Fixes order count display when "NaN" (in floors and tables view).
 - Fixes arguments of orm call for set_not_tip (model and method names were not given in the right order).

closes odoo/odoo#117941

Task-id: 2484291
Related: odoo/enterprise#39450
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-06-26 20:00:35 +02:00
pedrambiria 1214542413 [FIX] pos_restaurant: stay on current table after refund
Previously, when conducting a refund on a table, the system would
switch the active table to the table associated with the refunded
order. This was not the desired behavior, as it resulted in the details
of the order disappearing, requiring the user to navigate back to
the refund process.

Steps to reproduce the issue:

 - install PoS restaurant
 - pick a table, do an order and pay it
 - pick another table, refund
 - choose the previous order and refund
-> the order details disappear directly. You have to go back to refund.

opw-3301603

closes odoo/odoo#125908

X-original-commit: 1f560c8954359a15ba84eb695c7eca380722f9fc
Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
2023-06-22 08:35:04 +02:00
vlst 42087c6fa1 [IMP] point_of_sale: Allow products to be part of multiple pos categories
Currently, a product can only be part of one `pos_category`.
This PR changes the relationship between the `product` and the `pos_category` from a `One2many` to a `Many2many`.

closes odoo/odoo#122907

Task: 3138825
Related: odoo/enterprise#41791
Related: odoo/upgrade#4739
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-06-21 13:45:50 +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) a0aff5bda2 [IMP] pos_self_order: refacto, models and serverside price calculation
General refactoring of the codebase. Inline of certain components
that had no logic in the JS side, the XML of these components was
directly added to the place where they were called.

Simplification of the python controller, inline of many functions and
separation of the logic. There is now one function that manages new
orders and another that manages and updates existing orders if we are
in "pay after meal" mode. In "pay after each" mode, orders cannot be
edited.

Addition of different models, product, order and orderlines in order to
facilitate the use of these objects between the backend and the
frontend.

Added price calculation on the serverside because we can't trust the
data coming from the customer in the self since no identification
is required.

Management of last change sent added. Thanks to this, users will no
longer be able to click on the order button if no changes have been
made to the order.

closes odoo/odoo#122901

Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
2023-06-16 14:59:31 +02:00
vlst 55c8840a44 [IMP] pos_restaurant: Enable Floor Plans Link
The link to the `Floor Plans` configuration is only visible in debug mode.
This makes for a bad user experience.
This PR makes it so the link is always visible to `pos users`, regardless of whether
or not the user is in debug mode.

Task: 3357989
Part-of: odoo/odoo#124255
2023-06-16 09:34:49 +02:00
pedrambiria 88124fcf60 [FIX] point_of_sale: prevent removing order after bill screen timeout
steps to reproduce the issue:
-Navigate to POS, Open Bar (needs to be restaurant POS)
-Click on a table and add some items to the order.
-Click the Bill button under the order
-Wait about 90 seconds
-Bill page times out and goes back to the floor screen
-Click on Orders at the top and view Ongoing Orders. The one you just
made is not here (it should be)

The solution is to prevent removing the not finalized order when
coming back to the FloorScreen.

opw-3276345

closes odoo/odoo#124960

X-original-commit: be384e27ced7c256867938c53aa5d2a7d81c0ade
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
2023-06-14 10:54:53 +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
David Monnom (moda) 3db548c76f [IMP] point_of_sale,pos_restaurant: add bus_service
Before a longpolling every 5 seconds was set up to sync the number of
orders per table in the pos_restaurant, which was not very
userfriendly / efficient.

Now, the longpolling has been replaced by a bus (websocket). As soon as
an order is sent to the server by another PoS, the server dispatches the
information to all other PoS using the corresponding floor plan.

The bus_service was initialized in the pos_store of the point_of_sale,
but is now used only in the pos_restaurant via override.
This was done for obvious future use.

closes odoo/odoo#121875

Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
2023-05-31 14:23:24 +02:00
David Monnom (moda) c997ac8e11 [IMP] pos_*: order btn is always primary
closes odoo/odoo#119032

Related: odoo/enterprise#39981
Signed-off-by: Guilliams Adrien (adgu) <adgu@odoo.com>
2023-05-26 11:40:33 +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
Adrien Guilliams (adgu) a04adfac93 [FIX] pos: fix pos traceback when delete order
This commit resolves 2 bugs.
The first one is that, in a PoS without pos_restaurant installed,
if we delete the last order of the list, we get a traceback.
This is resolved by adding an empty order if there is no order left
in the order list.

task-id: task-id: 3291831

The second bug is that, with pos_restaurant installed,
when going to a retail PoS, if we createan order with some products,
then create a new order from the TicketScreen, add some products,
go the the TicketScreen and delete the current order
and then click back, we have in the ProductScreen the order
that is supposed to be deleted.
This order doesn't show up in the ticket screen anymore.
This comes from the fact that the _selectNextOrder function is
not correctly implemented, leading to the next order not being
chosen because we do not have a table (we are in classic PoS).
This fix resolves this problem by changing the _selectNextOrder
function and the newly added addOrderIfEmpty function in models.js.

closes odoo/odoo#122269

Task-id: 3291821
X-original-commit: cd956daf21695bef4753301fe29a6ece1e97d32a
Signed-off-by: Monnom David (moda) <moda@odoo.com>
Signed-off-by: Guilliams Adrien (adgu) <adgu@odoo.com>
2023-05-24 14:28:25 +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
Samuel Degueldre ebe526241f [REF] point_of_sale, pos_restaurant, pos_sale: remove useless base class
The IndependentToOrderScreen base class is used when a main screen
should not be stored on the order (so that it can be restored when the
order is selected again). Its implementation is simply a class with a
static flag, and a super simple close method which just calls the
equivalent method on the pos store. It has been removed and the classes
extending it have been adapted.

Part-of: odoo/odoo#122035
2023-05-24 14:27:59 +02:00
David Monnom (moda) e47bd1d71e [IMP] point_of_sale,pos_restaurant: cancelled order to preparation tools
Before when you deleted a order in PoS with the preparation tools
enabled. The order was not cancelled on them.

Now, when cancelling/deleting an order in PoS the information is sent
to the preparation tools.

closes odoo/odoo#120447

Taskid: 3278081
Related: odoo/enterprise#40673
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-05-23 18:01:35 +02:00
David Monnom (moda) d9f6a5d209 [IMP] point_of_sale,pos_restaurant: improve offline popup
Before when the point_of_sale was offline, popups were opened at each
RPC error. This was inconvenient for the user as the pos must be usable
offline.

Now, the error popup has been replaced by an alert popup explaining that
the point of sale works in limited version as long as it is offline.
The warning noise has also been removed.

closes odoo/odoo#120826

Related: odoo/enterprise#41323
Signed-off-by: Guilliams Adrien (adgu) <adgu@odoo.com>
2023-05-23 16:31:36 +02:00
David Monnom (moda) b22e770fd0 [IMP] point_of_sale, pos_*: misc ux improvement
- Modification of the search button on mobile to keep a fixed position.
- Modification of the splitbill system, after the validation of a part
ofthe order, a continue button is displayed in order to finish the
payment of the rest of it.
- The INPUT popup can now be validated by pressing the "enter" key.
- Debug widget is now hidden by default. And a button is added in the
burger menu to toggle its visibility.
- When adding a product with optional products the info popup is no
longer opened automatically but if the orderline is selected in the
order the info button will be highlighted.

closes odoo/odoo#119919

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-05-23 16:31:24 +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
Loukas Wets (lowe) 8a2e9c74ba [IMP] point_of_sale: set a pos config when a new company is created
A new POS config with the name `Shop` is created when a new company is
created with a dedicated fiscal postion and if `point_of_sale` is
installed. A `Bank` payement method is created for the POS, as well as a
`Customer Account` payement method. If a there is a cash journal that is
not already linked to a payement method it would create a cash payement
method for the dedicated POS. If the module `pos_restaurant`is installed
it would also create a POS config with the name `Bar` of type restaurant
with the same specification as for the normal pos config `Shop`.
Since the changes create default configs along with payement methods,
there was some conflicts with the test instances. Therefore the payement
methods where unlink in the set up of the test to resolve the conflicts.

task-3244511

closes odoo/odoo#119221

Related: odoo/enterprise#41003
Signed-off-by: adgu-odoo <adgu@odoo.com>
2023-05-17 10:33:53 +02:00
David Monnom (moda) e3514aad08 [FIX] point_of_sale,pos_restaurant: wrong error handler
When an error of type "ConnectionLostError" arrives in the PoS, we catch
it in order to warn the user. In the catch, a bad detection of the
instance of this error was made which blocked the flow by throwing
an error.

We were checking whether the error message was an instance of a
ConnectionLostError in a way that assumes that the error was a legacy
error which is no longer the case since the POS no longer uses the
legacy rpc service. This commit adapts the instanceof check

The necessary changes have been made, it now works.

closes odoo/odoo#121536

X-original-commit: 963ea1c5779fbf7af7d5421a294ca2a24d7940af
Signed-off-by: Samuel Degueldre <sad@odoo.com>
Signed-off-by: Monnom David (moda) <moda@odoo.com>
2023-05-16 15:55:44 +02:00
Samuel Degueldre ba29387924 [REF] pos*, web: use reactivity to react to changes in UI size
pos*: point_of_sale, pos_restaurant, pos_sale

Previously the pos would rerender the entire UI when the window was
resized. In practice, most components do not care about the size of the
UI for their rendering, and so we're doing a lot of needless work, and
also using an owl feature (deep renders) whose perennity is not certain
(we may want to remove the ability to do deep renders completely in the
future).

This commit changes the pos code to use the ui service `isSmall` field,
makes the ui service reactive so that components can subscribe to
changes inside of it with `useState`, and makes the ui service update
its internal state at most once per animation frame, instead of after
100ms without resizing, so that resizing the viewport results in a
smoother user experience.

closes odoo/odoo#121343

Signed-off-by: adgu-odoo <adgu@odoo.com>
2023-05-15 13:59:22 +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
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
Brieuc-brd 418413e499 [IMP] web, *: directional icons
This commit adapts the directional icons to improve the usability and
maintain consistency with the ui icons library.

task-2818586

Part-of: odoo/odoo#116641
2023-05-12 22:59:22 +02:00
Elisabeth Dickinson b2ef35a431 [IMP] *: replace .bg-color by .text-bg-color on ribbons
Also remove unnecessary CSS on ribbons.

Part-of: odoo/odoo#116641
2023-05-12 22:59:16 +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
Loukas Wets (lowe) e3ad1eb058 [IMP] pos_restaurant: always floor plan when restaurant
Enable floor plan for all PoS Restaurant config. To accomplish this, we are
removing the following fields:
- `pos.config.is_table_management`
- `res.config.settings.pos_is_table_management`.

All access to `is_table_management` can be replaced by `module_pos_restaurant`
because originally, `is_table_management` can only be true if
`module_pos_restaurant` is true.

To adapt the tests, we should manually set `module_pos_restaurant` to `False` for
the `pos.config` used in tests outside `pos_restaurant` addon. This is because
when pos_restaurant addon is installed, it sets every new `pos.config` record to
be restaurant by default.

Task-3282975

closes odoo/odoo#120117

Related: odoo/enterprise#40532
Related: odoo/upgrade#4622
Signed-off-by: Monnom David (moda) <moda@odoo.com>
2023-05-11 12:01:35 +02:00
David Monnom (moda) 55ec4f75bc [FIX] point_of_sale,pos_restaurant: fix order btn
Before this commit, the Order button wasn't displayed due to an
incorrect comparison with a `LazyTranslatedString` object
(`this.props.actionName`). This commit resolves the issue by ensuring
proper comparison of `this.props.actionType` with the string "payment".

Step to reproduce:
- create a pos_config (bar)
- active a printer on it
- open the PoS bar
- select a table and add some product
- The orderline are green but there's not order button.

opw-3300533

closes odoo/odoo#120846

X-original-commit: a04f8ebdfb724c74531f38927a655e6aae86bc26
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-05-10 20:15:26 +02:00
Samuel Degueldre af2b9eab4c [FIX] pos_restaurant: stop crashing in mobile
In odoo/odoo#120070 the pos assets bundle were refactored to stop
including the entirety of assets_backend. In doing so, jQuery.ui is no
longer present in the bundle. pos_restaurant adds an addon for jQuery.ui
to make its widgets work on mobile, but since the original library is
not present, this causes a crash when touch events are available (ie on
touch screens).

This commit fixes that by removing the addon entirely, since none of the
pos depends on jQuery.ui anymore.

Part-of: odoo/odoo#120791
2023-05-09 11:57:23 +02:00
Loan (LSE) ad7bdc94c0 [FIX] pos_restaurant: refunded_orderline_id array type instead of int
To reproduce (16.1 and >):

 1. install pos_restaurant
 2. open the bar PoS (NOT a shop)
 3. choose a table
 4. sell a product & make the payment & new order
 5. choose a table (can be the same as before, it does not matter)
 6. refund
 7. select the previous order > refund
 (already a bug, it is not proposed it is empty. But we can force
 its selection by going again in the refund tab. Will create a
 dedicated task for this issue)
 8. go back to the main floor (to force sync the order)
 9. go back to the table with the hanging refund order
 10. try to pay it

=> server error:
```
bad query: INSERT INTO "pos_order_line" (..., "refunded_orderline_id", ...) VALUES (..., ARRAY[1,'Coca-Cola'], ...) RETURNING "id"
ERROR: invalid input syntax for type integer: "Coca-Cola"
LINE 1: ..., ARRAY[1,'Coca-Cola'],...
```

This happens due to this recent fix:
https://github.com/odoo/odoo/pull/116271
Adding this field in the `search_read` yield the product ID and the name
 (ORM default behavior on Many2one fields). As the PoS needs only the ID
  we take it from the tuple.
Note: the fix does target originally version 15, but the forward port
code was changed only on version 16.1 and > creating this issue.

After this commit:
Able to refund order without an errors

opw-3292121

closes odoo/odoo#120722

X-original-commit: a2ad09c0fb50a299afa29e01b457ff1699f6d811
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Sens Loan (lse) <lse@odoo.com>
2023-05-08 23:39:44 +02:00
Joseph Caburnay 5d951d91bb [REF] point_of_sale,*: redefine format_currency{_no_symbol} using web's formatMonetary
*: l10n_ae_pos,l10n_fr_pos_cert,l10n_gcc_pos,pos_loyalty,pos_restaurant,
   pos_sale,pos_sale_product_configurator

This commit is the start of a series of changes in the definitions of formatters
and rounders used in pos. We are introducing a new service called
`contextual_utils_service` that loads when the `pos` service is ready making
sure the currency is loaded. In this service, we define `formatCurrency`
(potentially others) which is the replacement to `format_currency{_no_symbol}`.
Also, instead of defining our own formatter, we are depending on web's
`formatMonetary`.

In this commit, we are replacing all uses of `format_currency{_no_symbol}` with
`formatCurrency` that's based on web's `formatMonetary`.

Part-of: odoo/odoo#120317
2023-05-08 15:18:30 +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
David Monnom (moda) f23edc1729 [FIX] pos_restaurant: wrong arguments for orm.call function
The first two arguments of the call() function of the orm service
have been inverted.

This is fixed.

closes odoo/odoo#120404

X-original-commit: 0a4e035083d6d3d62d0041fad62f71668dd77d7e
Signed-off-by: Samuel Degueldre <sad@odoo.com>
Signed-off-by: Monnom David (moda) <moda@odoo.com>
2023-05-03 13:57:24 +02:00
David Monnom (moda) 73aae73f1b [IMP] point_of_sale,*: move kitchen printer logic to point_of_sale
*:pos_epson_printer,pos_epson_printer_restaurant,point_of_sale,
pos_restaurant,pos_hr_restaurant

Before the printers only worked in the pos_restaurant and not in the
point_of_sale. Indeed, the methods managing the printers were located
in the pos_restaurant.

Now all these methods have been moved.
For the community part here are the affected modules:
- The methods in pos_epson_printer_restaurant have been moved to
pos_epson_printer.
- The methods in pos_restaurant have been moved to point_of_sale.
- The module pos_epson_printer_restaurant has been removed as it only
handled printers.

Some of these methods have been adapted/renamed to better suit
the needs.

This branch the first part of the following task: 3224508

closes odoo/odoo#114655

Related: odoo/upgrade#4414
Related: odoo/enterprise#37901
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-05-03 12:39:17 +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
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
Pulinckx Pierre (PIPU) 608e90e998 [REF] *: Replace underscore functions by native JS
Replace _.map(), _.flatten(), _.delay(), _.contains(), _.pluck(), _.isUndefined(), _.isEmpty(), _.isString(), _.isEqual(), _.isBoolean(), _.memoize(), _.invoke(), _.bind(), _.escape(), _.debounce(),
_.str.sprintf(), _.str.repeat(), _.str.startswith(), _.str.trim(),
_.str.escapeHTML(), _.str.escapeRegExp(), _.str.startsWith(), _.str.include()

closes odoo/odoo#118012

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-04-20 11:57:29 +02:00
roen-odoo 2eafad8bf1 [FIX] pos_restaurant : add missing t-ref
Current behavior:
When printing a bill in the restaurant you had an error poping.

Steps to reproduce:
- Open a restaurant session
- Go on a table and add some products
- Click on the bill button
- Click on the print button
- You get an error

opw-3259014

closes odoo/odoo#119041

X-original-commit: 1d1808e7136c6416fe88c28e7971e97707de2557
Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
2023-04-20 10:51:49 +02:00
Rémy Voet (ryv) 234db70d86 [IMP] *: Use the new API of _read_group for backend use
Part-of: odoo/odoo#110737
2023-04-19 21:58:27 +02:00
Archana Vaghasiya 91a6b3097b [FIX] point_of_sale: prevent creation of journals with existing id's
Error:'UniqueViolation duplicate key value violates unique constraint
account_journal_code_company_uniq.'

When we install the 'point_of_sale'  module it tries to create account journals
with existing id's due to which we face the above error.

This commit removes the portion of code that creates the account journal
with already existing id's.

sentry - 4062359900

closes odoo/odoo#118618

X-original-commit: 3c209e5c91e374dc7738df01f48e630a7fba5caf
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-04-17 09:27:53 +02:00
Pulinckx Pierre (PIPU) 614de86989 [REF] *: Replace underscore function by native JS
Replace _.isNumber(), _.filter(), _.reject(), _.unique(), _.indexOf(), _.lastIndexOf(), _.findIndex(), _.range()
_.keys(), _.values(), _.str.sprintf() and some _.each()

closes odoo/odoo#118003

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-04-13 16:40:11 +02:00
Loukas Wets (lowe) dc4cb848de [IMP] pos_restaurant: Order button: Display product summary by category
We want the order button to display the product summary by category to give more feedback to the waiter while taking an order.

closes odoo/odoo#116846

Task-id: 3229596
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-04-13 15:26:01 +02:00
vlst 05fd65e855 [ADD] pos_self_order: QR Code Menu for Restaurant
New module that would allow restaurant customers to see the menu on their own devices by scanning a qr code and navigating to the provided link.
Task id 3232765

closes odoo/odoo#114022

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-04-13 04:08:08 +02:00