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

« back to all changes in this revision

Viewing changes to stock_supplier_average_price/wizard/stock_partial_picking.py

  • Committer: Jordi Esteve
  • Date: 2012-03-02 19:04:40 UTC
  • Revision ID: jesteve@zikzakmedia.com-20120302190440-ntk0hlxcn7afnqnx
[ADD] stock_supplier_average_price: This module adds cost price in the Process Wizard of the Supplier Return Picking, and remove it in the Process Wizard of the Customer Return Picking. Also modifies the default formula used in OpenERP to compute the new average price of a product in stock in returned pickings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution
 
5
#    Copyright (c) 2012 Zikzakmedia S.L. (http://zikzakmedia.com)
 
6
#                       All Rights Reserved.
 
7
#                       Jordi Esteve <jesteve@zikzakmedia.com>
 
8
#                       Jesús Martín <jmartin@zikzakmedia.com>
 
9
#    $Id$
 
10
#
 
11
#    This program is free software: you can redistribute it and/or modify
 
12
#    it under the terms of the GNU Affero General Public License as published by
 
13
#    the Free Software Foundation, either version 3 of the License, or
 
14
#    (at your option) any later version.
 
15
#
 
16
#    This program is distributed in the hope that it will be useful,
 
17
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
#    GNU Affero General Public License for more details.
 
20
#
 
21
#    You should have received a copy of the GNU Affero General Public License
 
22
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
23
#
 
24
##############################################################################
 
25
 
 
26
from osv import osv
 
27
 
 
28
class stock_partial_picking(osv.osv_memory):
 
29
    _inherit = "stock.partial.picking"
 
30
 
 
31
    def get_picking_type(self, cr, uid, picking, context=None):
 
32
        picking_type = picking.type
 
33
        return_picking = picking.name and '-return' in picking.name or False
 
34
        for move in picking.move_lines:
 
35
            if picking.type == 'in' and move.product_id.cost_method == \
 
36
                                            'average' and not return_picking:
 
37
                picking_type = 'in'
 
38
                break
 
39
            elif picking.type == 'out' and move.product_id.cost_method == \
 
40
                                            'average' and return_picking:
 
41
                picking_type = 'in'
 
42
                break
 
43
            else:
 
44
                picking_type = 'out'
 
45
        return picking_type
 
46
 
 
47
stock_partial_picking()