~domsense/stock-logistic-flows/adding_7.0_stock_move_backdating

« back to all changes in this revision

Viewing changes to picking_dispatch/picking_dispatch.py

[MRG] picking dispatch improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
            return result
46
46
        for dispatch_id in ids:
47
47
            result[dispatch_id] = []
48
 
        sql = ("SELECT sm.dispatch_id, sm.picking_id FROM stock_move sm "
 
48
        sql = ("SELECT DISTINCT sm.dispatch_id, sm.picking_id FROM stock_move sm "
49
49
              "WHERE sm.dispatch_id in %s AND sm.picking_id is NOT NULL")
50
50
        cr.execute(sql, (tuple(ids),))
51
51
        res = cr.fetchall()
54
54
        return result
55
55
 
56
56
    _columns  = {
57
 
        'name': fields.char('Name', size=64, required=True, select=True,
 
57
        'name': fields.char('Name', size=96, required=True, select=True,
58
58
                            states={'draft': [('readonly', False)]}, unique=True,
59
59
                            help='Name of the picking dispatch'),
60
60
        'date': fields.date('Date', required=True, readonly=True, select=True,
61
 
                            states={'draft': [('readonly', False)]},
 
61
                            states={'draft': [('readonly', False)],
 
62
                                    'assigned': [('readonly', False)]},
62
63
                            help='date on which the picking dispatched is to be processed'),
63
64
        'picker_id': fields.many2one('res.users', 'Picker', readonly=True, required=True,
64
 
                            states={'draft': [('readonly', False)]}, select=True,
65
 
                            help='the user to which the pickings are assigned'),
 
65
                                     states={'draft': [('readonly', False)],
 
66
                                             'assigned': [('readonly', False)]},
 
67
                                     select=True,
 
68
                                     help='the user to which the pickings are assigned'),
66
69
        'move_ids': fields.one2many('stock.move', 'dispatch_id', 'Moves',
67
70
                                    states={'draft': [('readonly', False)]},
68
71
                                    readonly=True,
69
72
                                    help='the list of moves to be processed'),
 
73
        'notes': fields.text('Notes', help='free form remarks'),
70
74
        'backorder_id': fields.many2one('picking.dispatch', 'Back Order of',
71
75
                                        help='if this dispatch was split, this links to the dispatch order containing the other part which was processed',
72
76
                                        select=True),
199
203
        for dispatch_id, move_ids in maybe_finished_dispatches.iteritems():
200
204
            move_obj.write(cr, uid, move_ids, {'dispatch_id': dispatch_id})
201
205
        dispatch_obj.check_finished(cr, uid, list(maybe_finished_dispatches), context)
 
206
        dispatch_obj.write(cr, uid, list(unfinished_dispatch_ids), {'state': 'assigned'})
202
207
        return complete_move_ids
203
208
 
204
209
 
227
232
 
228
233
    def action_done(self, cr, uid, ids, context=None):
229
234
        """
230
 
        in addition to the parent method does, set the dispatch done if all moves are done or cancelled
 
235
        in addition to the parent method does, set the dispatch done if all moves are done or canceled
231
236
        """
232
237
        _logger.debug('done stock.moves %s', ids)
233
238
        status = super(StockMove, self).action_done(cr, uid, ids, context)
274
279
        }
275
280
 
276
281
 
 
282
 
 
283
class res_company(Model):
 
284
    _name = 'res.company'
 
285
    _inherit = 'res.company'
 
286
    _columns = {
 
287
        'default_picker_id': fields.many2one('res.users', 'Default Picker',
 
288
                                          help='the user to which the pickings are assigned by default',
 
289
                                          select=True),
 
290
        }