1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2014 TeMPO Consulting, MSF
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.
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.
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/>.
20
##############################################################################
22
from osv import fields
26
class purchase_order(osv.osv):
28
override for workflow modification
30
_name = 'purchase.order'
31
_inherit = 'purchase.order'
34
'customer_id': fields.many2one('res.partner', string='Customer', domain=[('customer', '=', True)]),
37
def create(self, cr, uid, vals, context=None):
39
override for debugging purpose
41
return super(purchase_order, self).create(cr, uid, vals, context)
43
def _check_order_type_and_partner(self, cr, uid, ids, context=None):
45
Check order type and partner type compatibilities.
48
'regular': ['internal', 'intermission', 'section', 'external', 'esc'],
49
'donation_st': ['internal', 'intermission', 'section'],
50
'loan': ['internal', 'intermission', 'section', 'external'],
51
'donation_exp': ['internal', 'intermission', 'section'],
52
'in_kind': ['external', 'esc'],
53
'direct': ['external', 'esc'],
54
'purchase_list': ['external'],
57
for po in self.browse(cr, uid, ids):
58
if po.order_type not in compats or po.partner_id.partner_type not in compats[po.order_type]:
64
_check_order_type_and_partner,
65
"Partner type and order type are incompatible! Please change either order type or partner.",
66
['order_type', 'partner_id'],
72
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: