Commit Graph
141 Commits
Author SHA1 Message Date
pedrambiria 4f19f2040a [FIX] pos_loyalty: correctly compute discount with existing discount
Before this commit, if you have a discount promotion on the order,
adding a free product reward would change the discount incorrectly.

The problem is that in the `_getDiscountableOnSpecific` function the
non-discount rewards weren't excluded from `discountLinesPerReward`.

opw-3276337

closes odoo/odoo#127003

X-original-commit: 914dad0d23df4c3f8a117252a8159c07df9ee8ad
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
2023-07-03 19:57:49 +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
Adrien Guilliams (adgu) 16c4debe1e [ADD] pos: adapt PoS to add l10n_cl_edi_pos
In order to add the l10n_cl_edi_pos module we had to adapt some
things in the PoS module. This task changed the error handling of errors
sent to the server from the payment_screen. This led to some changes in
payment_screen.js and partner_editor.xml. It also add the mechanism
of not allowing an single order to combine refund and normal sale
in some localization if needed (needed for Chili).

closes odoo/odoo#121151

Related: odoo/enterprise#40940
Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com>
2023-06-26 20:00:48 +02:00
roen-odoo 075da19e4e [FIX] pos_loyalty: specific discountable take discount into account
Current behavior:
When computing the discountable values of an order, the discount of the
program where not taken into account if you used specific discountable
products.

Steps to reproduce:
- Create products A and B with a price of 20$
- Create a loyalty program
- Rule:
  - Minimum qty : 2
  - Apply on specific products : Product A and Product B
  - Reward : 5 points per order
- Reward:
  - 10$ per order
  - In exchange of 2 points
  - Apply on specific products : Product A and Product B
- Open PoS and add Product A and Product B to the order
- A reward should be added automatically with a value of -10$
- Click on the reward button, another reward should be added but it has
  the wrong value. It should be -10$ but it is not.

opw-3232565

closes odoo/odoo#126245

X-original-commit: f33d3b09ff49aae1fdaf3379915b7e7b5f03080c
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Robin Engels (roen) <roen@odoo.com>
2023-06-23 18:00:13 +02:00
pedrambiria 0e066e2006 [FIX] pos_loyalty: prevent unwanted free product points correction
Before this commit, purchasing a gift card along with applying a free
product promotion in the same order resulted in the gift card balance
being decreased by the free product price.

Steps to reproduce:
1. Create a buy x get y promo program.
2. Open the POS and use this program and sell a gift card in the same transaction.
3. Activate the promo program and complete the transaction.
The promo program discount will take money of the gift card amount.

Also there is another issue with Loyalty Cards points:
When the reward's product in not valid of the rule, it will decrease
the point when you add the reward.

opw-3284636

closes odoo/odoo#126014

X-original-commit: 975ffef9d1fa7a41b223859e5355e05bdba1d11c
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
2023-06-22 17:10:53 +02:00
vlst 5aaee3af66 [IMP] point_of_sale: Allow contact deletion
Currently, deleting contacts (partners) while a pos session is
open is not allowed.
(Even if the respective partner isn't part of any POS sessions)

This creates a bad experience in Contacts, with too many
unnecessary User Errors.

This PR fixes this issue, by allowing the deletion of contacts
even when a pos session is open, by introducing logic that
handles the cases where a contact might be deleted during an i
active pos session.

closes odoo/odoo#124152

Task: 3349851
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-06-20 19:09:08 +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
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
Valeriya(vchu) bce4aededc [IMP] (pos_,sale_)loyalty: improve validity period
currently it is only possible to define the end_date that
does not allow to prepare the program in advance.
Added the start_date property to the program model.
task-3305712

closes odoo/odoo#121193

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-06-12 17:40:58 +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
vlst 9eb008dd77 [IMP] point_of_sale: Improve the flow of emailing gift cards
The process of emailing _gift cards_ bought from the Point of Sale is rather confusing.
This PR makes the experience more intuitive.

closes odoo/odoo#123222

Task: 2711714
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-06-08 13:10:09 +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
pedrambiria 09b2dab543 [FIX] pos_loyalty: zero division when reward product has zero price
The issue occurred when a loyalty program's rule was set to be
based on money spent, and the reward was a free product with a
sale price of zero. This caused a zero division error in the code,
resulting in the remaining points becoming NaN after the reward
was obtained in the point of sale.

opw-3253366

closes odoo/odoo#123123

X-original-commit: 1eaca074741157e42c12da22e945a1817e7ceec3
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
2023-06-01 11:43:57 +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
Loukas Wets (lowe) 7cbe85756f [FIX] pos_loyalty: fix call of formatCurrency method
This fix is a followup to the changes made in 5d951d9
where `format_currency` is replaced with `formatCurrency` which is based
on a more standard way offormatting monetary values.

closes odoo/odoo#122420

X-original-commit: b56a5d1
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
2023-05-31 17:26:08 +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
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
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
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) a19cdd6e27 [IMP] point_of_sale,{pos_}loyalty: ux misc improvements
- The calculator logo of the cash opening popup has been changed to a
bill logo to be more explicite for the end user.
- The cash input is autofocused at the opening of the cash opening
popup. Select number input on focus and align numbers right money
details popup.
- Rearrange Close pos popup layout.
- Set the Gift Card amount to the price of the refound if there is one.
- Change pos_payement_method_view form id order to sequence. Set the
order of payement methods in PayementScreen to sequence.
- Fix markut issue in the chatter.

Task-3215901

closes odoo/odoo#118288

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-05-11 18:25:00 +02:00
Loukas Wets (lowe) aa5ba2a101 [FIX] pos_loyalty: stop crashing when downloading coupon
In odoo/odoo#120070 We refactor the pos to stop using the
action service, but one call in override pos_loyalty was
missed. This commits adapts that call to prenvent a crash.

Part-of: odoo/odoo#118288
2023-05-11 18:25:00 +02:00
Samuel Degueldre 1f90799ff9 [IMP] point_of_sale, pos_loyalty: make pos tours run on mobile
The previous commit highlighted the fact that the pos is not really
tested on mobile. This commit creates a new class that extends the
TestUi class from point_of_sale, which runs most of the pos tours, and
runs all the same tours on mobile.

In order for these tours to run to completion correctly, a bunch of tour
utils have been adapted to add mobile-only steps or fork a step into two
mutually exclusive steps that run only on desktop or only on mobile. A
tour in pos_loyalty has been adapted to the change in the pricelist
selection utility function.

closes odoo/odoo#120791

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-05-09 11:57:23 +02:00
roen-odoo 6b014dd0d6 [REV] pos_loyalty: revert gift card specifid point computation
The correct behavior for the gift cards should be that the value of the
gift card is equal to the value of the order line.
For example :
-50$ giftcard -> Apply discount 50% on the order line -> 25$ gift card

If we want to apply a discount on a gift card we need to use the global
discount

The commit we are reverting was forcing the value of the gift card to be
the base value of the order line.

This reverts commit 83ceeecde76a859749d0659d6c387d95155c8425.

OPW-3264945

closes odoo/odoo#120794

X-original-commit: 023e2f2571ab7c814ed3cad45871fc221562fb67
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
2023-05-09 06:07:44 +02:00
Joseph Caburnay 0589e3e734 [REF] point_of_sale,pos_loyalty: replace format_pr with formatFloat
Part-of: odoo/odoo#120317
2023-05-08 15:18:31 +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) bec5c746b4 [FIX] loyalty,pos_*: reward program loading issue
Previously, when a reward was applied on a product, the product was
checked against the reward_product_ids field, which is a computed m2m
field that contains all the IDS of the products on which this reward is
available. In many cases, rewards are available on all products, causing
the computation of the m2m to fill it with the ids of all products.
This caused performance issues on all DBs with lots of products (~200k)
in all flows involving rewards.

We can't remove reward_product_ids from the data loaded in the frontend
in stable because existing JS customisations might crash if they depend
on its presence. As such, to keep compatibility with existing databases,
an ir.config_parameter has been introduced to opt into the new
behaviour. This parameter is set when creating a database so that new
databases don't suffer from this performance penalty.
For existing databases, the parameter can be set by hand if the old
behaviour is not necessary and the performance penalty is an issue in
practice, but is unset by default.

When opting into the new behaviour, the reward_product_ids field now
always evaluates to an empty recordset, and the desired behaviour should
be achieved by evaluating records against the reward_product_domain
instead. In the point_of_sale, the products available on rewards are
calculated by evaluating each product against the reward when it is
loaded. In the loyalty modules, instead of using the in operator on the
reward_product_ids field, we instead evaluate the reward product domain
against the product, which is much faster. This is always done even when
not opting into the new behaviour as the change in implementation cannot
be observed outside of timing.

closes odoo/odoo#120074

X-original-commit: 6f72d053a31aca520cbfbba2d1257568b7f7c0cb
Related: odoo/enterprise#40503
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-04-28 14:44:07 +02:00
Loukas Wets (lowe) cd65f8bdb2 [IMP] point_of_sale,pos_loyalty: gift card info notification empty cart
When a valid gift card is added in a empty cart, the pos will display a
notification of the resume of the gift card.

We also made the notification component to preserve white space.

Task-3265311

closes odoo/odoo#118609

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-04-27 10:13:00 +02:00
Adrien Guilliams (adgu) 72e9034f9f [IMP] pos, l10n_fr_pos_cert: change price_manually_set behaviour
The price_manually_set variable was used to largely, we fix it
by adding a price_automatically_set variable. The price_manually_set
is now used when changing the price through the numpad, whereas
price_manually_set is used to indicate that the price is not
the price set in the database.

closes odoo/odoo#119362

X-original-commit: aa4f346d27aa28c23f8ee02fe73b892a1f5ef2dc
Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
2023-04-27 02:44:40 +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
rhe-odoo a40039632c [FIX] pos_Loyalty: remove loyalty program info
The loyalty details on the orders were not useful for the end user.
Now we delete it from the order widget. It also fits the sale behavior where we don't show those informaitons.

closes odoo/odoo#118789

Task-id: 2980232
X-original-commit: bafcda0e8c851fb66b0f6c6cb890cf0bdaad596d
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2023-04-21 09:48:41 +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
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
pedrambiria 5632ad99e3 [FIX] pos_loyalty: use float_compare to compare points
After this commit, we will be using float_compare function to compare
points. This will ensure that any floating point errors are properly
handled and that we receive correct responses from the
`validate_coupon_programs` function.

opw-3264681

closes odoo/odoo#118829

X-original-commit: 48013733a6e8b655cbc81211b1010e76102b9c2a
Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
2023-04-18 09:24:39 +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
Samuel Degueldre 8d35700aaf [REF] point_of_sale, pos_restaurant, *: stop using legacy environment
*: web

This commit removes the use of the legacy environment from the PoS, as
it is no longer needed. This will allow us to more easily use the new
unit testing infrastructure from web.

Part-of: odoo/odoo#117290
2023-04-06 16:12:02 +02:00
pedrambiria 24b068645a [FIX] pos_loyalty: not showing error without orderline
Steps to reproduce the error:
 1. Open a Pos
 2. Without any orderline, click on `+-` button
 3. You will see an error

issue https://github.com/odoo/odoo/issues/115642

closes odoo/odoo#117620

X-original-commit: a588bb7fbe9ad6accaa12ebf1ce59767284c4f12
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
2023-04-04 16:02:06 +02:00
Joseph Caburnay 2cf46f6265 [FIX] pos_loyalty: random tour error when selecting reward
In the current tour steps, there's ambiguity in the failing step and its
preceding steps. Basically, the failing step asks to click a selection item
that contains "Monitor Stand" and the previous step also do the same: clicking a
selection item with "Free Product - [Desk Pad, Monitor Stand]". And if you
notice, both step has text "Monitor Stand". Given the nature of the tour runner,
it will try as fast as it could to do the steps, so it will click "Free Product
- [Desk Pad, Monitor Stand]" then it will immediately be followed by clicking
"Monitor Stand" which is the same element clicked by the previous step. In
essence, the two steps only resulted in one action.

