product.py 751 B

12345678910111213141516171819202122232425262728
  1. # -*- coding: utf-8 -*-
  2. from odoo import api, fields, models
  3. class ProductTemplate(models.Model):
  4. _inherit = 'product.template'
  5. detailed_type = fields.Selection(selection_add=[
  6. ('event', 'Event Ticket'),
  7. ], ondelete={'event': 'set service'})
  8. @api.onchange('detailed_type')
  9. def _onchange_type_event(self):
  10. if self.detailed_type == 'event':
  11. self.invoice_policy = 'order'
  12. def _detailed_type_mapping(self):
  13. type_mapping = super()._detailed_type_mapping()
  14. type_mapping['event'] = 'service'
  15. return type_mapping
  16. class Product(models.Model):
  17. _inherit = 'product.product'
  18. event_ticket_ids = fields.One2many('event.event.ticket', 'product_id', string='Event Tickets')