[FIX]picking_wave: rename partner_id into user_id and change method done to work with list of ids

bzr revid: csn@openerp.com-20140130105801-gi35yjv7yowrxaua
This commit is contained in:
Cedric Snauwaert 2014-01-30 11:58:01 +01:00
parent 9c41b91632
commit ca041ac631
2 changed files with 11 additions and 10 deletions

View File

@ -7,7 +7,7 @@ class stock_picking_wave(osv.osv):
_order = "name desc" _order = "name desc"
_columns = { _columns = {
'name': fields.char('name', required=True, help='Name of the picking wave'), 'name': fields.char('name', required=True, help='Name of the picking wave'),
'partner_id': fields.many2one('res.users', 'Responsible', help='Person responsible for this wave'), 'user_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'), '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'), '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': fields.float('Capacity', help='The capacity of the transport used to get the goods'),
@ -68,12 +68,13 @@ class stock_picking_wave(osv.osv):
def done(self, cr, uid, ids, context=None): def done(self, cr, uid, ids, context=None):
#done should only be called from one wave at a time #done should only be called from one wave at a time
picking_todo = [] picking_todo = []
for picking in self.browse(cr, uid, ids, context=context)[0].picking_ids: for wave in self.browse(cr, uid, ids, context=context):
if picking.state not in ('cancel', 'done', 'assigned'): for picking in wave.picking_ids:
raise osv.except_osv(_('Warning'),_('Some pickings are still waiting for goods. Please check them before setting them to done')) if picking.state not in ('cancel', 'done', 'assigned'):
picking_todo.append(picking.id) 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: if picking_todo:
self.pool.get('stock.picking').action_done(cr, uid, picking_todo, context=context) self.pool.get('stock.picking').action_done(cr, uid, list(set(picking_todo)), context=context)
return self.write(cr, uid, ids, {'state': 'done'}, context=context) return self.write(cr, uid, ids, {'state': 'done'}, context=context)

View File

@ -22,7 +22,7 @@
</div> </div>
<group> <group>
<group> <group>
<field name="partner_id"/> <field name="user_id"/>
</group> </group>
<group> <group>
<label for="capacity"/> <label for="capacity"/>
@ -59,7 +59,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Stock Picking Waves" colors="black:state in ('in_progress','done');grey: state=='cancel'"> <tree string="Stock Picking Waves" colors="black:state in ('in_progress','done');grey: state=='cancel'">
<field name="name"/> <field name="name"/>
<field name="partner_id"/> <field name="user_id"/>
<field name="capacity"/> <field name="capacity"/>
<field name="capacity_uom"/> <field name="capacity_uom"/>
<field name="time" widget="float_time"/> <field name="time" widget="float_time"/>
@ -75,9 +75,9 @@
<search string="Search Picking Waves"> <search string="Search Picking Waves">
<field name="name" string="Picking Wave"/> <field name="name" string="Picking Wave"/>
<filter name="in_progress" string="In Progress" domain="[('state','=', 'in_progress')]" help="Picking Waves not finished"/> <filter name="in_progress" string="In Progress" domain="[('state','=', 'in_progress')]" help="Picking Waves not finished"/>
<field name="partner_id"/> <field name="user_id"/>
<group expand="0" string="Group By..."> <group expand="0" string="Group By...">
<filter string="Partner" domain="[]" context="{'group_by':'partner_id'}"/> <filter string="User" domain="[]" context="{'group_by':'user_id'}"/>
<filter string="State" domain="[]" context="{'group_by':'state'}"/> <filter string="State" domain="[]" context="{'group_by':'state'}"/>
</group> </group>
</search> </search>