← Back to team overview

openerp-dev-web team mailing list archive

lp:~openerp-dev/openobject-server/trunk-temporal-db-read-search-unlink-ksa into lp:~openerp-dev/openobject-server/trunk-temporal-db

 

Kirti Savalia(OpenERP) has proposed merging lp:~openerp-dev/openobject-server/trunk-temporal-db-read-search-unlink-ksa into lp:~openerp-dev/openobject-server/trunk-temporal-db.

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

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-temporal-db-read-search-unlink-ksa/+merge/59368

Unlink,Read,Search Method
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-temporal-db-read-search-unlink-ksa/+merge/59368
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-server/trunk-temporal-db.
=== modified file 'openerp/osv/orm.py'
--- openerp/osv/orm.py	2011-04-27 14:57:39 +0000
+++ openerp/osv/orm.py	2011-04-28 13:08:23 +0000
@@ -4293,7 +4293,7 @@
 
     def __init__(self, cr):
         self._columns.update({
-        'temporal_date_from': fields.datetime('Temporal From Date', required=True),
+        'temporal_date_from': fields.datetime('Temporal From Date'),
         'temporal_date_to': fields.function(self.set_date, method=True, string='Temporal To Date', type='datetime',
             store = {
                 self._name: (lambda self, cr, uid, ids, c={}: ids, ['temporal_date_from'], 10),
@@ -4320,5 +4320,34 @@
             orm.copy(self, cr, uid, record.id, defaults, context=context)
         return super(orm_temporal, self).write(cr, uid, ids, vals, context=context)
 
+    def unlink(self, cr, uid, ids, context=None):
+        unlink_ids = self.search(cr, uid, ['|',('temporal_parent_id', 'in', ids),('id','in', ids)], context=context)
+        return super(orm_temporal, self).unlink(cr, uid, unlink_ids, context=context)
+
+    def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
+        if context is None:
+            context = {}
+        original_args = args + [('temporal_parent_id', '=', False)]
+        if context.get('all_temporal'):
+            return super(orm_temporal,self).search(cr, user, args, offset, limit, order, context, count)
+        return super(orm_temporal, self).search(cr, user, original_args, offset, limit, order, context, count)
+
+        if context.get('temporal_date'):
+            args.append(['temporal_date_from', '<', context['temporal_date']] and ['temporal_date_to', '>', context['temporal_date']])
+        return super(orm_temporal, self).search(cr, user, args, offset, limit, order, context, count)
+
+
+    def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
+        new_ids = isinstance(ids, (str, int, long)) and [ids] or ids
+        if context is None:
+            context = {}
+        if fields and 'temporal_parent_id' not in fields:
+            original_fields = fields + [('temporal_parent_id', '=', False)]
+        data = self.search(cr, uid, [('temporal_parent_id', '=', False)], context=context)
+
+        if context.get('temporal_date'):
+            return super(orm_temporal, self).read(cr, uid, new_ids, fields=fields, context=context, load=load)
+        return super(orm_temporal, self).read(cr, uid, data, fields=original_fields, context=context, load=load)
+
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 


Follow ups