From 6d52f3646c7cf389ce76445cd16aa570f90e07e0 Mon Sep 17 00:00:00 2001 From: Juan Jose Scarafia Date: Sat, 11 Apr 2020 18:29:56 +0000 Subject: [PATCH] [FIX] account: update account and payment term - Create 2 customers A & B - On A, set a Payment Term for Sales and Purchases - Create a customer invoice - Add a line - Set Partner A => the payment term is selected - Set Partner B => the payment term is kept Moreover, the term account is set only if the customer has a payment term set, which is not logical. Since the partner is not mandatory, we keep an intermediate behavior: we set the info of the partner only if there is a partner defined. opw-2304436 closes odoo/odoo#55632 X-original-commit: 68d470ee832ea7999ebcb58109d249d7d463c83d Signed-off-by: Nicolas Martinelli (nim) Signed-off-by: Christophe Monniez (moc) --- addons/account/models/account_move.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 4ce41e9c7d7..72a82fbca27 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -396,11 +396,11 @@ class AccountMove(models.Model): self.partner_id = False return {'warning': warning} - if self.is_sale_document(include_receipts=True) and self.partner_id.property_payment_term_id: - self.invoice_payment_term_id = self.partner_id.property_payment_term_id + if self.is_sale_document(include_receipts=True) and self.partner_id: + self.invoice_payment_term_id = self.partner_id.property_payment_term_id or self.invoice_payment_term_id new_term_account = self.partner_id.commercial_partner_id.property_account_receivable_id - elif self.is_purchase_document(include_receipts=True) and self.partner_id.property_supplier_payment_term_id: - self.invoice_payment_term_id = self.partner_id.property_supplier_payment_term_id + elif self.is_purchase_document(include_receipts=True) and self.partner_id: + self.invoice_payment_term_id = self.partner_id.property_supplier_payment_term_id or self.invoice_payment_term_id new_term_account = self.partner_id.commercial_partner_id.property_account_payable_id else: new_term_account = None