[FIX] pos_loyalty: fix data format of reward_id in the pos_restaurant

Previously, reward_id was an array of two elements containing
the ID and name of the reward. But in the frontend,
reward_id is supposed to be an int with the ID

Adaptation of the _prepare_order_line function in the following modules:
- point_of_sale
- pos_restaurant
- pos_loyalty

Now the data is correctly sent to the frontend and the error
is no longer present.

closes odoo/odoo#111048

Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
This commit is contained in:
David Monnom (moda)
2023-01-27 18:48:45 +01:00
parent 4f7d03829e
commit 7c415e972f
3 changed files with 12 additions and 0 deletions
+3
View File
@@ -1045,6 +1045,9 @@ class PosOrder(models.Model):
"""This function is here to be overriden"""
return []
def _prepare_order_line(self, order_line):
return order_line
def export_for_ui(self):
""" Returns a list of dict with each item having similar signature as the return of
`export_as_JSON` of models.Order. This is useful for back-and-forth communication
+8
View File
@@ -143,6 +143,14 @@ class PosOrder(models.Model):
'coupon_report': coupon_per_report,
}
def _prepare_order_line(self, order_line):
order_line = super(PosOrder, self)._prepare_order_line(order_line)
if order_line["reward_id"]:
order_line["reward_id"] = order_line["reward_id"][0]
return order_line
def _get_fields_for_order_line(self):
fields = super(PosOrder, self)._get_fields_for_order_line()
fields.extend(['is_reward_line', 'reward_id', 'coupon_id', 'reward_identifier_code', 'points_cost'])
@@ -73,6 +73,7 @@ class PosOrder(models.Model):
:type order_line: pos.order.line.
:returns: dict -- dict representing the order line's values.
"""
order_line = super(PosOrder, self)._prepare_order_line(order_line)
order_line["product_id"] = order_line["product_id"][0]
order_line["server_id"] = order_line["id"]