# -*- coding: utf-8 -*-fromopenerpimportmodels,fields,apiclassProductTemplate(models.Model):_inherit='product.template'shift_ok=fields.Boolean('Shift Subscription',help="""Determine if a product needs to create automatically an event registration at the confirmation of a sales order line.""")shift_type_id=fields.Many2one('shift.type','Type of Shift',help="""Select event types so when we use this product in sales order lines, it will filter events of this type only.""")@api.onchange('type','shift_ok')defonchange_shift_ok(self):ifself.shift_ok:self.type='service'self.sale_ok=Falseself.purchase_ok=Falseself.event_ok=TrueclassProductProduct(models.Model):_inherit='product.product'shift_ticket_ids=fields.One2many('shift.ticket','product_id','Shift Tickets')@api.onchange('type','shift_ok')defonchange_shift_ok(self):"""Redirection, inheritance mechanism hides the method on the model"""ifself.shift_ok:self.type='service'self.sale_ok=Falseself.purchase_ok=Falseself.event_ok=True