Skip to content

Commit

Permalink
Fix carrier_id set on all stock.picking
Browse files Browse the repository at this point in the history
The shipping method must be set only on OUT pickings (so, the move is
related to a sale line), otherwise, on done, every picking of a chain
will try to deliver using the provider (DHL, ...).
  • Loading branch information
guewen committed Aug 27, 2020
1 parent 29c30d9 commit cb74d57
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions delivery_carrier_preference/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ def _compute_estimated_shipping_weight(self):

def _get_new_picking_values(self):
vals = super()._get_new_picking_values()
group_carrier = self.mapped("group_id.carrier_id")
if group_carrier:
vals["carrier_id"] = group_carrier.id
# Take the carrier_id from the group only when we have a related line
# (i.e. we are in an OUT). It reflects the code of the super method in
# "delivery" which takes the carrier of the related SO through SO line
if self.sale_line_id:
group_carrier = self.mapped("group_id.carrier_id")
if group_carrier:
vals["carrier_id"] = group_carrier.id
return vals

@staticmethod
Expand Down

0 comments on commit cb74d57

Please sign in to comment.