[FIX] account, sale: Default payment term when creating an invoice

Steps to reproduce the bug:

- Let's consider a partner P without property_payment_term_id
- Create a SO for P, confirm it and create an invoice I
- In debug mode, on the SO click on the smart button 'invoice'
- On I, click on the 'Set Default' in the debug menu
- Set a payment term PT as default value (ir.default) for all users
- From this view, create a new invoice

Bug:

The default payment term PT was not set on the new invoice

opw:2184367

closes odoo/odoo#44781

X-original-commit: c258b8a0427bd5aface891ed1f4420174f4afde4
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Goffin Simon
2020-02-06 17:25:20 +00:00
parent d657a9c29a
commit a4d46ec55c
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -323,9 +323,9 @@ class AccountMove(models.Model):
return {'warning': warning}
for line in self.line_ids:
line.partner_id = self.partner_id.commercial_partner_id
if self.is_sale_document(include_receipts=True):
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
elif self.is_purchase_document(include_receipts=True):
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
self._compute_bank_partner_id()
+1 -1
View File
@@ -565,7 +565,7 @@ class SaleOrder(models.Model):
context.update({
'default_partner_id': self.partner_id.id,
'default_partner_shipping_id': self.partner_shipping_id.id,
'default_invoice_payment_term_id': self.payment_term_id.id,
'default_invoice_payment_term_id': self.payment_term_id.id or self.partner_id.property_payment_term_id.id or self.env['ir.default'].sudo().get('account.move', 'invoice_payment_term_id', company_id=self.env.company.id),
'default_invoice_origin': self.mapped('name'),
'default_user_id': self.user_id.id,
})