From b879dca025e1f1d14e0dfd558c47cc82f2576cf1 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 12 Nov 2018 14:09:09 +0000 Subject: [PATCH] [FIX] sale: Payment terms from SO Let's consider a customer C with payment terms P1 set on it Steps to reproduce the bug: - Create a SO for C with payment terms P2 - Confirm the SO and generate the invoice Bug: The payment terms on the invoice was P1 instead of P2 This fix allows to keep the same behavior as in 11.0 Introduced by: f1b2d165fb5378a8f6140b42d19f1e028cc289cc opw:1905710 closes odoo/odoo#28585 --- addons/sale/models/sale.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index ca1b2cecdb1..6afc0b6b5d3 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -563,7 +563,10 @@ class SaleOrder(models.Model): # by onchanges, which are not triggered when doing a create. invoice.compute_taxes() # Idem for partner + so_payment_term_id = invoice.payment_term_id.id invoice._onchange_partner_id() + # To keep the payment terms set on the SO + invoice.payment_term_id = so_payment_term_id invoice.message_post_with_view('mail.message_origin_link', values={'self': invoice, 'origin': references[invoice]}, subtype_id=self.env.ref('mail.mt_note').id)