As a solution, we make sure to distinguish the first step of selecting
the reward program, followed by selecting the reward product.

We use the fact that a second span under `.selection-item` will be rendered
when displaying the program selection, therefore, we introduce an
extra_trigger in first step (provided by `claimReward` helper function).

Then, we add more steps that checks the selection items on the expected
2nd selection popup.

closes odoo/odoo#116819

Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2023-03-28 18:45:50 +02:00
roen-odoo 32f7be02c0 [FIX] pos_loyalty: correct value for gift card with discount
Current behavior:
When you sell a gift card in the PoS with a discount, the value of the
gift card is not correct. For example, if you sell a gift card of 100€
with a 50% discount the customer should pay 50€ and the gift card should
be worth 100€. But the customer pays 50€ and the gift card is worth 50€.

Steps to reproduce:
- Create a gift card program
- Open a PoS session
- Sell a gift card of 100€ with a 50% discount
- Pay the order
- The value of the giftcard should be 100€ but it is 50€

opw-3221553

closes odoo/odoo#116746

X-original-commit: 1631ab332a6c9c7ca5e1f2451a51fb663534cb8e
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
2023-03-28 13:43:46 +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
David Monnom (moda) a9608cdf1e [IMP] pos_restaurant: swap payment and order button
Previously, the payment button was larger than the others and next to
the numpad. The other buttons were managed by a mixin and arranged
in a predefined order.

Now, the payment button only stays in place when the "order" button is
not present, currently it can only be present if the restaurant module
is installed and a printer configured.

When it is present, it takes the place of the payment button and the
latter is added to the mixins with the other buttons

closes odoo/odoo#115988

X-original-commit: f32c07f28e2fd2830f568757d4700fa77b83ced7
Related: odoo/enterprise#38476
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2023-03-21 18:56:15 +01:00
Lucas Vermeulen (luve) b17acfc8ab [IMP] loyalty,*: loyalty cards statbutton on partners
Add a stat button on customers views to easily retrieve all
the linked loyalty cards.

task-3050152

closes odoo/odoo#107375

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-03-20 18:13:04 +01:00
David Monnom (moda) f8482b716d [IMP] pos_loyalty: display program name on reward selector
Before this PR, the name of the program from which an award comes
was not displayed in the selection popup.

closes odoo/odoo#112122

Taskid: 3069449
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2023-03-20 11:20:35 +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
Samuel Degueldre 54058db0ab [REF] point_of_sale, pos*: replace use of legacy rpc with orm service
*: l10n_co_pos, l10n_fr_pos_cert, point_of_sale, pos_loyalty,
pos_mercury, pos_restaurant, pos_sale, pos_sale_product_configurator

This is a step in the direction of making the pos no longer depend on
the legacy environment.

closes odoo/odoo#114668

Related: odoo/enterprise#37906
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2023-03-10 11:23:51 +01:00
rhe-odoo f100e021ce [FIX] pos_Loyalty: fix product loading
Before this commit, when loading the pos with pos_loyalty, even if limited product was activated, all the products were loaded to make sure that we could apply rewards.
Now, we don't load all the products but we only load the rewards by default.

closes odoo/odoo#114021

X-original-commit: 60e7cdee62cf6b19ce0b26f2c7cbe708f74a806e
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2023-03-07 18:02:45 +01:00
Aurelien van Delft (avd) a3e2431073 [FIX] pos_loyalty: speedup Customer View loading in pos session
Currently, when there is a huge number of loyalty cards (>4000) for
the LoyaltyProgram for instance, loading the Customer View in a
pos session can take a few seconds. This is mostly due
to the getLoyaltyCards function in JS.

This commit adds a small cache in the form of a partner_id ->
coupon_ids mapping. This cache is a kind of like a view
on the couponCache and it allows to retrieve the PosLoyaltyCard
instances from the couponCache much faster.

opw-3145342

closes odoo/odoo#113805

X-original-commit: 2e88d9fef8e713ccc4227cd14b0fa85420d983e3
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
Signed-off-by: Van Delft Aurélien (avd) <avd@odoo.com>
2023-02-28 18:08:18 +01:00