product.py 923 B

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import api, fields, models
  4. class ProductTemplate(models.Model):
  5. _inherit = 'product.template'
  6. detailed_type = fields.Selection(selection_add=[
  7. ('event_booth', 'Event Booth'),
  8. ], ondelete={'event_booth': 'set service'})
  9. @api.onchange('detailed_type')
  10. def _onchange_type_event_booth(self):
  11. if self.detailed_type == 'event_booth':
  12. self.invoice_policy = 'order'
  13. def _detailed_type_mapping(self):
  14. type_mapping = super()._detailed_type_mapping()
  15. type_mapping['event_booth'] = 'service'
  16. return type_mapping
  17. class Product(models.Model):
  18. _inherit = 'product.product'
  19. @api.onchange('detailed_type')
  20. def _onchange_type_event_booth(self):
  21. if self.detailed_type == 'event_booth':
  22. self.invoice_policy = 'order'