You will probably have to create a partner for your user anyways. My thought is that you may want to make your players partners. You can override the view and remove the elements that are not player oriented or hide them if the is_player
flag is true. (You may want to add a new is_player
boolean). You can use the is_player
boolean to define when to display the player view or a generic contact view.
Personally I would use partner and users as so much of Odoo's security and structures are already built around these models.
If your player inherits partner you can override the create() method and within it simply create a user after you have created your contact.
@api.model
@api.returns('self', lambda rec: rec.id)
def create(self, vals):
vals['notify_email'] = 'always'
rec = super(Partner, self).create(vals)
v = {
'active': True,
'login': rec.email,
'company_id': 1,
'partner_id': rec.id,
'create_uid': 1,
'write_uid': 1,
'display_groups_suggestions': False,
'share': False
}
user_id = self.env['res.users'].sudo().create(v)
return rec
The above example creates a user with a bunch of values you will probably want to change to be more appropriate for your needs. After you create the user you will want to send a password reset.