1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
23
from osv import osv, fields
27
class sale_journal_invoice_type(osv.osv):
28
_name = 'sale_journal.invoice.type'
29
_description = 'Invoice Types'
31
'name': fields.char('Invoice Type', size=64, required=True),
32
'active': fields.boolean('Active'),
33
'note': fields.text('Note'),
34
'invoicing_method': fields.selection([('simple','Non grouped'),('grouped','Grouped')], 'Invoicing method', required=True),
37
'active': lambda *a: True,
38
'invoicing_method': lambda *a:'simple'
40
sale_journal_invoice_type()
42
class sale_journal(osv.osv):
43
_name = 'sale_journal.sale.journal'
44
_description = 'Sale Journal'
46
'name': fields.char('Journal', size=64, required=True),
47
'code': fields.char('Code', size=16, required=True),
48
'user_id': fields.many2one('res.users', 'Responsible', required=True),
49
'date': fields.date('Journal date', required=True),
50
'date_created': fields.date('Creation date', readonly=True, required=True),
51
'date_validation': fields.date('Validation date', readonly=True),
52
'sale_stats_ids': fields.one2many("sale_journal.sale.stats", "journal_id", 'Sale Stats', readonly=True),
53
'state': fields.selection([
57
], 'State', required=True),
58
'note': fields.text('Note'),
61
'date': lambda *a: time.strftime('%Y-%m-%d'),
62
'date_created': lambda *a: time.strftime('%Y-%m-%d'),
63
'user_id': lambda self,cr,uid,context: uid,
64
'state': lambda self,cr,uid,context: 'draft',
66
def button_sale_cancel(self, cr, uid, ids, context={}):
68
sale_ids = self.pool.get('sale.order').search(cr, uid, [('journal_id','=',id),('state','=','draft')])
69
for saleid in sale_ids:
70
wf_service = netsvc.LocalService("workflow")
71
wf_service.trg_validate(uid, 'sale.order', saleid, 'cancel', cr)
73
def button_sale_confirm(self, cr, uid, ids, context={}):
75
sale_ids = self.pool.get('sale.order').search(cr, uid, [('journal_id','=',id),('state','=','draft')])
76
for saleid in sale_ids:
77
wf_service = netsvc.LocalService("workflow")
78
wf_service.trg_validate(uid, 'sale.order', saleid, 'order_confirm', cr)
81
def button_open(self, cr, uid, ids, context={}):
82
self.write(cr, uid, ids, {'state':'open'})
84
def button_draft(self, cr, uid, ids, context={}):
85
self.write(cr, uid, ids, {'state':'draft'})
87
def button_close(self, cr, uid, ids, context={}):
88
self.write(cr, uid, ids, {'state':'done', 'date_validation':time.strftime('%Y-%m-%d')})
92
class picking_journal(osv.osv):
93
_name = 'sale_journal.picking.journal'
94
_description = 'Packing Journal'
96
'name': fields.char('Journal', size=64, required=True),
97
'code': fields.char('Code', size=16, required=True),
98
'user_id': fields.many2one('res.users', 'Responsible', required=True),
99
'date': fields.date('Journal date', required=True),
100
'date_created': fields.date('Creation date', readonly=True, required=True),
101
'date_validation': fields.date('Validation date', readonly=True),
102
'picking_stats_ids': fields.one2many("sale_journal.picking.stats", "journal_id", 'Journal Stats', readonly=True),
103
'state': fields.selection([
107
], 'Creation date', required=True),
108
'note': fields.text('Note'),
111
'date': lambda *a: time.strftime('%Y-%m-%d'),
112
'date_created': lambda *a: time.strftime('%Y-%m-%d'),
113
'user_id': lambda self,cr,uid,context: uid,
114
'state': lambda self,cr,uid,context: 'draft',
116
def button_picking_cancel(self, cr, uid, ids, context={}):
118
pick_ids = self.pool.get('stock.picking').search(cr, uid, [('journal_id','=',id)])
119
for pickid in pick_ids:
120
wf_service = netsvc.LocalService("workflow")
121
wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_cancel', cr)
123
def button_open(self, cr, uid, ids, context={}):
124
self.write(cr, uid, ids, {'state':'open'})
126
def button_draft(self, cr, uid, ids, context={}):
127
self.write(cr, uid, ids, {'state':'draft'})
129
def button_close(self, cr, uid, ids, context={}):
130
self.write(cr, uid, ids, {'state':'done', 'date_validation':time.strftime('%Y-%m-%d')})
134
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: