2010-04-09 13:57:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
2010-06-23 11:53:20 +00:00
|
|
|
#
|
2010-04-09 13:57:28 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2010-06-23 11:53:20 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-04-09 13:57:28 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
|
|
|
from openerp.tools.translate import _
|
2010-04-09 13:57:28 +00:00
|
|
|
|
2010-04-16 06:17:50 +00:00
|
|
|
class purchase_requisition_partner(osv.osv_memory):
|
|
|
|
_name = "purchase.requisition.partner"
|
|
|
|
_description = "Purchase Requisition Partner"
|
2010-04-09 13:57:28 +00:00
|
|
|
_columns = {
|
2012-06-01 12:30:48 +00:00
|
|
|
'partner_id': fields.many2one('res.partner', 'Supplier', required=True,domain=[('supplier', '=', True)]),
|
2010-08-13 12:20:05 +00:00
|
|
|
}
|
2010-04-09 13:57:28 +00:00
|
|
|
|
2010-04-13 06:57:37 +00:00
|
|
|
def view_init(self, cr, uid, fields_list, context=None):
|
2010-11-23 07:05:05 +00:00
|
|
|
if context is None:
|
2010-11-22 10:37:53 +00:00
|
|
|
context = {}
|
2010-04-16 06:17:50 +00:00
|
|
|
res = super(purchase_requisition_partner, self).view_init(cr, uid, fields_list, context=context)
|
2010-06-23 11:53:20 +00:00
|
|
|
record_id = context and context.get('active_id', False) or False
|
2010-11-22 10:37:53 +00:00
|
|
|
tender = self.pool.get('purchase.requisition').browse(cr, uid, record_id, context=context)
|
2010-04-13 06:57:37 +00:00
|
|
|
if not tender.line_ids:
|
2014-01-24 13:03:27 +00:00
|
|
|
raise osv.except_osv(_('Error!'), _('Define product(s) you want to include in the call for bids.'))
|
2011-12-02 07:27:55 +00:00
|
|
|
return res
|
2010-04-13 06:57:37 +00:00
|
|
|
|
2010-11-22 10:37:53 +00:00
|
|
|
def create_order(self, cr, uid, ids, context=None):
|
2011-12-02 07:27:55 +00:00
|
|
|
active_ids = context and context.get('active_ids', [])
|
|
|
|
data = self.browse(cr, uid, ids, context=context)[0]
|
|
|
|
self.pool.get('purchase.requisition').make_purchase_order(cr, uid, active_ids, data.partner_id.id, context=context)
|
2010-12-28 10:41:38 +00:00
|
|
|
return {'type': 'ir.actions.act_window_close'}
|
2010-04-12 08:26:03 +00:00
|
|
|
|
2010-04-09 13:57:28 +00:00
|
|
|
|
2010-06-23 11:53:20 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|