Active Record
This commit is contained in:
1 parent
ec72418f54
commit
6a3d10b60c
3 files changed
+34
-17
No files matched your search
@@ -1,5 +1,13 @@
|
||||
#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.pool import Pool
|
||||
from .company import *
|
||||
from .res import *
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Company,
|
||||
User,
|
||||
module='company_work_time', type_='model')
|
||||
+16
-10
@@ -1,27 +1,33 @@
|
||||
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
"Company"
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
|
||||
class Company(ModelSQL, ModelView):
|
||||
_name = 'company.company'
|
||||
__all__ = ['Company']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class Company:
|
||||
__name__ = 'company.company'
|
||||
|
||||
hours_per_work_day = fields.Float("Hours per Work Day", required=True)
|
||||
hours_per_work_week = fields.Float("Hours per Work Week", required=True)
|
||||
hours_per_work_month = fields.Float("Hours per Work Month", required=True)
|
||||
hours_per_work_year = fields.Float("Hours per Work Year", required=True)
|
||||
|
||||
def default_hours_per_work_day(self):
|
||||
@staticmethod
|
||||
def default_hours_per_work_day():
|
||||
return 8
|
||||
|
||||
def default_hours_per_work_week(self):
|
||||
@staticmethod
|
||||
def default_hours_per_work_week():
|
||||
return 40
|
||||
|
||||
def default_hours_per_work_month(self):
|
||||
@staticmethod
|
||||
def default_hours_per_work_month():
|
||||
return 160
|
||||
|
||||
def default_hours_per_work_year(self):
|
||||
@staticmethod
|
||||
def default_hours_per_work_year():
|
||||
return 1920
|
||||
|
||||
Company()
|
||||
@@ -1,13 +1,18 @@
|
||||
#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
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
|
||||
class User(ModelSQL, ModelView):
|
||||
_name = 'res.user'
|
||||
__all__ = ['User']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
def _get_preferences(self, user, context_only=False):
|
||||
res = super(User, self)._get_preferences(user,
|
||||
|
||||
class User:
|
||||
__name__ = 'res.user'
|
||||
|
||||
@classmethod
|
||||
def _get_preferences(cls, user, context_only=False):
|
||||
res = super(User, cls)._get_preferences(user,
|
||||
context_only=context_only)
|
||||
if user.company:
|
||||
res['company_work_time'] = {
|
||||
@@ -17,5 +22,3 @@ class User(ModelSQL, ModelView):
|
||||
'd': user.company.hours_per_work_day,
|
||||
}
|
||||
return res
|
||||
|
||||
User()
|
||||
Reference in new issue
Block a user