Commit Graph
27 Commits
Author SHA1 Message Date
“moda” 4db538611d [IMP] point_of_sale,pos_*: automaticaly paid order when amount is 0
*: pos_online_payment_self_order,pos_restaurant,pos_self_order

Previously, when self order was set to "pay after each" and a user
ordered an order with a total of $0.00, the order was not automatically
set to paid status, as is the case with point_of_sale.

Now, when the self order is set to "pay after each" and an order with a
total of $0.00 is placed, it will be automatically paid.

Minor fixes:
- A props has been removed from `ReceiptHeader` because it was causing
an error in debug mode.
- In point_of_sale, when an order was placed with a total of $0.00, an
error was raised during validation because no payment method was
selected. Now, before checking this payment method, we first check
whether it exists.

closes odoo/odoo#139555

Related: odoo/enterprise#49442
Signed-off-by: Adrien Guilliams (adgu) <adgu@odoo.com>
2023-10-25 18:11:05 +00:00
“moda” c0df2a08b0 [ADD] pos_self_order_stripe: add stripe payment method to self order
When implementing the Stripe terminal in a device that will be used by
end-users, we need to ensure that it is the server that will validate
the data and not Javascript as is the case in Point of Sale.

Nevertheless, we're using the Javascript SDK for the connection to the
terminal, as we don't want to add a Python dependency to the Odoo server

How the SDK works:
During initialization, we create a terminal via the `create` function.
This function will receive as argument a function that generates a
unique token with a precise lifetime managed by the SDK. These tokens
must be supplied only to trusted devices, such as the kiosk, accessible
only if we have `access_token` from the `pos_config`.

Then, when making a payment, we make a request to the Odoo server to
create a Stripe payment request from the backend, connect the terminal
to the frontend via the `connectReader` function and send it the payment
request via the `collectPaymentMethod` function, passing it the
`client_secret` sent by the Odoo server.

We then use the `processPayment` function once the customer has
presented his payment card to finalize the payment on the terminal.

Finally, we call the `capturePayment` function, which contacts the Odoo
server to validate the amount and payment. If this is the case, it will
mark the order as paid and send a message via websocket to the kiosk to
display the confirmation page.

During these various stages, trust is placed in the server and not in
the frontend.

Stripe Javascript SDK documentation:
https://stripe.com/docs/terminal/references/api/js-sdk

closes odoo/odoo#138646

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-10-23 20:07:21 +00:00
vlst d149b8add6 [IMP] pos_self_order*: enable kiosk receipt
*point_of_sale, pos_self_order, pos_self_order_epson_printer

In this commit we introduce the functionality that allows
the pos_self_order module to generate receipts.

At the moment, this is possible by using Epson Printers via HTTP.
This is done through the use of the newly added bridge module
`pos_self_order_epson_printer`.

In order to generate the data required for the receipt we add more data
on the first load of the kiosk ( such as company information ) and
also in the `_export_for_self_order` method.

Printing is done through the `printer` service from POS.

closes odoo/odoo#137397

Task: 3487638
Related: odoo/enterprise#48304
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-10-18 15:26:31 +00:00
Adrien Guilliams (adgu) adc58cdafe [IMP] pos_self_order: send kiosk order to preparation display
This commit consist of adaptation of the pos_self_order module to send
orders to preparation display. The main changes consist of sending the
table stand number that the client put in to the backend to be shown
in the preparation display. It also consist of moving the tracking
number from the pos_self_order module to the point_of_sale module so
that every number has a tracking number.

closes odoo/odoo#134980

Task-id: 3495477
Related: odoo/enterprise#47203
Signed-off-by: David Monnom (moda) <moda@odoo.com>
2023-10-12 16:11:56 +00:00
Joseph Caburnay 1569d59c9d [FIX] pos_self_order: correct fiscal position in self order
**Steps to reproduce:**

- Create a fiscal position that maps to a different tax.
- Use that fiscal position as alternative fiscal position for the "Eat in / Take
  away" setting.
- Create a "Take Away" order from the self-ordering app (kiosk or mobile).
- ISSUE: Send the order to the database (by "Pay at Cashier" or "Pay").
  - Check the order and it doesn't have correct fiscal position resulting to
    wrong amounts in the lines.

**FIX:** When creating the order, we make sure the correct fiscal position is
set. Also, we precompute `is_take_away` variable which is used in many places of
processing the order.

