Prior to this commit an user could try to add a product to cart that does not exist anymore because it was deleted while the user /shop page wasn't refreshed. This commit avoids this (rare) use case to happen. TaskId-2835736 closes odoo/odoo#91752 X-original-commit: 7aeec2921d7159f0c7fa4c8caf2d00f802c69264 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com> Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
17 lines
536 B
Python
17 lines
536 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
# defined for access rules
|
|
class Product(models.Model):
|
|
_inherit = 'product.product'
|
|
|
|
event_ticket_ids = fields.One2many('event.event.ticket', 'product_id', string='Event Tickets')
|
|
|
|
def _is_add_to_cart_allowed(self):
|
|
# Allow adding event tickets to the cart regardless of product's rules
|
|
self.ensure_one()
|
|
res = super()._is_add_to_cart_allowed()
|
|
return res or any(event.website_published for event in self.event_ticket_ids.event_id)
|