I am extending stock.picking to modify the default value used as location_dest_id
.
Standard definition is:
location_dest_id = fields.Many2one(¬
'stock.location', "Destination Location Zone",¬
default=lambda self: self.env['stock.picking.type'].browse(self._context.get('default_picking_type_id')).default_location_dest_id,¬
readonly=True, required=True,¬
states={'draft': [('readonly', False)]})¬
Which basically uses the default location defined in the picking_type.
I have extended the model so there is a new field in picking_type
named force_destination
. I would like to set the destination on the stock.picking based on that condition.
Pseudocode:
location_dest_id = fields.Many2one(¬
....
default=
if self.env['stock.picking.type'].browse(self._context.get('default_picking_type_id')).force_destination:
default=1
else:
default=lambda self: self.env['stock.picking.type'].browse(self._context.get('default_picking_type_id')).default_location_dest_id
....