purchase_delivery_carrier: integrate with delivery_carrier_partner_account
This commit is contained in:
parent
c8e492b481
commit
bcd92d5039
1 changed files with 11 additions and 7 deletions
|
|
@ -11,21 +11,25 @@ class SalesOrder(models.Model):
|
|||
)
|
||||
sender_id = fields.Many2one(
|
||||
comodel_name="res.partner",
|
||||
related="company_id.partner_id",
|
||||
related="warehouse_id.partner_id",
|
||||
)
|
||||
|
||||
@api.model
|
||||
def write(self, values):
|
||||
res = super().write(values)
|
||||
# If carrier account ID changes for a confirmed order, change it on its
|
||||
# pending pickings as well.
|
||||
if "carrier_account_id" in values:
|
||||
def write(self, vals):
|
||||
res = super().write(vals)
|
||||
if (
|
||||
"carrier_account_id" in vals
|
||||
or "carrier_id" in vals
|
||||
or "delivery_billing_mode" in vals
|
||||
):
|
||||
for rec in self.filtered(
|
||||
lambda order: order.state not in ["draft", "sent"]
|
||||
):
|
||||
for picking in rec.picking_ids.filtered(
|
||||
lambda pick: pick.state not in ("done", "cancel")
|
||||
lambda pick: pick.state not in ["done", "cancel"]
|
||||
):
|
||||
picking.carrier_id = rec.carrier_id
|
||||
picking.delivery_billing_mode = rec.delivery_billing_mode
|
||||
picking.carrier_account_id = rec.carrier_account_id
|
||||
return res
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue