[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) <nim@odoo.com>
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
This commit is contained in:
Juan Jose Scarafia
2020-08-07 13:36:06 +00:00
committed by Nicolas Martinelli
parent 1ca3a590f7
commit 6d52f3646c
+4 -4
View File
@@ -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