~willowit-openerp-team/willowit-openerp-addons/development

« back to all changes in this revision

Viewing changes to product_margin/wizard/wizard_product_margin.py

  • Committer: Deepak Seshadri
  • Date: 2011-04-04 07:04:07 UTC
  • Revision ID: deepak@willowit.com.au-20110404070407-8j9mnxzzgh53o24t
Remove irrelevant modules from this branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#    
4
 
#    OpenERP, Open Source Management Solution
5
 
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6
 
#
7
 
#    This program is free software: you can redistribute it and/or modify
8
 
#    it under the terms of the GNU Affero General Public License as
9
 
#    published by the Free Software Foundation, either version 3 of the
10
 
#    License, or (at your option) any later version.
11
 
#
12
 
#    This program is distributed in the hope that it will be useful,
13
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
#    GNU Affero General Public License for more details.
16
 
#
17
 
#    You should have received a copy of the GNU Affero General Public License
18
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
19
 
#
20
 
##############################################################################
21
 
 
22
 
import wizard
23
 
import pooler
24
 
import time
25
 
 
26
 
from tools.translate import _
27
 
 
28
 
def _action_open_window(self, cr, uid, data, context):
29
 
    pool = pooler.get_pool(cr.dbname) 
30
 
    mod_obj = pool.get('ir.model.data') 
31
 
    result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
32
 
    id = mod_obj.read(cr, uid, result, ['res_id'])    
33
 
    cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.graph', 'graph'))
34
 
    view_res3 = cr.fetchone()[0]
35
 
    cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.form.inherit', 'form'))
36
 
    view_res2 = cr.fetchone()[0]
37
 
    cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.tree', 'tree'))
38
 
    view_res = cr.fetchone()[0]
39
 
    return {
40
 
        'name': _('Product Margins'),
41
 
        'context':{'date_from':data['form']['from_date'],'date_to':data['form']['to_date'],'invoice_state' : data['form']['invoice_state']},
42
 
        'view_type': 'form',
43
 
        "view_mode": 'tree,form,graph',
44
 
        'res_model':'product.product',
45
 
        'type': 'ir.actions.act_window',
46
 
        'views': [(view_res,'tree'), (view_res2,'form'), (view_res3,'graph')],
47
 
        'view_id': False,
48
 
        'search_view_id': id['res_id'] 
49
 
    }
50
 
 
51
 
 
52
 
class product_margins(wizard.interface):
53
 
    form1 = '''<?xml version="1.0"?>
54
 
    <form string="View Stock of Products">
55
 
        <separator string="Select " colspan="4"/>
56
 
        <field name="from_date"/>
57
 
        <field name="to_date"/>
58
 
        <field name="invoice_state"/>
59
 
    </form>'''
60
 
    form1_fields = {
61
 
             'from_date': {
62
 
                'string': 'From',
63
 
                'type': 'date',
64
 
                'default': lambda *a:time.strftime('%Y-01-01'),
65
 
 
66
 
        },
67
 
             'to_date': {
68
 
                'string': 'To',
69
 
                'type': 'date',
70
 
                'default': lambda *a:time.strftime('%Y-12-31'),
71
 
 
72
 
        },
73
 
         'invoice_state': {
74
 
                'string': 'Invoice State',
75
 
                'type': 'selection',
76
 
                'selection': [('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid'),],
77
 
                'required': True,
78
 
                'default': lambda *a:"open_paid",
79
 
        },
80
 
    }
81
 
 
82
 
    states = {
83
 
      'init': {
84
 
            'actions': [],
85
 
            'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Margins','gtk-ok')]}
86
 
        },
87
 
    'open': {
88
 
            'actions': [],
89
 
            'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
90
 
        }
91
 
    }
92
 
product_margins('product.margins')
93
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: