From 5b66d394db82f91414663efbd00fb08837c81654 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Thu, 27 Jun 2013 11:43:56 +0200 Subject: [PATCH 1/6] [ADD]module picking_wave, an object that group several stock.picking object and can confirm or cancel them altogether bzr revid: csn@openerp.com-20130627094356-w4fn3as89lbu0mb0 --- addons/picking_wave/__init__.py | 24 ++++++ addons/picking_wave/__openerp__.py | 39 +++++++++ addons/picking_wave/picking_wave.py | 52 ++++++++++++ addons/picking_wave/picking_wave_view.xml | 82 +++++++++++++++++++ .../picking_wave/security/ir.model.access.csv | 2 + 5 files changed, 199 insertions(+) create mode 100644 addons/picking_wave/__init__.py create mode 100644 addons/picking_wave/__openerp__.py create mode 100644 addons/picking_wave/picking_wave.py create mode 100644 addons/picking_wave/picking_wave_view.xml create mode 100644 addons/picking_wave/security/ir.model.access.csv diff --git a/addons/picking_wave/__init__.py b/addons/picking_wave/__init__.py new file mode 100644 index 00000000000..83928b4b941 --- /dev/null +++ b/addons/picking_wave/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import picking_wave + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/picking_wave/__openerp__.py b/addons/picking_wave/__openerp__.py new file mode 100644 index 00000000000..e42a8ca0e9c --- /dev/null +++ b/addons/picking_wave/__openerp__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'Picking Waves', + 'version': '1.0', + 'category': 'Stock Management', + 'description': """ +This module adds the picking wave option in warehouse management. +================================================================= + """, + 'author': 'OpenERP SA', + 'website': 'http://www.openerp.com', + 'depends': ['stock'], + 'data': ['security/ir.model.access.csv', + 'picking_wave_view.xml'], + 'demo': [], + 'installable': True, + 'auto_install': True, +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/picking_wave/picking_wave.py b/addons/picking_wave/picking_wave.py new file mode 100644 index 00000000000..3e61342183c --- /dev/null +++ b/addons/picking_wave/picking_wave.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +from openerp.tools.translate import _ +from openerp.osv import fields, osv +from openerp import workflow + +class picking_wave(osv.osv): + _name = "picking.wave" + _columns = { + 'name': fields.char('name', required=True, help='Name of the picking wave'), + 'resp_id': fields.many2one('res.partner', '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'), + } + + 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) + self.pool.get('stock.picking').wave_confirm_picking(cr, uid, picking_todo, context=context) + return True + + 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) + self.pool.get('stock.picking').wave_cancel_picking(cr, uid, picking_todo, context=context) + return True + + +class stock_picking(osv.osv): + _inherit = "stock.picking" + _columns = { + 'wave_id': fields.many2one('picking.wave', 'Picking Wave', help='Picking wave associated to this picking'), + } + + def wave_confirm_picking(self, cr, uid, ids, context=None): + """Set all stocks moves associated to this picking to done state and if picking is in draft, + advance workflow to confirmed (which mean that it will afterwards automatically go to done) + """ + move_obj = self.pool.get('stock.move') + for picking in self.browse(cr, uid, ids, context=context): + if picking.state == 'draft': + workflow.trg_validate(uid, 'stock.picking', picking.id, 'button_confirm', cr) + + moves_todo = move_obj.search(cr, uid, [('picking_id', 'in', ids)], context=context) + move_obj.action_done(cr, uid, moves_todo, context=context) + return True + + def wave_cancel_picking(self, cr, uid, ids, context=None): + """Cancel the pickings and all stock move associated + """ + for id in ids: + workflow.trg_validate(uid, 'stock.picking', id, 'button_cancel', cr) + return True \ No newline at end of file diff --git a/addons/picking_wave/picking_wave_view.xml b/addons/picking_wave/picking_wave_view.xml new file mode 100644 index 00000000000..5f2a27183ce --- /dev/null +++ b/addons/picking_wave/picking_wave_view.xml @@ -0,0 +1,82 @@ + + + + picking.wave.form + picking.wave + +
+ +
+
+ + + + + + + + + + + + + + + + + + + +