diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py
index 38c5a2a9380..8acbf9da317 100644
--- a/addons/account/models/account_payment.py
+++ b/addons/account/models/account_payment.py
@@ -179,6 +179,16 @@ class account_payment(models.Model):
def _get_has_invoices(self):
self.has_invoices = bool(self.invoice_ids)
+ @api.multi
+ @api.depends('move_line_ids.reconciled')
+ def _get_move_reconciled(self):
+ for payment in self:
+ rec = True
+ for aml in payment.move_line_ids.filtered(lambda x: x.account_id.reconcile):
+ if not aml.reconciled:
+ rec = False
+ payment.move_reconciled = rec
+
@api.one
@api.depends('invoice_ids', 'amount', 'payment_date', 'currency_id')
def _compute_payment_difference(self):
@@ -217,6 +227,20 @@ class account_payment(models.Model):
# FIXME: ondelete='restrict' not working (eg. cancel a bank statement reconciliation with a payment)
move_line_ids = fields.One2many('account.move.line', 'payment_id', readonly=True, copy=False, ondelete='restrict')
+ move_reconciled = fields.Boolean(compute="_get_move_reconciled", readonly=True)
+
+ def open_payment_matching_screen(self):
+ # Open reconciliation view for customers/suppliers
+ action_context = {'show_mode_selector': False, 'company_ids': [self.company_id.id], 'partner_ids': [self.partner_id.commercial_partner_id.id]}
+ if self.partner_type == 'customer':
+ action_context.update({'mode': 'customers'})
+ elif self.partner_type == 'supplier':
+ action_context.update({'mode': 'suppliers'})
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'manual_reconciliation_view',
+ 'context': action_context,
+ }
@api.one
@api.depends('invoice_ids', 'payment_type', 'partner_type', 'partner_id')
diff --git a/addons/account/views/account_payment_view.xml b/addons/account/views/account_payment_view.xml
index 620d6638e65..9f9e49ecd05 100644
--- a/addons/account/views/account_payment_view.xml
+++ b/addons/account/views/account_payment_view.xml
@@ -89,7 +89,11 @@
+