~zaber/openupgrade-addons/missing-import

« back to all changes in this revision

Viewing changes to audittrail/wizard/wizard_view_log.py

  • Committer: Sofia
  • Date: 2008-09-16 11:45:13 UTC
  • mto: (1558.2.75 addons)
  • mto: This revision was merged to the branch mainline in revision 1588.
  • Revision ID: sahibsofia@gmail.com-20080916114513-7an9yz59hucjmjk8
The following modules are merged::
addons-extra/product_procurement -> mrp module
addons-extra/inventory_merge -> stock
addons-extra/product_pricelist_print -> product
addons-extra/invoice_payment -> account 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
import wizard
 
3
import pooler
 
4
import time
 
5
 
 
6
class wizard_view_log(wizard.interface):
 
7
    
 
8
    form1 = '''<?xml version="1.0"?>
 
9
    <form string="Audit Logs">
 
10
        <field name="from" colspan="4"/>
 
11
        <newline/>
 
12
        <field name="to" colspan="4"/>        
 
13
    </form>'''
 
14
    
 
15
    form1_fields = {
 
16
            'from': {
 
17
                'string': 'Log From',
 
18
                'type': 'datetime',
 
19
        
 
20
        },
 
21
             'to': {
 
22
                'string': 'Log To',
 
23
                'type': 'datetime',
 
24
                'default': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
 
25
                'required':True
 
26
        },
 
27
    }
 
28
    
 
29
    
 
30
    def _log_open_window(self, cr, uid, data, context):
 
31
        mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
 
32
        act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
 
33
        result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
 
34
        id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
 
35
        result = act_obj.read(cr, uid, [id])[0]
 
36
        log_obj= pooler.get_pool(cr.dbname).get(result['res_model'])
 
37
        log_id = log_obj.search(cr, uid, [])
 
38
        log_model=log_obj.read(cr, uid,log_id,['object_id'])       
 
39
        if not data['form']['from']:
 
40
            if  data['form']['to'] <> time.strftime("%Y-%m-%d %H:%M:%S"):
 
41
                result['domain'] = str([('timestamp', '<',data['form']['to'])])                
 
42
            else:
 
43
                pass
 
44
        else:
 
45
            result['domain'] = str([('timestamp', '>',data['form']['from']),('timestamp', '<',data['form']['to'])])
 
46
            
 
47
        return result
 
48
 
 
49
    states = {
 
50
        'init': {
 
51
            'actions': [],
 
52
            'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel'), ('open', 'Open Logs')]}
 
53
        },
 
54
        'open': {
 
55
            'actions': [],
 
56
            'result': {'type': 'action', 'action':_log_open_window, 'state':'end'}
 
57
        }
 
58
    }
 
59
wizard_view_log('audittrail.view.log')
 
60
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
61