diff --git a/purchase_sale_inter_company/models/sale_order.py b/purchase_sale_inter_company/models/sale_order.py index 4f4fd17c377..f6df35791f8 100644 --- a/purchase_sale_inter_company/models/sale_order.py +++ b/purchase_sale_inter_company/models/sale_order.py @@ -22,3 +22,10 @@ def action_confirm(self): if line.auto_purchase_line_id: line.auto_purchase_line_id.price_unit = line.price_unit return super().action_confirm() + + def write(self, vals): + res = super().write(vals) + purchase_id = self.auto_purchase_order_id + if "commitment_date" in vals and purchase_id: + purchase_id.sudo().write({"date_planned": vals["commitment_date"]}) + return res diff --git a/purchase_sale_inter_company/tests/test_inter_company_purchase_sale.py b/purchase_sale_inter_company/tests/test_inter_company_purchase_sale.py index 8c51f9415fc..65a036531b0 100644 --- a/purchase_sale_inter_company/tests/test_inter_company_purchase_sale.py +++ b/purchase_sale_inter_company/tests/test_inter_company_purchase_sale.py @@ -275,3 +275,11 @@ def test_bypass_check_when_update_locked_sale_order_with_ctx(self): purchase.order_line[0].with_context(allow_update_locked_sales=True).write( {"product_qty": 99} ) + + def test_change_delivery_date_sale(self): + from dateutil.relativedelta import relativedelta + + sale = self._approve_po() + self.assertEqual(self.purchase_company_a.date_planned, sale.commitment_date) + sale.commitment_date = sale.commitment_date + relativedelta(days=3) + self.assertEqual(self.purchase_company_a.date_planned, sale.commitment_date)