| 1 |
|
| 2 |
|
| 3 |
from odoo.http import request, route |
| 4 |
from odoo.tools.misc import format_amount |
| 5 |
|
| 6 |
from odoo.addons.loyalty.controllers import portal as loyalty_portal |
| 7 |
|
| 8 |
|
| 9 |
class CustomerPortalLoyalty(loyalty_portal.CustomerPortalLoyalty): |
| 10 |
|
| 11 |
@route() |
| 12 |
def portal_get_card_history_values(self, card_id): |
| 13 |
"""Add published trigger products for the loyalty program.""" |
| 14 |
res = super().portal_get_card_history_values(card_id) |
| 15 |
program_sudo = request.env['loyalty.program'].sudo().search([ |
| 16 |
('coupon_ids', '=', int(card_id)), |
| 17 |
]) |
| 18 |
if not program_sudo: |
| 19 |
return res |
| 20 |
|
| 21 |
currency = request.env.company.currency_id |
| 22 |
res['program']['trigger_products'] = [{ |
| 23 |
'id': product.id, 'total_price': format_amount(self.env, product.lst_price, currency) |
| 24 |
} for product in program_sudo.trigger_product_ids if product.website_published] |
| 25 |
return res |