Launchpad automatic translations update.
[odoo/odoo.git] / addons / purchase_requisition / wizard / purchase_requisition_partner.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
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.
11 #
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.
16 #
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/>.
19 #
20 ##############################################################################
21
22 import time
23 from osv import fields, osv
24 from osv.orm import browse_record, browse_null
25 from tools.translate import _
26
27 class purchase_requisition_partner(osv.osv_memory):
28     _name = "purchase.requisition.partner"
29     _description = "Purchase Requisition Partner"
30     _columns = {
31         'partner_id': fields.many2one('res.partner', 'Supplier', required=True,domain=[('supplier', '=', True)]),
32     }
33
34     def view_init(self, cr, uid, fields_list, context=None):
35         if context is None:
36             context = {}
37         res = super(purchase_requisition_partner, self).view_init(cr, uid, fields_list, context=context)
38         record_id = context and context.get('active_id', False) or False
39         tender = self.pool.get('purchase.requisition').browse(cr, uid, record_id, context=context)
40         if not tender.line_ids:
41             raise osv.except_osv(_('Error!'), _('No Product in Tender.'))
42         return res
43
44     def create_order(self, cr, uid, ids, context=None):
45         active_ids = context and context.get('active_ids', [])
46         data =  self.browse(cr, uid, ids, context=context)[0]
47         self.pool.get('purchase.requisition').make_purchase_order(cr, uid, active_ids, data.partner_id.id, context=context)
48         return {'type': 'ir.actions.act_window_close'}
49
50 purchase_requisition_partner()
51
52
53 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: