2
# -*- coding: utf-8 -*-
3
##############################################################################
5
# OpenERP, Open Source Management Solution
6
# Copyright (C) 2012 TeMPO Consulting, MSF. All Rights Reserved
7
# Developer: Olivier DOSSMANN
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU Affero General Public License as
11
# published by the Free Software Foundation, either version 3 of the
12
# License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU Affero General Public License for more details.
19
# You should have received a copy of the GNU Affero General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
##############################################################################
26
class purchase_order(osv.osv):
27
_name = 'purchase.order'
28
_inherit = 'purchase.order'
30
def create(self, cr, uid, vals, context=None):
32
Change invoice method for in-kind donation PO to 'order' after its creation
36
res = super(purchase_order, self).create(cr, uid, vals, context)
37
if vals.get('order_type', False) and vals.get('order_type') == 'in_kind':
38
vals.update({'invoice_method': 'picking'})
42
def write(self, cr, uid, ids, vals, context=None):
44
Change invoice method for in-kind donation PO after a write
48
res = super(purchase_order, self).write(cr, uid, ids, vals, context)
49
if vals.get('order_type', False) and vals.get('order_type') == 'in_kind':
50
cr.execute("UPDATE purchase_order SET invoice_method = 'picking' WHERE id in %s", (tuple(ids),))
53
def onchange_internal_type(self, cr, uid, ids, order_type, partner_id, categ, dest_partner_id=False, warehouse_id=False, delivery_requested_date=False):
55
Change invoice method for in-kind donation
57
res = super(purchase_order, self).onchange_internal_type(cr, uid, ids, order_type, partner_id, categ, dest_partner_id, warehouse_id, delivery_requested_date)
58
if order_type in ['in_kind']:
59
v = res.get('value', {})
60
v.update({'invoice_method': 'picking'})
61
res.update({'value': v})
65
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: