diff --git a/account_payment_order/models/account_payment_line.py b/account_payment_order/models/account_payment_line.py index 5df4c2644..a938cc7c6 100644 --- a/account_payment_order/models/account_payment_line.py +++ b/account_payment_order/models/account_payment_line.py @@ -27,7 +27,8 @@ class AccountPaymentLine(models.Model): related='order_id.state', string='State', readonly=True, store=True) move_line_id = fields.Many2one( - 'account.move.line', string='Journal Item') + 'account.move.line', string='Journal Item', + ondelete='restrict') ml_maturity_date = fields.Date( related='move_line_id.date_maturity', readonly=True) currency_id = fields.Many2one( diff --git a/account_payment_order/wizard/account_payment_line_create.py b/account_payment_order/wizard/account_payment_line_create.py index f131db886..16fe79cbd 100644 --- a/account_payment_order/wizard/account_payment_line_create.py +++ b/account_payment_order/wizard/account_payment_line_create.py @@ -112,9 +112,11 @@ class AccountPaymentLineCreate(models.TransientModel): ('debit', '>', 0), ('account_id.internal_type', '=', 'receivable'), ] - # Exclude lines that are already in a non-cancelled payment order + # Exclude lines that are already in a non-cancelled + # and non-uploaded payment order; lines that are in a + # uploaded payment order are proposed if they are not reconciled, paylines = self.env['account.payment.line'].search([ - ('state', '!=', 'cancel'), + ('state', 'in', ('draft', 'open', 'generated')), ('move_line_id', '!=', False)]) if paylines: move_lines_ids = [payline.move_line_id.id for payline in paylines]