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

« back to all changes in this revision

Viewing changes to sale_picking_reservation/stock.py

  • Committer: sebastien beau
  • Date: 2011-11-14 14:57:34 UTC
  • mto: (5520.1.1 extra-trunk)
  • mto: This revision was merged to the branch mainline in revision 5522.
  • Revision ID: sebastien.beau@akretion.com.br-20111114145734-5ce7o9h8v0ch03td
[REF] refactor code in order to be compatible with 6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- encoding: utf-8 -*-
2
2
#################################################################################
3
3
#                                                                               #
4
 
#    sale_extended_workflow for OpenERP                                          #
 
4
#    sale_picking_reservation for OpenERP                                       #
5
5
#    Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>   #
6
6
#                                                                               #
7
7
#    This program is free software: you can redistribute it and/or modify       #
26
26
class stock_picking(osv.osv):
27
27
    
28
28
    _inherit = "stock.picking"
 
29
 
 
30
    _columns = {
 
31
        'reserved': fields.boolean('Reserved Picking', readonly=True),
 
32
    }
 
33
 
 
34
    _defaults = {
 
35
        'reserved': lambda *a: False,
 
36
    }
 
37
 
29
38
    
30
 
    def create(self, cr, uid, vals, context=None):
31
 
        picking_id = super(stock_picking, self).create(cr, uid, vals, context)
32
 
        if vals.get('sale_id', False) and self.pool.get('sale.order').search(cr, uid, [['reserved', '=', True], ['id', '=', vals['sale_id']]], context=context):
33
 
            wf_service = netsvc.LocalService("workflow")
34
 
            wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_reserve', cr)
35
 
        return picking_id
 
39
    def action_reserve(self, cr, uid, ids, context=None):
 
40
        """ Reserved picking.
 
41
        @return: True
 
42
        """
 
43
        self.write(cr, uid, ids, {'reserved' : True})
 
44
        todo = []
 
45
        for picking in self.browse(cr, uid, ids, context=context):
 
46
            for r in picking.move_lines:
 
47
                if r.state == 'draft':
 
48
                    todo.append(r.id)
 
49
 
 
50
        #self.log_picking(cr, uid, ids, context=context)
 
51
 
 
52
        todo = self.action_explode(cr, uid, todo, context)
 
53
        if len(todo):
 
54
            self.pool.get('stock.move').action_confirm(cr, uid, todo, context=context)
 
55
        return True
36
56
 
37
57
stock_picking()