parent
7005593040
commit
264297b4d1
|
@ -7,7 +7,7 @@ from . import bank
|
|||
from . import employee
|
||||
from . import carrier
|
||||
from . import party
|
||||
|
||||
from . import user
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
|
@ -17,6 +17,7 @@ def register():
|
|||
party.Address,
|
||||
party.PartyIdentifier,
|
||||
party.ContactMechanism,
|
||||
user.User,
|
||||
module='party_company', type_='model')
|
||||
Pool.register(
|
||||
activity.Activity,
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# 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
|
Loading…
Reference in New Issue