Reviewers: ,


Please review this at http://codereview.tryton.org/397007/

Affected files:
  M __init__.py
  M company.py
  M res.py


Index: __init__.py
===================================================================

--- a/__init__.py
+++ b/__init__.py
@@ -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')

Index: company.py
===================================================================

--- a/company.py
+++ b/company.py
@@ -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()

Index: res.py
===================================================================

--- a/res.py
+++ b/res.py
@@ -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 @@
                 'd': user.company.hours_per_work_day,
             }
         return res
-
-User()



--
tryton-dev@googlegroups.com mailing list

Reply via email to