closes odoo/odoo#137669

Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com>
2023-10-09 13:25:36 +00:00
David Monnom (moda) dcae390faf [IMP] point_of_sale, pos_self_order: save custom product attribute
Previously, the custom value of an attribute was not saved in the
database when selected via the point of sale or Self Order. The only way
to see this value was via the product name.

Now, this custom value is saved via the `product.attribute.custom.value`
template, in order to follow the behavior of the Sale module.

Others fix in this PR:
- Prevent to pass to payment page when we are in mobile mode. Only kiosk
mode is allowed to do so.
- Hide "Modify" button in the cart page when the line is already sent to
the server.
- Make the language popup behaviour available in mobile mode too.

closes odoo/odoo#136612

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-10-02 14:12:49 +00:00
David Monnom (moda) 391ac741c2 [IMP] pos_self_order: merging mobile and kiosk
Previously, the self-order code and parameters were split into two parts
mobile and kiosk.

Now kiosk and mobile have been merged with each other to simplify
maintainability.

closes odoo/odoo#136051

Related: odoo/upgrade#5174
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-09-25 13:09:08 +00:00
David Monnom (moda) 4f5dd90aa7 [IMP] pos_self_order: default user for self_order mobile
Following the Odo comment https://github.com/odoo/odoo/pull/129562#discussion_r1306030434

We need to ensure that we have a default user for the mobile SelfOrder
when no session is open.

If we don't have a user, the system will be in sudo mode and the price
calculation will be erroneous because the system has chosen the wrong
taxes: it doesn't know which company to use to calculate the taxes.

We now force the setting of a default user for pos_config with mobile
selfOrder enabled, so that when no session is open, the default user
will be used.

closes odoo/odoo#134273

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-09-18 16:48:02 +00:00
Loukas Wets (lowe) 27d51c1f10 [FIX] pos_self_order: acces without access token restriction
Following this PR https://github.com/odoo/odoo/pull/131140 when the self
order is accessed without access token the access restrictions are not
applied anymore. This commit aims to restore the previous behaviour
implemented in the following PR https://github.com/odoo/odoo/pull/122901/.

This commit also add a test to verify the flow of accessing the self order
without an access token. While doing so a the tour util cannotAddProduct
was fixed since it did not behave as inteded.

closes odoo/odoo#133595

X-original-commit: ae1dbc1d34fd622959540ec84bcefe795e15552b
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Loukas Wets (lowe) <lowe@odoo.com>
2023-09-13 08:20:33 +00:00
Adrien Guilliams (adgu) e19cc8eac8 [FIX] pos_self_order: fix combo price when changing combo quantity
When changing the quantity of a combo, the price was not correctly
updated due to a miscomputation in the backend.

closes odoo/odoo#134622

Signed-off-by: David Monnom (moda) <moda@odoo.com>
2023-09-12 17:16:19 +00:00
vlst 0ffd04e7de [IMP] point_of_sale,pos_self_order: handling product attributes
When selecting an attribute value in POS, what we store is the `description`,
which is a string that represents the selected attribute values.
Ex: selecting `Size: M` and `Material: Leather` will result in the description:
`(L, Leather)`.

This choice does not lead to a logical API for dealing with product attibutes.

In this pr, we add a new field that stores the selected `ids` of
`"product.template.attribute.value"` and remove the
`selected_attributes` `Json` field from the `pos_self_order`
override of the `pos.order.line` model.

The `attributeHelper` function from the `tour_utils.js` file
from `pos_self_order` is improved such that it can now handle
both checking if a certain attribute is selected and actually
selecting an attribute.

closes odoo/odoo#126398

Task: 3378533
Related: odoo/upgrade#4992
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-09-11 22:41:01 +00:00
David Monnom (moda) 4a12c68184 [IMP] point_of_sale, pos_*: overall improvements and fixes
List of improvements:
- Add `Is a Kiosk` field when creating a new POS config
- Add category and change the image of the combo demo product
- Hide useless settings when kiosk mode is enabled

List of fixes:
- Fix bootstrap carousel traceback when no image is set
- Changed the warning sentence concerning adyen payments
- Fix start category in kiosk
- Fix sync between Self Order mobile and PoS restaurant, now new Lines
  from restaurant are added to the mobile order
- Fix product reminder when adding something in PoS mobile

