wip no funciona el onchange en el web client en campos one2many

Si ponemos location_dst_id en el create, los stock moves se crean con el location antiguo (partner_vendors)
https://github.com/odoo/odoo/issues/2693
This commit is contained in:
snt 2024-09-12 18:10:31 +02:00
parent ca3ff032a2
commit 492c8c6025

View file

@ -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: