[FIX] pos_self_order: prevent error with online payment method

Prior to this commit, using an online payment method with an image in
self-ordering mode resulted in an issue preventing the opening of the
mobile menu. The specific error encountered was:
`TypeError: Object of type bytes is not JSON serializable`

This issue arose due to the image field being of type bytes. Since the
image field is not necessary for self-ordering, this commit addresses
the problem by preventing the loading of the image for a payment
method, resolving the serialization error.

opw-3624798

closes odoo/odoo#151388

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
Pedram (pebr)
2024-01-27 01:29:54 +00:00
parent e40cfe8495
commit a48353d602
2 changed files with 8 additions and 4 deletions
@@ -18,8 +18,7 @@ class PosConfig(models.Model):
def _get_self_ordering_data(self):
res = super()._get_self_ordering_data()
payment_search_params = self.current_session_id._loader_params_pos_payment_method()
payment_methods = self.self_order_online_payment_method_id.read(payment_search_params['search_params']['fields'])
payment_methods = self._get_self_ordering_payment_methods_data(self.self_order_online_payment_method_id)
res['pos_payment_methods'] += payment_methods
return res
+7 -2
View File
@@ -331,10 +331,15 @@ class PosConfig(models.Model):
}
return printerData
def _get_self_ordering_payment_methods_data(self, payment_methods):
excluded_fields = ['image']
payment_search_fields = self.current_session_id._loader_params_pos_payment_method()['search_params']['fields']
filtered_fields = [field for field in payment_search_fields if field not in excluded_fields]
return payment_methods.read(filtered_fields)
def _get_self_ordering_data(self):
self.ensure_one()
payment_search_params = self.current_session_id._loader_params_pos_payment_method()
payment_methods = self._get_allowed_payment_methods().read(payment_search_params['search_params']['fields'])
payment_methods = self._get_self_ordering_payment_methods_data(self._get_allowed_payment_methods())
default_language = self.self_ordering_default_language_id.read(["code", "name", "iso_code", "flag_image_url"])
return {