[FIX+IMP] account_payment_order: 2 things:

* IMP: prevent deleting a move-line that is linked to a payment order line
* FIX: better filtering of move lines already included in open payment order
This commit is contained in:
Stéphane Bidoul
2016-06-25 14:56:40 +02:00
committed by Pedro M. Baeza
parent 5b8b35163e
commit 1f24a20fb8
2 changed files with 6 additions and 3 deletions

View File

@@ -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(

View File

@@ -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]