1
##############################################################################
3
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
5
# WARNING: This program as such is intended to be used by professional
6
# programmers who take the whole responsability of assessing all potential
7
# consequences resulting from its eventual inadequacies and bugs
8
# End users who are looking for a ready-to-use solution with commercial
9
# garantees and support are strongly adviced to contract a Free Software
12
# This program is Free Software; you can redistribute it and/or
13
# modify it under the terms of the GNU General Public License
14
# as published by the Free Software Foundation; either version 2
15
# of the License, or (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU General Public License for more details.
22
# You should have received a copy of the GNU General Public License
23
# along with this program; if not, write to the Free Software
24
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
##############################################################################
33
dates_form = '''<?xml version="1.0"?>
34
<form string="Select period">
35
<field name="company_id" colspan="4"/>
37
<field name="fiscalyear" colspan="4"/>
42
<field name="method" colspan="4"/>
43
<!--field name="mode" colspan="4"/-->
45
<field name="all" colspan="2"/>
46
<separator string="Select Products" colspan="4"/>
48
<field name="products" colspan="4"/>
52
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
53
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
54
'help': 'Keep empty for all open fiscal year'},
55
'date1': {'string':'Start of Date', 'type':'date', 'required':True},
56
'date2': {'string':'End of Date', 'type':'date', 'required':True},
60
'relation': 'product.product',
62
'all':{'string':'All Products', 'type':'boolean'},
63
'method': {'string': 'Method', 'type': 'selection','selection':[('fifo','FIFO'),('lifo','LIFO'),('weighted avg','WEIGHTED AVG'),('simple avg','SIMPLE AVG')]},
64
# 'mode': {'string': 'Mode', 'type': 'selection','selection':[('all invoice','All Invoice'),('with order','With Order'),('without order','WithOut Order')]},
67
class wizard_stock_summary_product_vice(wizard.interface):
68
def _get_defaults(self, cr, uid, data, context):
69
data['form']['method']='fifo'
70
data['form']['mode']='all invoice'
71
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
72
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
73
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
74
context['fiscalyear']= fiscalyear_obj.find(cr, uid)
75
year_start_date = fiscalyear_obj.browse(cr, uid, context['fiscalyear'] ).date_start
76
year_end_date = fiscalyear_obj.browse(cr, uid, context['fiscalyear'] ).date_stop
77
data['form']['date1'] = mx.DateTime.strptime(year_start_date,"%Y-%m-%d").strftime("%Y-%m-%d")
78
data['form']['date2'] = mx.DateTime.strptime(year_end_date,"%Y-%m-%d").strftime("%Y-%m-%d")
80
company_id = user.company_id.id
82
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
83
data['form']['company_id'] = company_id
85
# to process company IDS
86
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
87
company_ids = pooler.get_pool(cr.dbname).get('res.company')._get_company_children(cr, uid, user.company_id.id)
88
dates_fields['company_id']['domain'] = "[('id','in',"+str(company_ids) +")]"
94
'actions': [_get_defaults],
95
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
99
'result': {'type':'print', 'report':'stock.summary.prod.vice.report', 'state':'end'}
102
wizard_stock_summary_product_vice('stock.summary.prod.vice.report')