diff --git a/addons/stock_picking_wave/security/ir.model.access.csv b/addons/stock_picking_wave/security/ir.model.access.csv index c33f87685bc..40168055609 100644 --- a/addons/stock_picking_wave/security/ir.model.access.csv +++ b/addons/stock_picking_wave/security/ir.model.access.csv @@ -1,3 +1,2 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_stock_picking_wave,stock.picking.wave stock users,model_stock_picking_wave,stock.group_stock_user,1,1,1,1 -access_stock_picking_wave_type,stock.picking.wave.type stock users,model_stock_picking_wave_type,stock.group_stock_user,1,1,1,1 +access_stock_picking_wave,stock.picking.wave stock users,model_stock_picking_wave,stock.group_stock_user,1,1,1,1 \ No newline at end of file diff --git a/addons/stock_picking_wave/stock_picking_wave.py b/addons/stock_picking_wave/stock_picking_wave.py index 33148cac6f0..50df7dd6d3e 100644 --- a/addons/stock_picking_wave/stock_picking_wave.py +++ b/addons/stock_picking_wave/stock_picking_wave.py @@ -7,23 +7,23 @@ class stock_picking_wave(osv.osv): _order = "name desc" _columns = { 'name': fields.char('name', required=True, help='Name of the picking wave'), - 'partner_id': fields.many2one('res.partner', 'Responsible', help='Person responsible for this wave'), + 'partner_id': fields.many2one('res.users', 'Responsible', help='Person responsible for this wave'), 'time': fields.float('Time', help='Time it will take to perform the wave'), 'picking_ids': fields.one2many('stock.picking', 'wave_id', 'Pickings', help='List of picking associated to this wave'), 'capacity': fields.float('Capacity', help='The capacity of the transport used to get the goods'), 'capacity_uom': fields.many2one('product.uom', 'Unit of Measure', help='The Unity Of Measure of the transport capacity'), - 'wave_type_id': fields.many2one('stock.picking.wave.type', 'Picking Wave Type'), - 'state': fields.selection([('in_progress', 'Running'), ('done', 'Done'), ('cancel', 'Cancelled')], required=True), + 'state': fields.selection([('draft', 'Draft'), ('in_progress', 'Running'), ('done', 'Done'), ('cancel', 'Cancelled')], required=True), } _defaults = { 'name': '/', - 'state': 'in_progress', + 'state': 'draft', } def confirm_picking(self, cr, uid, ids, context=None): picking_todo = self.pool.get('stock.picking').search(cr, uid, [('wave_id', 'in', ids)], context=context) - return self.pool.get('stock.picking').action_done(cr, uid, picking_todo, context=context) + self.write(cr, uid, ids, {'state': 'in_progress'}, context=context) + return self.pool.get('stock.picking').action_assign(cr, uid, picking_todo, context=context) def cancel_picking(self, cr, uid, ids, context=None): picking_todo = self.pool.get('stock.picking').search(cr, uid, [('wave_id', 'in', ids)], context=context) @@ -66,6 +66,14 @@ class stock_picking_wave(osv.osv): return super(stock_picking_wave, self).copy(cr, uid, id, default=default, context=context) def done(self, cr, uid, ids, context=None): + #done should only be called from one wave at a time + picking_todo = [] + for picking in self.browse(cr, uid, ids, context=context)[0].picking_ids: + if picking.state not in ('cancel', 'done', 'assigned'): + raise osv.except_osv(_('Warning'),_('Some pickings are still waiting for goods. Please check them before setting them to done')) + picking_todo.append(picking.id) + if picking_todo: + self.pool.get('stock.picking').action_done(cr, uid, picking_todo, context=context) return self.write(cr, uid, ids, {'state': 'done'}, context=context) @@ -73,17 +81,4 @@ class stock_picking(osv.osv): _inherit = "stock.picking" _columns = { 'wave_id': fields.many2one('stock.picking.wave', 'Picking Wave', help='Picking wave associated to this picking'), - 'wave_type_ids': fields.related('partner_id', 'wave_type_ids', type="many2many", relation='stock.picking.wave.type', string='Picking Wave Type'), - } - -class res_partner(osv.osv): - _inherit = 'res.partner' - _columns = { - 'wave_type_ids': fields.many2many('stock.picking.wave.type', 'stock_picking_wave_type_rel', 'wave_type_id', 'partner_id', 'Picking Wave Type'), - } - -class stock_picking_wave_type(osv.osv): - _name = 'stock.picking.wave.type' - _columns = { - 'name': fields.char('Type', required=True), } diff --git a/addons/stock_picking_wave/stock_picking_wave_demo.xml b/addons/stock_picking_wave/stock_picking_wave_demo.xml index ffcdeb4462c..0ef026422ec 100644 --- a/addons/stock_picking_wave/stock_picking_wave_demo.xml +++ b/addons/stock_picking_wave/stock_picking_wave_demo.xml @@ -1,18 +1,6 @@ - - - - Type Freeze - - - - Type Dry - - @@ -20,17 +8,14 @@ Picking Dry for John 15 - in_progress - - + in_progress Picking Freeze for Mickael 600 - in_progress - + in_progress