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(
|
sender_id = fields.Many2one(
|
||||||
comodel_name="res.partner",
|
comodel_name="res.partner",
|
||||||
related="company_id.partner_id",
|
related="warehouse_id.partner_id",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def write(self, values):
|
def write(self, vals):
|
||||||
res = super().write(values)
|
res = super().write(vals)
|
||||||
# If carrier account ID changes for a confirmed order, change it on its
|
if (
|
||||||
# pending pickings as well.
|
"carrier_account_id" in vals
|
||||||
if "carrier_account_id" in values:
|
or "carrier_id" in vals
|
||||||
|
or "delivery_billing_mode" in vals
|
||||||
|
):
|
||||||
for rec in self.filtered(
|
for rec in self.filtered(
|
||||||
lambda order: order.state not in ["draft", "sent"]
|
lambda order: order.state not in ["draft", "sent"]
|
||||||
):
|
):
|
||||||
for picking in rec.picking_ids.filtered(
|
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
|
picking.carrier_account_id = rec.carrier_account_id
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue