1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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 datetime import datetime, timedelta
23
from dateutil.relativedelta import relativedelta
26
from osv import fields, osv
27
from tools.translate import _
28
import decimal_precision as dp
31
class sale_order(osv.osv):
32
_inherit = "sale.order"
34
def onchange_partner_id(self, cr, uid, ids, part):
36
return super(sale_order, self).onchange_partner_id(cr, uid, ids, part)
37
res = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)
38
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery', 'invoice', 'contact'])
39
part = self.pool.get('res.partner').browse(cr, uid, part)
40
delivery = self.pool.get('res.partner.address').browse(cr, uid, addr['delivery'])
41
if delivery.property_product_pricelist:
42
res['value']['pricelist_id'] = delivery.property_product_pricelist.id
45
def onchange_partner_shipping_id(self, cr, uid, ids, shipping):
49
delivery = self.pool.get('res.partner.address').browse(cr, uid, shipping)
50
if delivery.property_product_pricelist:
51
val = {'pricelist_id': delivery.property_product_pricelist.id}
57
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: