Rucha (Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-temporal-db-intermediate-branch-rpa-ksa-o2m-get-rpa
 into 
lp:~openerp-dev/openobject-addons/trunk-temporal-db-intermediate-branch-rpa-ksa.

Requested reviews:
  Rucha (Open ERP) (rpa-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-temporal-db-intermediate-branch-rpa-ksa-o2m-get-rpa/+merge/68085

Implemented o2m get() to display temporal records of o2m field properly
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-temporal-db-intermediate-branch-rpa-ksa-o2m-get-rpa/+merge/68085
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-temporal-db-intermediate-branch-rpa-ksa.
=== modified file 'base_temporal/base_temporal.py'
--- base_temporal/base_temporal.py	2011-07-12 07:10:21 +0000
+++ base_temporal/base_temporal.py	2011-07-15 12:56:11 +0000
@@ -22,20 +22,21 @@
 from osv import orm
 import time
 
-#TODO: override the get of *2many fields 
-#class one2many(_column):
-#
-#
-#    def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
-#         if isinstance(self._obj, orm_temporal):
-#             res = []
-#             for i in ids:
-#                 ctx = context.copy()
-#                 ctx.update({'temporal_date': i.temporal_date_to})
-#                 new_ids = self._obj.get_ids_of_same_group()
-#                 res += super.get(ids=new_ids, context=ctx)
-#             return res
-#          return super.get()
+# override the get of *2many fields to get proper values 
+class one2many_temporal(fields.one2many):
+    def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
+        temporal_obj = obj.pool.get(self._obj)
+        if isinstance(temporal_obj, orm_temporal):
+            res = {}
+            ctx = context.copy()
+            for record in obj.browse(cr, user, ids, context=context):
+                if record.temporal_date_to:
+                    ctx.update({'temporal_date': record.temporal_date_to, 'temporal_mode': True})
+                record_ids = obj.get_ids_of_same_group(cr, user, [record.id], context=context)[record.id]
+                temporal_ids = temporal_obj.search(cr, user, [(self._fields_id, 'in', tuple(record_ids))], context=ctx)
+                res[record.id] = temporal_ids
+            return res
+        return super(one2many_temporal, self).get(cr, obj, ids, name, user=user, offset=offset, context=context, values=values)
 
 
 class orm_temporal(orm.orm):
@@ -168,7 +169,7 @@
 
         #add the time constraint
         temporal_date = context.get("temporal_date", cr.transaction_datestart)
-        new_args += ['&','|',('temporal_date_from','=',False),('temporal_date_from', '<=', temporal_date), '|', ('temporal_date_to', '=', False), ('temporal_date_to', '>', temporal_date)]
+        new_args += ['&','|',('temporal_date_from','=',False),('temporal_date_from', '<', temporal_date), '|', ('temporal_date_to', '=', False), ('temporal_date_to', '>=', temporal_date)]
         return super(orm_temporal, self).search(cr, user, new_args, offset, limit, order, context, count)
 
     def read(self, cr, uid, ids_orig, fields=None, context=None, load='_classic_read'):

=== modified file 'base_temporal/base_temporal_test.py'
--- base_temporal/base_temporal_test.py	2011-07-12 07:10:47 +0000
+++ base_temporal/base_temporal_test.py	2011-07-15 12:56:11 +0000
@@ -20,6 +20,7 @@
 ##############################################################################
 from osv import fields, osv
 import time
+import base_temporal
 
 class base_temporal_test(osv.osv_temporal):
     _name = "base.temporal.test"
@@ -27,7 +28,7 @@
 
     _columns = {
         'name': fields.char('Name', size=64),
-        'line_ids': fields.one2many('base.temporal.test.line', 'test_id', 'Lines'),
+        'line_ids': base_temporal.one2many_temporal('base.temporal.test.line', 'test_id', 'Lines'),
          }
 
 #in order to test if the temporal date is transactional

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to