});
this.$('.js_create_lot').click(function(){
var op_id = $(this).parents("[data-id]:first").data('id');
- self.getParent().create_lot(op_id);
+ var lot_name = false;
+ self.$('.js_lot_scan').val('');
+ var $lot_modal = self.$el.siblings('#js_LotChooseModal');
+ self.getParent().barcode_scanner.disconnect();
+ $lot_modal.modal()
+ //focus input
+ $lot_modal.on('shown.bs.modal', function(){
+ self.$('.js_lot_scan').focus();
+ })
+ self.$('.js_lot_scan').focus();
+ //button action
+ self.$('.js_validate_lot').click(function(){
+ //get content of input
+ var name = self.$('.js_lot_scan').val();
+ if (name.length !== 0){
+ lot_name = name;
+ }
+ self.getParent().barcode_scanner.connect(function(ean){
+ self.getParent().scan(ean);
+ });
+ $lot_modal.modal('hide');
+ self.getParent().create_lot(op_id, lot_name);
+ });
});
this.$('.js_delete_pack').click(function(){
var pack_id = $(this).parents("[data-id]:first").data('id');
}
});
},
- create_lot: function(op_id){
+ create_lot: function(op_id, lot_name){
var self = this;
new instance.web.Model('stock.pack.operation')
- .call('create_and_assign_lot',[parseInt(op_id)])
+ .call('create_and_assign_lot',[parseInt(op_id), lot_name])
.then(function(){
return self.refresh_ui(self.picking.id);
});
</div>
</div>
+ <div class="modal fade" id="js_LotChooseModal" tabindex="-1" role="dialog" aria-labelledby="LotChooseModal" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
+ <h4 class="modal-title" id="myModalLabel">Create Lot</h4>
+ </div>
+ <div class="modal-body">
+ <p>Scan a lot or type it below (leave empty to generate one automatically)</p>
+ <input class='col-xs-6 js_lot_scan' type='text'/>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ <button type="button" class="btn btn-primary js_validate_lot">Create Lot</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
<div class="row">
<div>
<div class="col-sm-4 col-xs-6">
processed_ids.append(op)
self.write(cr, uid, processed_ids, {'processed': 'true'}, context=context)
- def create_and_assign_lot(self, cr, uid, id, context=None):
+ def create_and_assign_lot(self, cr, uid, id, name, context=None):
''' Used by barcode interface to create a new lot and assign it to the operation
'''
obj = self.browse(cr,uid,id,context)
product_id = obj.product_id.id
+ val = {'product_id': product_id}
+ if name:
+ val.update({'name': name})
if not obj.lot_id:
- new_lot_id = self.pool.get('stock.production.lot').create(cr, uid, {'product_id': product_id}, context=context)
+ new_lot_id = self.pool.get('stock.production.lot').create(cr, uid, val, context=context)
self.write(cr, uid, id, {'lot_id': new_lot_id}, context=context)
def _search_and_increment(self, cr, uid, picking_id, domain, filter_visible=False ,visible_op_ids=False, increment=True, context=None):