[IMP] stock: some minor changes made during code review
bzr revid: qdp-launchpad@openerp.com-20140401093127-j2adv1ljm7th7vyt
This commit is contained in:
parent
8631692023
commit
e6249680c1
|
@ -611,9 +611,11 @@ function openerp_picking_widgets(instance){
|
|||
}).then(function(){
|
||||
return new instance.web.Model('stock.picking').call('check_group_pack').then(function(result){
|
||||
return self.show_pack = result;
|
||||
|
||||
});
|
||||
|
||||
}).then(function(){
|
||||
return new instance.web.Model('stock.picking').call('check_group_lot').then(function(result){
|
||||
return self.show_lot = result;
|
||||
});
|
||||
}).then(function(){
|
||||
if (self.picking.pack_operation_exist === false){
|
||||
self.picking.recompute_pack_op = false;
|
||||
|
@ -687,6 +689,9 @@ function openerp_picking_widgets(instance){
|
|||
if (!self.show_pack){
|
||||
self.$('.js_pick_pack').addClass('hidden');
|
||||
}
|
||||
if (!self.show_lot){
|
||||
self.$('.js_create_lot').addClass('hidden');
|
||||
}
|
||||
|
||||
}).fail(function(error) {console.log(error);});
|
||||
|
||||
|
@ -710,6 +715,9 @@ function openerp_picking_widgets(instance){
|
|||
if (!self.show_pack){
|
||||
self.$('.js_pick_pack').addClass('hidden');
|
||||
}
|
||||
if (!self.show_lot){
|
||||
self.$('.js_create_lot').addClass('hidden');
|
||||
}
|
||||
if (self.picking.recompute_pack_op){
|
||||
self.$('.js_reload_op').removeClass('hidden');
|
||||
}
|
||||
|
|
|
@ -221,8 +221,8 @@
|
|||
|
||||
<div class="container">
|
||||
<div class='oe_placeholder_picking_editor'/>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-default js_reload_op">Recompute operations</button>
|
||||
<div class="text-right small">
|
||||
The reserved stock changed. You might want to <button class="btn btn-default js_reload_op"> Recompute </button> the operations.
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
|
|
@ -329,9 +329,9 @@ class stock_quant(osv.osv):
|
|||
#reserve quants
|
||||
if toreserve:
|
||||
self.write(cr, SUPERUSER_ID, toreserve, {'reservation_id': move.id}, context=context)
|
||||
#if move has a picking_id, write on that picking that pack_operation might have change and need to be recompute
|
||||
#if move has a picking_id, write on that picking that pack_operation might have changed and need to be recomputed
|
||||
if move.picking_id:
|
||||
self.pool.get('stock.picking').write(cr, uid, [move.picking_id.id], {'recompute_pack_op':True}, context=context)
|
||||
self.pool.get('stock.picking').write(cr, uid, [move.picking_id.id], {'recompute_pack_op': True}, context=context)
|
||||
#check if move'state needs to be set as 'assigned'
|
||||
if reserved_availability == move.product_qty and move.state in ('confirmed', 'waiting'):
|
||||
self.pool.get('stock.move').write(cr, uid, [move.id], {'state': 'assigned'}, context=context)
|
||||
|
@ -537,9 +537,9 @@ class stock_quant(osv.osv):
|
|||
def quants_unreserve(self, cr, uid, move, context=None):
|
||||
related_quants = [x.id for x in move.reserved_quant_ids]
|
||||
if related_quants:
|
||||
#if move has a picking_id, write on that picking that pack_operation might have change and need to be recompute
|
||||
#if move has a picking_id, write on that picking that pack_operation might have changed and need to be recomputed
|
||||
if move.picking_id:
|
||||
self.pool.get('stock.picking').write(cr, uid, [move.picking_id.id], {'recompute_pack_op':True}, context=context)
|
||||
self.pool.get('stock.picking').write(cr, uid, [move.picking_id.id], {'recompute_pack_op': True}, context=context)
|
||||
if move.partially_available:
|
||||
self.pool.get("stock.move").write(cr, uid, [move.id], {'partially_available': False}, context=context)
|
||||
return self.write(cr, SUPERUSER_ID, related_quants, {'reservation_id': False}, context=context)
|
||||
|
@ -731,20 +731,25 @@ class stock_picking(osv.osv):
|
|||
continue
|
||||
return res
|
||||
|
||||
def check_group_pack(self, cr, uid, context=None):
|
||||
"""
|
||||
This function will return true if we have the setting to use package activated
|
||||
"""
|
||||
def check_group_lot(self, cr, uid, context=None):
|
||||
""" This function will return true if we have the setting to use lots activated. """
|
||||
settings_obj = self.pool.get('stock.config.settings')
|
||||
config_ids = settings_obj.search(cr, uid, [], limit=1, order='id DESC', context=context)
|
||||
#If we don't have updated config until now, all fields are by default false and so should be not dipslayed
|
||||
if not config_ids:
|
||||
return False
|
||||
|
||||
stock_settings = settings_obj.browse(cr, uid, config_ids[0], context=context)
|
||||
if stock_settings.group_stock_tracking_lot:
|
||||
return True
|
||||
return False
|
||||
return stock_settings.group_stock_production_lot
|
||||
|
||||
def check_group_pack(self, cr, uid, context=None):
|
||||
""" This function will return true if we have the setting to use package activated. """
|
||||
settings_obj = self.pool.get('stock.config.settings')
|
||||
config_ids = settings_obj.search(cr, uid, [], limit=1, order='id DESC', context=context)
|
||||
#If we don't have updated config until now, all fields are by default false and so should be not dipslayed
|
||||
if not config_ids:
|
||||
return False
|
||||
stock_settings = settings_obj.browse(cr, uid, config_ids[0], context=context)
|
||||
return stock_settings.group_stock_tracking_lot
|
||||
|
||||
def action_assign_owner(self, cr, uid, ids, context=None):
|
||||
for picking in self.browse(cr, uid, ids, context=context):
|
||||
|
@ -795,7 +800,7 @@ class stock_picking(osv.osv):
|
|||
'owner_id': fields.many2one('res.partner', 'Owner', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, help="Default Owner"),
|
||||
# Used to search on pickings
|
||||
'product_id': fields.related('move_lines', 'product_id', type='many2one', relation='product.product', string='Product'),
|
||||
'recompute_pack_op': fields.boolean('Recompute pack operation?', help='True if quants has changed and we might need to recompute the package operations'),
|
||||
'recompute_pack_op': fields.boolean('Recompute pack operation?', help='True if reserved quants changed, which mean we might need to recompute the package operations'),
|
||||
'location_id': fields.related('move_lines', 'location_id', type='many2one', relation='stock.location', string='Location', readonly=True),
|
||||
'location_dest_id': fields.related('move_lines', 'location_dest_id', type='many2one', relation='stock.location', string='Destination Location', readonly=True),
|
||||
'group_id': fields.related('move_lines', 'group_id', type='many2one', relation='procurement.group', string='Procurement Group', readonly=True,
|
||||
|
@ -876,8 +881,8 @@ class stock_picking(osv.osv):
|
|||
for pick in self.browse(cr, uid, ids, context=context):
|
||||
move_ids = [x.id for x in pick.move_lines if x.state in ['confirmed', 'waiting']]
|
||||
self.pool.get('stock.move').force_assign(cr, uid, move_ids, context=context)
|
||||
#pack_operation might have change and need to be recompute
|
||||
self.write(cr, uid, ids, {'recompute_pack_op':True}, context=context)
|
||||
#pack_operation might have changed and need to be recomputed
|
||||
self.write(cr, uid, ids, {'recompute_pack_op': True}, context=context)
|
||||
return True
|
||||
|
||||
def action_cancel(self, cr, uid, ids, context=None):
|
||||
|
@ -1121,7 +1126,7 @@ class stock_picking(osv.osv):
|
|||
pack_operation_obj.create(cr, uid, vals, context=ctx)
|
||||
#recompute the remaining quantities all at once
|
||||
self.do_recompute_remaining_quantities(cr, uid, picking_ids, context=context)
|
||||
self.write(cr, uid, picking_ids, {'recompute_pack_op':False}, context=context)
|
||||
self.write(cr, uid, picking_ids, {'recompute_pack_op': False}, context=context)
|
||||
|
||||
def do_unreserve(self, cr, uid, picking_ids, context=None):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue