1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2008 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 fields,osv
28 class purchase_tender(osv.osv):
29 _name = "purchase.tender"
30 _description="Purchase Tender"
32 'name': fields.char('Tender Reference', size=32,required=True),
33 'date_start': fields.datetime('Date Start'),
34 'date_end': fields.datetime('Date End'),
35 'user_id': fields.many2one('res.users', 'Responsible'),
36 'description': fields.text('Description'),
37 'purchase_ids' : fields.one2many('purchase.order','tender_id','Purchase Orders'),
38 'state': fields.selection([('draft','Draft'),('open','Open'),('close','Close')], 'State', required=True)
41 'date_start': lambda *args: time.strftime('%Y-%m-%d %H:%M:%S'),
42 'state': lambda *args: 'open',
43 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'purchase.order.tender'),
47 class purchase_order(osv.osv):
48 _inherit = "purchase.order"
49 _description = "purchase order"
51 'tender_id' : fields.many2one('purchase.tender','Purchase Tender')
53 def wkf_confirm_order(self, cr, uid, ids, context={}):
54 res = super(purchase_order, self).wkf_confirm_order(cr, uid, ids, context)
55 for po in self.browse(cr, uid, ids, context):
57 for order in po.tender_id.purchase_ids:
59 wf_service = netsvc.LocalService("workflow")
60 wf_service.trg_validate(uid, 'purchase.order', order.id, 'purchase_cancel', cr)
61 self.pool.get('purchase.tender').write(cr, uid, [po.tender_id.id], {'state':'close'})