El onchange picking type no se ejecuta en el create, nos aseguramos de setear el depósito correcto.
This commit is contained in:
parent
5fa23f8d26
commit
bc3625c416
1 changed files with 15 additions and 2 deletions
|
@ -1,12 +1,12 @@
|
||||||
# Copyright 2021 Criptomart
|
# Copyright 2021 Criptomart
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||||
|
|
||||||
#import logging
|
import logging
|
||||||
|
|
||||||
from odoo import api, models, fields
|
from odoo import api, models, fields
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
#_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class PickingType(models.Model):
|
class PickingType(models.Model):
|
||||||
_inherit = 'stock.picking.type'
|
_inherit = 'stock.picking.type'
|
||||||
|
@ -20,12 +20,25 @@ class PickingType(models.Model):
|
||||||
class Picking(models.Model):
|
class Picking(models.Model):
|
||||||
_inherit = 'stock.picking'
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def create(self, vals):
|
||||||
|
if vals.get("partner_id") and vals.get("location_id") == self.env.ref("stock_picking_deposito.stock_location_deposits_stock").id:
|
||||||
|
partner = self.env['res.partner'].browse(vals.get("partner_id"))
|
||||||
|
vals['location_id'] = partner.deposit_sale_location_id.id
|
||||||
|
return super().create(vals)
|
||||||
|
|
||||||
@api.onchange('picking_type_id','partner_id')
|
@api.onchange('picking_type_id','partner_id')
|
||||||
def onchange_picking_type(self):
|
def onchange_picking_type(self):
|
||||||
|
_logger.warning("onchange stock picking type init")
|
||||||
super(Picking, self).onchange_picking_type()
|
super(Picking, self).onchange_picking_type()
|
||||||
|
_logger.warning("onchange stock picking type after super")
|
||||||
if self.picking_type_id.is_deposit and self.partner_id:
|
if self.picking_type_id.is_deposit and self.partner_id:
|
||||||
self.change_dest_location()
|
self.change_dest_location()
|
||||||
|
_logger.warning("env ref stock location %s" %self.env.ref("stock_picking_deposito.stock_location_deposits_stock"))
|
||||||
|
_logger.warning("self location id : %s" %self.location_id.id)
|
||||||
|
_logger.warning("self partner : %s" %self.partner_id.display_name)
|
||||||
if self.partner_id and self.location_id == self.env.ref("stock_picking_deposito.stock_location_deposits_stock"):
|
if self.partner_id and self.location_id == self.env.ref("stock_picking_deposito.stock_location_deposits_stock"):
|
||||||
|
_logger.warning("changing location id : %s" %self.partner_id.deposit_sale_location_id.id)
|
||||||
self.update({
|
self.update({
|
||||||
'location_id': self.partner_id.deposit_sale_location_id.id,
|
'location_id': self.partner_id.deposit_sale_location_id.id,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue