[FIX] pos_loyalty: load reward products

Before this commit, if the config setting
limited_products_loading was activated,
some reward products might not get loaded
in the frontend. So the UI crashed whenever a
reward product was accessed.

In this commit we force-load all the reward products
at the start of session, regardless of the number of
loaded products (loading_products_amount)

Part-of: odoo/odoo#84719
This commit is contained in:
Eleftherios Kritsotakis
2022-06-03 16:39:50 +02:00
committed by Joseph Caburnay
parent 891bd99299
commit 602acc4801
+9
View File
@@ -97,3 +97,12 @@ class PosSession(models.Model):
(rewards.all_discount_product_ids | rewards.reward_product_ids)
result['search_params']['domain'] = OR([result['search_params']['domain'], [('id', 'in', products.ids)]])
return result
def _get_pos_ui_product_product(self, params):
result = super()._get_pos_ui_product_product(params)
rewards = self.config_id.all_program_ids.reward_ids
products = rewards.discount_line_product_id | rewards.reward_product_ids
products = self.env['product.product'].search_read([('id', 'in', products.ids)], fields=params['search_params']['fields'])
self._process_pos_ui_product_product(products)
result.extend(products)
return result