Skip to content

Commit

Permalink
[FIX] point_of_sale: load product requests
Browse files Browse the repository at this point in the history
When the pos was loading only a part of the products, the request should follow those rules order:
- product is a favorite
- product is a service
- product had stock moves soon
- product update

But this request didn't take into account consumables products and if there was no stock move,
the value was null and postgres consider null values first when ordering desc.
Now with that changes, the order is correctly set based on the rules above.

closes odoo#124223

Signed-off-by: Monnom David (moda) <moda@odoo.com>
  • Loading branch information
rhe-odoo committed Jun 8, 2023
1 parent e406b08 commit 102791f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions addons/point_of_sale/models/pos_config.py
Expand Up @@ -613,8 +613,9 @@ def get_limited_products_loading(self, fields):
WITH pm AS (
SELECT product_id,
Max(write_date) date
FROM stock_quant
FROM stock_move_line
GROUP BY product_id
ORDER BY date DESC
)
SELECT p.id
FROM product_product p
Expand All @@ -626,10 +627,11 @@ def get_limited_products_loading(self, fields):
AND (t.company_id=%(company_id)s OR t.company_id IS NULL)
AND %(available_categ_ids)s IS NULL OR t.pos_categ_id=ANY(%(available_categ_ids)s)
) OR p.id=%(tip_product_id)s
ORDER BY t.priority DESC,
t.detailed_type DESC,
COALESCE(pm.date,p.write_date) DESC
LIMIT %(limit)s
ORDER BY t.priority DESC,
case when t.detailed_type = 'service' then 1 else 0 end DESC,
pm.date DESC NULLS LAST,
p.write_date
LIMIT %(limit)s
"""
params = {
'company_id': self.company_id.id,
Expand Down

0 comments on commit 102791f

Please sign in to comment.