1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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.
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.
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/>.
20
##############################################################################
26
from tools.translate import _
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]
40
'name': _('Product Margins'),
41
'context':{'date_from':data['form']['from_date'],'date_to':data['form']['to_date'],'invoice_state' : data['form']['invoice_state']},
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')],
48
'search_view_id': id['res_id']
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"/>
64
'default': lambda *a:time.strftime('%Y-01-01'),
70
'default': lambda *a:time.strftime('%Y-12-31'),
74
'string': 'Invoice State',
76
'selection': [('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid'),],
78
'default': lambda *a:"open_paid",
85
'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Margins','gtk-ok')]}
89
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
92
product_margins('product.margins')
93
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: