From 5207e1be28f7217a61fc3df8662f316cdd25b5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 22 May 2009 10:51:54 +0200 Subject: [PATCH] Set company_work_time in user context --- __init__.py | 1 + res.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 res.py diff --git a/__init__.py b/__init__.py index 98cd30b8f3..74b0386c54 100644 --- a/__init__.py +++ b/__init__.py @@ -2,3 +2,4 @@ #this repository contains the full copyright notices and license terms. from company import * +from res import * diff --git a/res.py b/res.py new file mode 100644 index 0000000000..41b92b26ea --- /dev/null +++ b/res.py @@ -0,0 +1,22 @@ +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. +from trytond.model import ModelView, ModelSQL + + +class User(ModelSQL, ModelView): + _name = 'res.user' + + def _get_preferences(self, cursor, user_id, user, context_only=False, + context=None): + res = super(User, self)._get_preferences(cursor, user_id, user, + context_only=context_only, context=context) + if user.company: + res['company_work_time'] = { + 'Y': user.company.hours_per_work_year, + 'M': user.company.hours_per_work_month, + 'w': user.company.hours_per_work_week, + 'd': user.company.hours_per_work_day, + } + return res + +User()