diff --git a/stock_picking_deposito/models/stock_picking.py b/stock_picking_deposito/models/stock_picking.py index e5f93cb..879c484 100644 --- a/stock_picking_deposito/models/stock_picking.py +++ b/stock_picking_deposito/models/stock_picking.py @@ -1,4 +1,4 @@ -# Copyright 2021 Criptomart +# Copyright 2021-2024 Criptomart # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) import logging @@ -27,13 +27,22 @@ class Picking(models.Model): pick.change_dest_location() return pick + @api.onchange("partner_id") + def onchange_partner_id(self): + if self.partner_id and self.picking_type_id.is_deposit: + if self.picking_type_id.code == 'internal': + self.location_dest_id = self.partner_id.deposit_sale_location_id + elif self.picking_type_id.code == 'incoming': + self.location_dest_id = self.partner_id.deposit_buy_location_id + _logger.warning("location id: %s %s", self.location_dest_id, self.partner_id.deposit_sale_location_id) + def change_dest_location(self): if self.picking_type_id.code == 'internal': if not self.partner_id.deposit_sale_accept: raise ValidationError("Éste cliente no acepta material en depósito, configúralo antes de crear un depósito para él.") return self.update({ - 'location_dest_id': self.partner_id.deposit_sale_location_id.id, + 'location_dest_id': self.partner_id.deposit_sale_location_id.id, }) elif self.picking_type_id.code == 'incoming': if not self.partner_id.deposit_buy_accept: