|
@@ -20,9 +20,21 @@ class stock_transfer_details(models.TransientModel):
|
|
|
else:
|
|
|
raise Warning(_('No existe un tipo de transferencia adecuado para esta operación'))
|
|
|
|
|
|
+
|
|
|
+
|
|
|
picking_type_id = fields.Many2one('stock.picking.type', 'Tipo de transferencia', default=_get_picking_type, required=True)
|
|
|
- picking_source_location_id = fields.Many2one('stock.location', string="Head source location", related='picking_type_id.default_location_src_id', store=False, readonly=True)
|
|
|
- picking_destination_location_id = fields.Many2one('stock.location', string="Head destination location", related='picking_type_id.default_location_dest_id', store=False, readonly=True)
|
|
|
+ picking_source_warehouse_id = fields.Many2one('stock.warehouse', string="Head source location", compute="getWarehouse", store=True)
|
|
|
+ picking_destination_warehouse_id = fields.Many2one('stock.warehouse', string="Head destination location", compute="getWarehouse", store=True)
|
|
|
+
|
|
|
+ @api.one
|
|
|
+ @api.depends('picking_type_id')
|
|
|
+ def getWarehouse(self):
|
|
|
+ for rec in self:
|
|
|
+ warehouse_origen = self.env['stock.warehouse'].search([('lot_stock_id','=',self.picking_type_id.default_location_src_id.id)])
|
|
|
+ warehouse_dest = self.env['stock.warehouse'].search([('lot_stock_id','=',self.picking_type_id.default_location_dest_id.id)])
|
|
|
+ self.picking_source_warehouse_id = warehouse_origen.id,
|
|
|
+ self.picking_destination_warehouse_id = warehouse_dest.id
|
|
|
+
|
|
|
|
|
|
|
|
|
@api.multi
|
|
@@ -112,8 +124,10 @@ class stock_transfer_details_items(models.TransientModel):
|
|
|
product_uom_id = fields.Many2one('product.uom', 'Unidad de medida')
|
|
|
quantity = fields.Float('Cantidad', digits=dp.get_precision('Product Unit of Measure'), default = 1.0)
|
|
|
price_unit = fields.Float('Precio Unitario')
|
|
|
- sourceloc_id = fields.Many2one('stock.location', 'Ubicación Origen',required=True)
|
|
|
- destinationloc_id = fields.Many2one('stock.location', 'Ubicación Destino',required=True)
|
|
|
+ source_warehouse = fields.Many2one('stock.warehouse', 'Déposito Origen')
|
|
|
+ dest_warehouse = fields.Many2one('stock.warehouse', 'Déposito Destino')
|
|
|
+ sourceloc_id = fields.Many2one('stock.location', 'Ubicación Origen', related="source_warehouse.lot_stock_id", store=True)
|
|
|
+ destinationloc_id = fields.Many2one('stock.location', 'Ubicación Destino',related="dest_warehouse.lot_stock_id", store=True)
|
|
|
date = fields.Datetime('Fecha')
|
|
|
origin = fields.Char('Pedido')
|
|
|
owner_id = fields.Many2one('res.partner', 'Creado por:', help="Owner of the quants")
|
|
@@ -143,8 +157,8 @@ class sale_order(models.Model):
|
|
|
'name' : line.name,
|
|
|
'product_uom_id' : line.product_uom.id,
|
|
|
'quantity' : line.product_uom_qty,
|
|
|
- 'sourceloc_id' : created_id.picking_type_id.default_location_src_id.id,
|
|
|
- 'destinationloc_id' : created_id.picking_type_id.default_location_dest_id.id,
|
|
|
+ 'source_warehouse' : created_id.picking_source_warehouse_id.id,
|
|
|
+ 'dest_warehouse' : created_id.picking_destination_warehouse_id.id,
|
|
|
'origin' : item.name,
|
|
|
'price_unit' : line.price_unit,
|
|
|
}
|
|
@@ -154,32 +168,32 @@ class sale_order(models.Model):
|
|
|
class stock_location(models.Model):
|
|
|
_inherit = "stock.location"
|
|
|
|
|
|
- @api.multi
|
|
|
- def name_get(self):
|
|
|
- if self._context is None:
|
|
|
- self._context = {}
|
|
|
- res = []
|
|
|
- if self._context.get('nombre_para_stock_transfer', False):
|
|
|
- product = self._context.get('transfer_product_id')
|
|
|
- for location in self:
|
|
|
- suma = 0
|
|
|
- quant_ids = self.env['stock.quant'].search([('product_id','=', product),('location_id','=',location.id)])
|
|
|
- if quant_ids:
|
|
|
- for quant_id in quant_ids:
|
|
|
- suma = suma + quant_id.qty
|
|
|
-
|
|
|
- res.append((location.id, ("%(location_parent)s/%(location_name)s - %(location_qty)s") % {
|
|
|
- 'location_parent': location.location_id.name,
|
|
|
- 'location_name': location.name,
|
|
|
- 'location_qty': suma
|
|
|
- }))
|
|
|
- else:
|
|
|
- for record in self:
|
|
|
- res.append((record.id, ("%(location_parent)s/%(location_name)s") % {
|
|
|
- 'location_parent': record.location_id.name or "",
|
|
|
- 'location_name': record.name
|
|
|
- }))
|
|
|
- return res
|
|
|
+ # @api.multi
|
|
|
+ # def name_get(self):
|
|
|
+ # if self._context is None:
|
|
|
+ # self._context = {}
|
|
|
+ # res = []
|
|
|
+ # if self._context.get('nombre_para_stock_transfer', False):
|
|
|
+ # product = self._context.get('transfer_product_id')
|
|
|
+ # for location in self:
|
|
|
+ # suma = 0
|
|
|
+ # quant_ids = self.env['stock.quant'].search([('product_id','=', product),('location_id','=',location.id)])
|
|
|
+ # if quant_ids:
|
|
|
+ # for quant_id in quant_ids:
|
|
|
+ # suma = suma + quant_id.qty
|
|
|
+ #
|
|
|
+ # res.append((location.id, ("%(location_parent)s/%(location_name)s %(location_qty)s") % {
|
|
|
+ # 'location_parent': location.location_id.name,
|
|
|
+ # 'location_name': location.name,
|
|
|
+ # 'location_qty': suma
|
|
|
+ # }))
|
|
|
+ # else:
|
|
|
+ # for record in self:
|
|
|
+ # res.append((record.id, ("%(location_parent)s/%(location_name)s") % {
|
|
|
+ # 'location_parent': record.location_id.name or "",
|
|
|
+ # 'location_name': record.name
|
|
|
+ # }))
|
|
|
+ # return res
|
|
|
|
|
|
class stock_picking(models.Model):
|
|
|
_inherit = 'stock.picking'
|