~openerp-commiter/openobject-addons/trunk-extra-addons

« back to all changes in this revision

Viewing changes to purchase_delivery/delivery.py

  • Committer: Harshad Modi
  • Date: 2008-03-29 09:20:28 UTC
  • Revision ID: hmo@tinyerp.com-ef1523b03713a254c1242af83490a352b25ff31f
*** account_journal_visibility ***: 
when we open the journals list, people will only see journal for which they are allowed (means their group is specified on the journal definition). and also Only people in the group defined on the journal will be able to see the invoices of this journal.

*** mrp_production_report ***:
 Add partner on procurement form which set when Sale order confirm , Add link between production and procument , New report for production.

*** stock_back_order ***: 
To manage all back-orders (means partial pickings):  When products coming from suppliers arrive but some are missing, we have to make a partial picking. The remaining products are called "back-orders" and have to be separated from normal waiting picking (in a predefined list called "Back-Orders"). The same process has to be done for sending goods.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##############################################################################
 
2
#
 
3
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
 
4
#                    Fabien Pinckaers <fp@tiny.Be>
 
5
#
 
6
# WARNING: This program as such is intended to be used by professional
 
7
# programmers who take the whole responsability of assessing all potential
 
8
# consequences resulting from its eventual inadequacies and bugs
 
9
# End users who are looking for a ready-to-use solution with commercial
 
10
# garantees and support are strongly adviced to contract a Free Software
 
11
# Service Company
 
12
#
 
13
# This program is Free Software; you can redistribute it and/or
 
14
# modify it under the terms of the GNU General Public License
 
15
# as published by the Free Software Foundation; either version 2
 
16
# of the License, or (at your option) any later version.
 
17
#
 
18
# This program is distributed in the hope that it will be useful,
 
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
# GNU General Public License for more details.
 
22
#
 
23
# You should have received a copy of the GNU General Public License
 
24
# along with this program; if not, write to the Free Software
 
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
26
#
 
27
##############################################################################
 
28
 
 
29
import netsvc
 
30
from osv import fields,osv,orm
 
31
 
 
32
class delivery_grid(osv.osv):
 
33
        _name = "delivery.grid"
 
34
        _inherit = "delivery.grid"
 
35
 
 
36
        def get_price(self, cr, uid, id, order, dt, context):
 
37
                """
 
38
                This is not very clean because the function has to check the type of order.
 
39
                It could be improve by changing the signature of the method and by passing a dict in place of a browse record.
 
40
                """
 
41
                total = 0
 
42
                weight = 0
 
43
                volume = 0
 
44
 
 
45
                for line in order.order_line:
 
46
                        if not line.product_id:
 
47
                                continue
 
48
                        qty = 0.0
 
49
                        
 
50
                        if order._table_name == "sale.order":
 
51
                                qty = line.product_uom_qty
 
52
                        else:
 
53
                                qty = line.product_qty
 
54
 
 
55
                        total += line.price_subtotal or 0.0
 
56
                        weight += (line.product_id.weight or 0.0) * qty
 
57
                        volume += (line.product_id.volume or 0.0) * qty
 
58
 
 
59
                return self.get_price_from_picking(cr, uid, id, total,weight, volume, context)
 
60
 
 
61
        def get_price_from_picking(self, cr, uid, id, total, weight, volume, context={}):
 
62
                grid = self.browse(cr, uid, id, context)
 
63
 
 
64
                price = 0.0
 
65
                ok = False
 
66
 
 
67
                for line in grid.line_ids:
 
68
                        price_dict = {'price': total, 'volume':volume, 'weight': weight, 'wv':volume*weight}
 
69
                        test = eval(line.type+line.operator+str(line.max_value), price_dict)
 
70
                        if test:
 
71
                                if context.has_key('object') and context['object']=='purchase':
 
72
                                        price = line.standard_price
 
73
                                else:
 
74
                                        price = line.list_price
 
75
                                if line.price_type=='variable':
 
76
                                        price *= price_dict[line.variable_factor]
 
77
                                ok = True
 
78
                                break
 
79
                if not ok:
 
80
                        raise except_osv('No price avaible !', 'No line matched this order in the choosed delivery grids !')
 
81
                return price
 
82
 
 
83
delivery_grid()