closes odoo/odoo#134508

Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com>
2023-09-08 07:17:52 +00:00
Jitendra Prajapat 4c8fddd570 [FIX] point_of_sale: modified flow of order date
Before this commit:
===================
In the back-end, there is only one field "date_order" is used, while on the
frontend side, there are two separate fields: "creation_date" and
"validation_date," which causes confusion in the code flow and leads to
redundancies.

After this commit:
==================
Revised the order date flow by eliminating the confusion stemming from the
separate "creation_date" and "validation_date" fields. Both have been
consolidated into the "date_order" field, offering clarity to the order date
process.

task - 3482072

closes odoo/odoo#133293

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-09-06 13:25:27 +00:00
vlst f5307d810d [IMP] pos_self_order: introduce combos
Using the POS app, one can buy a combo consisting of multiple products.

In this PR we implement this functionality in the `pos_self_order`.
A user can now navigate to a combo product, select each combo choice
and order the desired combo directly from the `pos_self_order` app.

In this commit we also change the values displayed in the orderlines
of the `pos_self_order`, such that they better reflect the values
that would be shown by the POS for the same respective orderlines.

Ex: when buying 5 units of an item that has unit price 138.58, the
POS ( and also the invoicing app, etc ) would display a total price
of 692.88. The self order now does the same, but before it was showing
692.90 for the same situation.

closes odoo/odoo#134169

Task: 3437447
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-09-06 11:50:54 +00:00
vlstandJoseph Caburnay 00dcc575b8 [IMP] point_of_sale,*: integrate combos in pos ui
*: pos_discount,pos_loyalty,pos_restaurant,pos_self_order

In a previous commit (669b9fcc2f) we added the
backend logic needed for creating combos in `pos`.

In this PR we add the combo functionality to the classic pos ui.

This means that products can now be grouped together and sold as a combo.

ex: Create a product called `Burger Menu` with type='combo'.This product will
have multiple combos associated with it, for ex:

- Drinks - will contain the list of drinks from which the customer can choose
- Main Course - will contain the list of main courses from which the customer
  can choose
- Dessert - will contain the list of desserts from which the customer can choose

In the event that one of the products inside one of the combos is to be more
expensive, this product will have a specific `combo_price` which will be added
to the main combo product's price.

We add the relational fields `combo_parent_id` and `combo_line_ids` in the
`pos.order.line` model. In the previous example, `combo_parent_id` will contain
the `id` of the `orderline` of the `Burger Menu` product.

In many cases `combo lines` have to be handled together. For example, deletion
of an orderline containing a product from a combo implies the deletion of all
other orderlines containing products from that combo. This means that multiple
methods from the codebase had to be changed for this reason. Places that needed
changes for this reason:

- `split_bill_screen.js`
- `addProductToCurrentOrder()`
- `remove_orderline()` and `add_orderline()` from the `Order` js model

In this PR we also:

- improve the demo data such that it contains a `pos combo`;
- refactor the `ProductItem` component such that it relies on a stateless
  component. This stateless component can now be used anywhere; ( it is now used
  in the popup which allows selecting the desired combo products )
- add a new method called `is_pos_groupable` on the `Orderline` js model. Before
  we relied on the product unit to see whether or not a product is groupable. We
  now needed a new mechanism, which could account for different reasons for
  which products are not groupable, such as belonging in a combo;

Note on price calculation:

- The idea is simple, imagine a rectangle divided into two parts. The whole
  rectangle is the total order, whereas the two partitions are the orderlines.
  - Now, imagine shrinking the rectangle by a certain factor. This shrinked
    rectangle represents an order containing a combo -- because normally, a
    combo results to smaller price. The two partitions are also shrinked by the
    same factor.
  - So the calculation will be:
    - Nominal total price is calculated. This is the sum of the orderlines'
      prices when they are added individually. This represents the whole
      rectangle.
    - Target price is derived from the combo product's price and selected
      components' combo prices. This represents the shrinked rectangle.
    - Reduction factor is computed as the ratio between the target price and the
      nominal price.
    - Each component's unit price is adjusted by multiplying the reduction
      factor.
    - When the unit prices of the components are computed, we now let the normal
      price computation take place.
- A spreadsheet is prepared to show a sample calculation:
  https://docs.google.com/spreadsheets/d/1iOdnaILnvKiaf2_z7jTijYiVfB_3mjKWjq6nOB70Un0/edit#gid=0

closes odoo/odoo#129483

Task: 3430636
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Co-authored-by: Joseph Caburnay <jcb@odoo.com>
2023-09-04 08:03:34 +00:00
David Monnom (moda) e512634935 [IMP] pos_self_order: order number and tracking_number
To begin with, there are two different fields.
- tracking_number: used with the kiosk or self so that the customer can
track his order.
- name (order_reference): classic order number, used to find them in the
odoo backend.

Example of tracking number:
- A1
- B1

Example of order_reference:
- Classic PoS: Order 00001-001-0001
- SelfOrder Mobile: Self-Order 00001-001-0001
- Kiosk: Kiosk 00001-001-0001

Two ir.sequences are used to generate these numbers. The first to
generate order_reference numbers per session, and the second to generate
tracking_numbers, which are common to all pos_configs and reset once
a day.

closes odoo/odoo#133902

Signed-off-by: Adrien Guilliams (adgu) <adgu@odoo.com>
2023-09-01 15:09:53 +00:00
David Monnom (moda) 605943b5ea [ADD] point_of_sale,pos_*: add kiosk mode
*:point_of_sale,pos_adyen,pos_online_payment_self_order,pos_restaurant,
pos_sale,pos_self_order,pos_self_order_adyen,pos_self_order_restaurant,
pos_self_order_sale

This PR adds the kiosk to the existing `pos_self_order` module, which
until now has enabled end-users to order their restaurant meals directly
from their smartphones.

We've added the possibility of creating kiosks / totems (devices with
large touch screens) that allow users to order their menu directly
without having to go through a waiter.
Once the order has been placed, the user will be invited to pay either
by adyen, already integrated into this PR, or at the counter.

At the end of the order, the user will receive an order number and his
table number if `service at table` is activated.

Main differences with the Self-order mobile:
- Kiosk shouldn't be accessible publicly
- Kiosk should support payments via card readers

closes odoo/odoo#129562

Design: XLU
Dev: ADGU & MODA
Taskid: 3323163
Related: odoo/upgrade#5024
Signed-off-by: Adrien Guilliams (adgu) <adgu@odoo.com>
2023-08-31 04:13:04 +00:00
Joseph Caburnay e628b6507f [FIX] pos_{online_payment_}self_order: price based on company taxes
**Steps to reproduce:**

- Install pos_self_order.
- Create a product with a price of any price, say 100.
- Assign a tax of 10% to the product.
- Create a new company and switch to it.
- With the same product, add a new tax, say 20%.
- Go back to the original company.
- Open a bar (restaurant pos.config) that allows self order which also loads the
  product.
- Open self order page and add the product.
- [BUG] The product's price is not only 10%-taxed, but also 20%-taxed.

**Explanation and fix**

The issue is caused by use of sudo almost everywhere in the context of
pos_self_order. This commit removes/reduces this use of sudo in many places and
contextualize the records involved in the calculation such as pos.config,
product.product, etc. to be the ones of the company and the user who opened the
current pos.session.

After this changes, only the taxes that belong to the company of the pos.config
record are used in the price and tax calculations.

closes odoo/odoo#131140

X-original-commit: 7ce7f3e21ad8f457742e27f88b7146c7d8fff5f3
Signed-off-by: David Monnom (moda) <moda@odoo.com>
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-08-08 08:56:25 +02:00
Theo VINCENT (thvi) b81a049a4e [ADD] pos_online_payment_self_order, *: add module
*: pos_self_order

Adds online payment support for self-order flow in the Point of Sale app.

 - Adds a configurable online payment method specific to the self-order flow, which is optional in "Pay after meal" mode, required in "Pay after each" mode.
The POS config of a restaurant can use 2 different online payment methods, one for the frontend cashier flow, and another for the self-order flow, or can use the same for both.
By default, if an online payment method is configured for the self-order flow, any new order paid online will be paid with that payment method.
But if the cashier requests an online payment with a different online payment method, that payment method will be used for that order during the time the cashier keeps his online payment popup open (without cancelling the online payment) (after cancelling the online payment, the order could potentially still be paid online, and if so it will use the online payment method of the self-order if one is configured, otherwise the online payment method of the cashier flow).
 - Allows the customer to open the online payment page of an order from the self-order UI.
In "Pay after meal" mode, if an online payment method is configured, the "Pay" button is displayed when the customer order is saved on the server, otherwise the "Order" button is displayed (even when the order has been sent to the server and then modified without sending it again).
Otherwise, if no online payment method is configured, the "Pay at cashier" unclickable button is displayed.
In "Pay after each" mode, the "Pay" button is displayed everytime.
 - Replaces the self_order_after_each_cart_tour test.

