← Back to team overview

oerppy-hackers team mailing list archive

[Branch ~oerppy-hackers/oerppy/trunk] Rev 44: * Split-out Canonical customizations into subclasses and copied appropriate

 

------------------------------------------------------------
revno: 44
committer: duncan@xxxxxxxxxx
branch nick: trunk
timestamp: Thu 2011-06-09 10:45:22 -0600
message:
  * Split-out Canonical customizations into subclasses and copied appropriate
    methods over to the Canonical query class.
  * Added some missing docstrings to models.
modified:
  oerppy/addons/canonical/model.py
  oerppy/addons/canonical/query.py
  oerppy/model.py


--
lp:oerppy
https://code.launchpad.net/~oerppy-hackers/oerppy/trunk

Your team oerppy Hackers is subscribed to branch lp:oerppy.
To unsubscribe from this branch go to https://code.launchpad.net/~oerppy-hackers/oerppy/trunk/+edit-subscription
=== modified file 'oerppy/addons/canonical/model.py'
--- oerppy/addons/canonical/model.py	2011-06-06 18:29:31 +0000
+++ oerppy/addons/canonical/model.py	2011-06-09 16:45:22 +0000
@@ -3,7 +3,10 @@
 
 
 class UserCategory(model.Model):
-
+    """
+    This is an object model that maps to search results from the custom OpenERP
+    "canonical.user.category" entity.
+    """
     def __init__(self, row):
         self.id = row.get("id")
         self.code = row.get("code")
@@ -20,13 +23,18 @@
 
 
 class UserCategoriesSet(model.ResultSet):
-
+    """
+    An object for collecting UserCategory records together.
+    """
     model = UserCategory
 
 
 
 class TaskWork(project.model.TaskWork):
-
+    """
+    This is an object model that maps to search results from the customized
+    OpenERP "project.task.work" entity.
+    """
     def __init__(self, row, depts):
         super(TaskWork, self).__init__(row, depts)
         self.project = model.KeyValuePairField(row.get("project_id"))
@@ -34,10 +42,29 @@
 
 
 class TaskWorkSet(project.model.TaskWorkSet):
-
+    """
+    An object for collecting TaskWork records together.
+    """
     model = TaskWork
 
     def get_work(self, project_id):
         for project in self:
             if project.project.key == project_id:
                 return project
+
+
+class User(model.User):
+    """
+    This is an object model that maps to search results from the customized
+    OpenERP "res.users" entity.
+    """
+    def __init__(self, row):
+        super(User, self).__init__(row)
+        self.category_ids = row.get("category_ids")
+
+
+class UsersSet(model.UsersSet):
+    """
+    An object for collecting User records together.
+    """
+    model = User

=== modified file 'oerppy/addons/canonical/query.py'
--- oerppy/addons/canonical/query.py	2011-06-09 15:25:17 +0000
+++ oerppy/addons/canonical/query.py	2011-06-09 16:45:22 +0000
@@ -33,6 +33,23 @@
             raise OpenERPPyParameterError("Unknown value for 'report.'")
         return records
 
+    def get_users(self):
+        raw_results = self.client.searchfields(
+            entity='res.users',
+            query=[],
+            fields=[])
+        return model.UsersSet(raw_results)
+
+    def get_user_names(self, user_ids):
+        """
+        Get the OpenERP user names for the user IDs provided.
+        """
+        raw_results = self.client.searchfields(
+            'res.users' ,
+            [('id','in', user_ids)],
+            ['id', 'name'])
+        return model.UsersSet(raw_results)
+
     def get_user_dept(self):
         user_dept = self._cache.get("user_dept")
         if user_dept:

=== modified file 'oerppy/model.py'
--- oerppy/model.py	2011-06-09 03:06:38 +0000
+++ oerppy/model.py	2011-06-09 16:45:22 +0000
@@ -50,11 +50,13 @@
 
 
 class User(Model):
-
+    """
+    This is an object model that maps to search results from OpenERP's
+    "res.users" entity.
+    """
     def __init__(self, row):
         self.id = row.get("id")
         self.active = row.get("active")
-        self.category_ids = row.get("category_ids")
         self.company_ids = row.get("company_ids")
         self.menu_tips = row.get("menu_tips")
         self.date = row.get("date")
@@ -85,7 +87,9 @@
 
 
 class UsersSet(ResultSet):
-
+    """
+    An object for collecting User records together.
+    """
     model = User
 
     def get_user(self, user_id):