From 96e085355d2e29d81ace06e08dc76ea5668846ef Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 17 May 2016 17:51:16 +0200 Subject: [PATCH] [FIX] account: partial reconcile unreconcile with deleted credit/debit move `debit_move_id` and `credit_move_id` of `account.partial.reconcile` must be required. Not having one of them set on this model does not make sense, you cannot have a reconciliation with a debit move but without a credit move, for instance. Databases already having the trouble, having partial reconciliations without either a debit or a credit move, had issues for the computation of the `payment_move_line_ids` compute field, which relied on the fact these fields were supposed to be required. This revision makes a retro-compatibility patch for these databases already having the issue. opw-677709 --- addons/account/models/account_invoice.py | 4 ++-- addons/account/models/account_move.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 89a6dcd1cb0..4465d4ff7f0 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -180,8 +180,8 @@ class AccountInvoice(models.Model): def _compute_payments(self): payment_lines = [] for line in self.move_id.line_ids: - payment_lines.extend([rp.credit_move_id.id for rp in line.matched_credit_ids]) - payment_lines.extend([rp.debit_move_id.id for rp in line.matched_debit_ids]) + payment_lines.extend(filter(None, [rp.credit_move_id.id for rp in line.matched_credit_ids])) + payment_lines.extend(filter(None, [rp.debit_move_id.id for rp in line.matched_debit_ids])) self.payment_move_line_ids = self.env['account.move.line'].browse(list(set(payment_lines))) name = fields.Char(string='Reference/Description', index=True, diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 0b8db4bf796..5cc899b9fad 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1208,8 +1208,8 @@ class AccountPartialReconcile(models.Model): _name = "account.partial.reconcile" _description = "Partial Reconcile" - debit_move_id = fields.Many2one('account.move.line', index=True) - credit_move_id = fields.Many2one('account.move.line', index=True) + debit_move_id = fields.Many2one('account.move.line', index=True, required=True) + credit_move_id = fields.Many2one('account.move.line', index=True, required=True) amount = fields.Monetary(currency_field='company_currency_id', help="Amount concerned by this matching. Assumed to be always positive") amount_currency = fields.Monetary(string="Amount in Currency") currency_id = fields.Many2one('res.currency', string='Currency')