closes odoo/odoo#127869

Task-id: 3171698
Related: odoo/enterprise#44055
Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com>
2023-07-20 14:22:57 +02:00
David Monnom (moda) b0668f106e [FIX] pos_self_order: some bugs fixes
- Corrected incorrect use of access_token in an order.
- Correction of order change calculation in self_order.

closes odoo/odoo#125941

Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com>
2023-07-13 19:28:01 +02:00
David Monnom (moda) 0a6cac7002 [IMP] pos_self_order: ux improvements
- Remove the notification and add a persistent banner at the top of the
screen when the restaurant is closed.
- Change the size of the product card to make it more compact and
smaller.
- Added a little shadow to the element fixed at the top and bottom.
- Corrected the alignment of price and quantity in the product list.
- In the card, the calculated price is now below the product list.
- The "add to cart" button is now dynamic, and will be
"remove from cart" if if the requested quantity is 0.
- Make the "my orders" button visible in meal mode and in each mode.

Part-of: odoo/odoo#125941
2023-07-13 19:28:01 +02:00
David Monnom (moda) 0ae2b9a3f2 [IMP] pos_self_order: change authorisation token
Previously, access_token were linked to tables. These tables were linked
to a floor_plan, which could be linked to several pos_configs.

The only way to access the self-order was to obtain a valid table
access_token. This behaviour was not correct because sometimes we would
allow table selection directly in the interface or commands without
a table.

Now, access_token is managed by pos_config. When a user has this token,
they can place commands and select the table they want if the option is
enabled.

closes odoo/odoo#126186

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-07-03 21:56:04 +02:00
David Monnom (moda) 2222b6911e [IMP] pos_self_order: add bus notification for self order
Previously, when an order was paid for at the restaurant counter,
the self-orderer received no update that the order had
been paid for.

Now, if the customer self-order page is still open on their phone,
it will receive a notification via websocket that the order has been
paid for from the restaurant counter.The order will no longer be
editable.

In the event that they have already closed the self-order when paying
at the counter, the next time they return to this page. An RPC request
will be made with the access_token of the old order and the
states will be aligned.

closes odoo/odoo#125921

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-06-27 16:26:53 +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 e82f75d66f [IMP] point_of_sale, *: Unify price type field
*: l10n_fr_pos_cert, pos_discount, pos_loyalty, pos_sale, pos_self_order

The `Orderline` model contains the fields: `price_manually_set` and `price_automatically_set`.
They are meant to signify what type of price the orderline has: `automatic`, `manual` or `original`.

It's very confusing to manage the two fields when in fact they only describe three types of setting the orderline price.

This PR replaces the 2 fields with a single one: `price_type`, which will take one of the 3 possible values.

closes odoo/odoo#124858

Task: 3358265
Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
2023-06-14 10:53:57 +02:00
vlst 13e37bda7c [IMP] pos_self_order: Allow ordering from web app
Currently from the pos_self_order app a customer can only view the menu.
This PR adds the option to order items.
A customer of the restaurant will now be able to scan a qr code on their table, and navigate to a website where they will be able to order items from the pos.
The customer can select product variants and add a specific notes for each of the ordered products.

This version does not support online payment. This means that the customer will still have to pay by the usual methods.

The pos can be configured such that a customer can add items to an existing order. For example, ordering a second coffee will result in an update of the existing pos order containing the first coffee. Alternatively, the pos can be configured such that each order made from the web app results in a new pos order. Orders made from the self order app will be placed in the same pos session as regular orders. Once a customer orders from the self order app, a new order will appear in the pos app. Thus, a waiter will be able to quickly see all the orders placed by customers from the self order app. He/She will then be able to send the order to the preparation display. This step has to be done manually.

In the interest of security, each table now has an associated access token. It is included in url that the customer gets from the qr code. When sending the order, the self order app also sends back to the server this access token. The server will only process the order if it receives a valid access token. When placing an order, the server will respond with the pos_reference and access_token of the created order. The web app will keep this data and will send it back to the
 server as a proof of ownership in the event that it intends to get the latest state of the order or to update it. The server will only reveal information about an existing order when the request contains a valid pair of pos_reference and access_token.

closes odoo/odoo#121029

Task: 3058586
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-05-19 13:33:08 +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