[FIX] sale: delete draft invoices with downpayments
Create a SO, Validate it. Create Invoice: down payment (fixed amount) and validate invoice Now back to the SO. Create Invoice: Invoiceable lines (deduct down payments). A draft invoice is created. Try to delete it. User gets an error, this occur because the second invoice creation bind another invoice_line to the downpayment sale order line (first line was added when making the downpayment). When the user delete the invoice the sale order line should be deleted as well, but is still linked to an invoice so the error raise. Unlinking only unbinded sol fix the issue opw-2258218 closes odoo/odoo#53144 X-original-commit: 7c7275b8a943196975182a8e66cef0e82f87b21d Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -36,7 +36,7 @@ class AccountMove(models.Model):
|
||||
self.fiscal_position_id = fiscal_position
|
||||
|
||||
def unlink(self):
|
||||
downpayment_lines = self.mapped('line_ids.sale_line_ids').filtered(lambda line: line.is_downpayment)
|
||||
downpayment_lines = self.mapped('line_ids.sale_line_ids').filtered(lambda line: line.is_downpayment and line.invoice_lines <= self.mapped('line_ids'))
|
||||
res = super(AccountMove, self).unlink()
|
||||
if downpayment_lines:
|
||||
downpayment_lines.unlink()
|
||||
|
||||
Reference in New Issue
Block a user