22 lines
679 B
Python
22 lines
679 B
Python
# The COPYRIGHT file at the top level of this repository contains the full
|
|
# copyright notices and license terms.
|
|
from trytond.pool import PoolMeta
|
|
|
|
|
|
class User(metaclass=PoolMeta):
|
|
__name__ = 'res.user'
|
|
|
|
@classmethod
|
|
def __setup__(cls):
|
|
super(User, cls).__setup__()
|
|
if not 'companies' in cls._context_fields:
|
|
cls._context_fields.insert(0, 'companies')
|
|
|
|
@classmethod
|
|
def _get_preferences(cls, user, context_only=False):
|
|
res = super(User, cls)._get_preferences(user,
|
|
context_only=context_only)
|
|
if not res.get('companies'):
|
|
res['companies'] = [c.id for c in user.companies]
|
|
return res
|