1
##############################################################################
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
29
from osv import osv, fields
33
class sale_journal_invoice_type(osv.osv):
34
_name = 'sale_journal.invoice.type'
35
_description = 'Invoice Types'
37
'name': fields.char('Invoice Type', size=64, required=True),
38
'active': fields.boolean('Active'),
39
'note': fields.text('Note'),
40
'invoicing_method': fields.selection([('simple','Non grouped'),('grouped','Grouped')], 'Invoicing method', required=True),
43
'active': lambda *a: True,
44
'invoicing_method': lambda *a:'simple'
46
sale_journal_invoice_type()
48
class sale_journal(osv.osv):
49
_name = 'sale_journal.sale.journal'
50
_description = 'Sale Journal'
52
'name': fields.char('Journal', size=64, required=True),
53
'code': fields.char('Code', size=16, required=True),
54
'user_id': fields.many2one('res.users', 'Responsible', required=True),
55
'date': fields.date('Journal date', required=True),
56
'date_created': fields.date('Creation date', readonly=True, required=True),
57
'date_validation': fields.date('Validation date', readonly=True),
58
'sale_stats_ids': fields.one2many("sale_journal.sale.stats", "journal_id", 'Sale Stats', readonly=True),
59
'state': fields.selection([
63
], 'State', required=True),
64
'note': fields.text('Note'),
67
'date': lambda *a: time.strftime('%Y-%m-%d'),
68
'date_created': lambda *a: time.strftime('%Y-%m-%d'),
69
'user_id': lambda self,cr,uid,context: uid,
70
'state': lambda self,cr,uid,context: 'draft',
72
def button_sale_cancel(self, cr, uid, ids, context={}):
74
sale_ids = self.pool.get('sale.order').search(cr, uid, [('journal_id','=',id),('state','=','draft')])
75
for saleid in sale_ids:
76
wf_service = netsvc.LocalService("workflow")
77
wf_service.trg_validate(uid, 'sale.order', saleid, 'cancel', cr)
79
def button_sale_confirm(self, cr, uid, ids, context={}):
81
sale_ids = self.pool.get('sale.order').search(cr, uid, [('journal_id','=',id),('state','=','draft')])
82
for saleid in sale_ids:
83
wf_service = netsvc.LocalService("workflow")
84
wf_service.trg_validate(uid, 'sale.order', saleid, 'order_confirm', cr)
87
def button_open(self, cr, uid, ids, context={}):
88
self.write(cr, uid, ids, {'state':'open'})
90
def button_draft(self, cr, uid, ids, context={}):
91
self.write(cr, uid, ids, {'state':'draft'})
93
def button_close(self, cr, uid, ids, context={}):
94
self.write(cr, uid, ids, {'state':'done', 'date_validation':time.strftime('%Y-%m-%d')})
98
class picking_journal(osv.osv):
99
_name = 'sale_journal.picking.journal'
100
_description = 'Packings Journal'
102
'name': fields.char('Journal', size=64, required=True),
103
'code': fields.char('Code', size=16, required=True),
104
'user_id': fields.many2one('res.users', 'Responsible', required=True),
105
'date': fields.date('Journal date', required=True),
106
'date_created': fields.date('Creation date', readonly=True, required=True),
107
'date_validation': fields.date('Validation date', readonly=True),
108
'picking_stats_ids': fields.one2many("sale_journal.picking.stats", "journal_id", 'Journal Stats', readonly=True),
109
'state': fields.selection([
113
], 'Creation date', required=True),
114
'note': fields.text('Note'),
117
'date': lambda *a: time.strftime('%Y-%m-%d'),
118
'date_created': lambda *a: time.strftime('%Y-%m-%d'),
119
'user_id': lambda self,cr,uid,context: uid,
120
'state': lambda self,cr,uid,context: 'draft',
122
def button_picking_cancel(self, cr, uid, ids, context={}):
124
pick_ids = self.pool.get('stock.picking').search(cr, uid, [('journal_id','=',id)])
125
for pickid in pick_ids:
126
wf_service = netsvc.LocalService("workflow")
127
wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_cancel', cr)
129
def button_open(self, cr, uid, ids, context={}):
130
self.write(cr, uid, ids, {'state':'open'})
132
def button_draft(self, cr, uid, ids, context={}):
133
self.write(cr, uid, ids, {'state':'draft'})
135
def button_close(self, cr, uid, ids, context={}):
136
self.write(cr, uid, ids, {'state':'done', 'date_validation':time.strftime('%Y-%m-%d')})