OCA/OCB — pull request #110 by bwrsandman (2014-12-16 20:56:23+00:00)
Title: [7.0] Factor out generation of user values to inheritable function

Odoo PR: https://github.com/odoo/odoo/pull/2355

## Description

There is no easy way to edit the values sent to newly generated users from oauth_signup.

In some cases, the mapping from an oauth provider can be different.
* ex: login is something other than email

In other cases, there are additional fields in res_users added by a module
* ex: firstname and last name in `partner_firstname` from OCA

Since this module basically only adds an overwrite to the `_auth_oauth_signin()` function, factoring out the part which is most likely to be altered is a good alternative to copying the `_auth_oauth_signin()` function each time a module needs different values.

This factorization allows modules inheriting from `auth_oauth_signup` to alter values sent to the copy of Template User with needed changes which I described. This means smaller changes to the default behaviour and the ability to properly inherit (multiple times if needed) this module without losing needed behaviour.

## Example inheriting

For partner_firstname, the following code could be use to add extra default values
```python
from openerp.osv import orm

class res_users(orm.Model):
_inherit = 'res.users'

def _generate_signup_values(
self, cr, uid, provider, validation, params, context=None):
values = super(res_users, self)._generate_signup_values(
cr, uid, provider, validation, params, context=context
)
values.update(
lastname=validation.get('lastname') or values.get('name') or False,
firstname=validation.get('firstname') or False,
)
return values
```

A server which doesn't always supply an email address
```python
from openerp.osv import orm

class res_users(orm.Model):
_inherit = 'res.users'

def _generate_signup_values(
self, cr, uid, provider, validation, params, context=None):
"""Email isn't a required field in oauth server
use oauth_uid for login instead
"""
values = super(res_users, self)._generate_signup_values(
cr, uid, provider, validation, params, context=context
)
values['login'] = values['oauth_uid']
return values
```

Problem described here https://github.com/OCA/partner-contact/issues/30