~openbias/bias-trunk/bias-public-trunk

« back to all changes in this revision

Viewing changes to bias_partner_address_pricelist/sale.py

  • Committer: Jose Patricio
  • Date: 2011-10-19 03:16:40 UTC
  • Revision ID: josepato@bias.com.mx-20111019031640-05zd7r5lxwx084qu
el push inicial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
from datetime import datetime, timedelta
 
23
from dateutil.relativedelta import relativedelta
 
24
import time
 
25
 
 
26
from osv import fields, osv
 
27
from tools.translate import _
 
28
import decimal_precision as dp
 
29
import netsvc
 
30
 
 
31
class sale_order(osv.osv):
 
32
    _inherit = "sale.order"
 
33
 
 
34
    def onchange_partner_id(self, cr, uid, ids, part):
 
35
        if not 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
 
43
        return res
 
44
 
 
45
    def onchange_partner_shipping_id(self, cr, uid, ids, shipping):
 
46
        if not shipping:
 
47
            return {}
 
48
        val = {}
 
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}
 
52
        return {'value': val}
 
53
 
 
54
sale_order()
 
55
 
 
56
 
 
57
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: