|
@@ -94,7 +94,7 @@ class stock_transfer_details(models.TransientModel):
|
|
|
'company_id': self.env.user.company_id.id,
|
|
|
'date': now.strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
'date_expected': now.strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
- 'invoice_state':'none'
|
|
|
+ 'invoice_state':'none',
|
|
|
}
|
|
|
move_id = self.env['stock.move'].create(move)
|
|
|
move_id.action_done()
|
|
@@ -199,5 +199,28 @@ class stock_picking(models.Model):
|
|
|
def entregar_producto(self):
|
|
|
for item in self:
|
|
|
for move in item.move_lines:
|
|
|
+ if move.product_id.type == 'product':
|
|
|
+ uom_record = move.product_id.uom_id
|
|
|
+ qty_available = self.get_location_qty(move.product_id.id, move.location_id.id, move.picking_type_id.id)
|
|
|
+ compare_qty = float_compare(qty_available, move.product_uom_qty, precision_rounding=uom_record.rounding)
|
|
|
+
|
|
|
+ if compare_qty == -1:
|
|
|
+ warn_msg = _('Estas intentando transferir %.2f %s de %s pero el almacén de origen posee %.2f %s disponible!') % \
|
|
|
+ (move.product_uom_qty, uom_record.name,
|
|
|
+ move.product_id.name,
|
|
|
+ max(0,qty_available), uom_record.name)
|
|
|
+ raise Warning(_("No hay stock suficiente: "),_(warn_msg))
|
|
|
move.action_done()
|
|
|
return True
|
|
|
+
|
|
|
+ @api.multi
|
|
|
+ def get_location_qty(self, product_id, location_id, picking_type_id):
|
|
|
+ picking_type = self.env['stock.picking.type'].browse(picking_type_id)
|
|
|
+ location_ids = self.env['stock.location'].search([('active','=',True),('usage','=','internal'),('id','!=',picking_type.default_location_dest_id.id)])
|
|
|
+ for id in location_ids:
|
|
|
+ suma = 0
|
|
|
+ quant_ids = self.env['stock.quant'].search([('product_id','=', product_id),('location_id','=',location_id)])
|
|
|
+ if quant_ids:
|
|
|
+ for quant_id in quant_ids:
|
|
|
+ suma = suma + quant_id.qty
|
|
|
+ return suma
|