product.py 536 B

1234567891011121314151617
  1. # -*- coding: utf-8 -*-
  2. from odoo import fields, models
  3. # defined for access rules
  4. class Product(models.Model):
  5. _inherit = 'product.product'
  6. event_ticket_ids = fields.One2many('event.event.ticket', 'product_id', string='Event Tickets')
  7. def _is_add_to_cart_allowed(self):
  8. # Allow adding event tickets to the cart regardless of product's rules
  9. self.ensure_one()
  10. res = super()._is_add_to_cart_allowed()
  11. return res or any(event.website_published for event in self.event_ticket_ids.event_id)