[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
This commit is contained in:
Cedric Snauwaert 2013-06-27 11:43:56 +02:00
parent c180afab26
commit 5b66d394db
5 changed files with 199 additions and 0 deletions

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import picking_wave
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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:

View File

@ -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

View File

@ -0,0 +1,82 @@
<openerp>
<data>
<record id="view_picking_wave_form" model="ir.ui.view">
<field name="name">picking.wave.form</field>
<field name="model">picking.wave</field>
<field name="arch" type="xml">
<form string="Stock Inventory Lines" version="7.0">
<sheet>
<div class="oe_right oe_button_box">
<button name="confirm_picking" string="Confirm all pickings" type="object"/>
<button name="cancel_picking" string="Cancel all pickings" type="object"/>
</div>
<group>
<group>
<field name="name"/>
<field name="resp_id"/>
</group>
<group>
<label for="capacity"/>
<div>
<field name="capacity" class="oe_inline"/>
<field name="capacity_uom" class="oe_inline"/>
</div>
<field name="time" widget="float_time"/>
</group>
</group>
<separator string="Pickings"/>
<field name="picking_ids" widget="many2many">
<tree>
<field name="name"/>
<field name="backorder_id"/>
<field name="origin"/>
<field name="date"/>
<field name="min_date"/>
<field name="invoice_state"/>
<field name="stock_journal_id" widget="selection"/>
<field name="state"/>
<button name="wave_confirm_picking" string="Confirm picking" type="object" icon="gtk-apply" attrs="{'invisible': [('state', 'in', ('done', 'cancel'))]}"/>
<button name="wave_cancel_picking" string="Cancel picking" type="object" icon="gtk-cancel" attrs="{'invisible': [('state', 'in', ('done', 'cancel'))]}"/>
</tree>
</field>
</sheet>
</form>
</field>
</record>
<record id="view_picking_wave_tree" model="ir.ui.view">
<field name="name">picking.wave.tree</field>
<field name="model">picking.wave</field>
<field name="arch" type="xml">
<tree string="Picking Waves">
<field name="name"/>
<field name="resp_id"/>
<field name="capacity"/>
<field name="capacity_uom"/>
<field name="time" widget="float_time"/>
</tree>
</field>
</record>
<record id="action_picking_wave" model="ir.actions.act_window">
<field name="name">Picking Waves</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">picking.wave</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a Picking Wave.
</p><p>
The Goal of the picking waves is to group operations that may
(needs to) be done together in order to increase their efficiency.
It may also be useful to assign jobs (one person = one wave) or
help the timing management of operations (tasks to be done at 1pm).
</p>
</field>
</record>
<menuitem action="action_picking_wave" id="menu_action_picking_wave" parent="stock.menu_stock_warehouse_mgmt" sequence="30"/>
</data>
</openerp>

View File

@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
picking_wave,picking.wave,model_picking_wave,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 picking_wave picking.wave model_picking_wave base.group_user 1 1 1 1