summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqdp-odoo <qdp@odoo.com>2017-04-12 13:11:26 +0200
committerqdp-odoo <qdp@odoo.com>2017-04-12 16:22:40 +0200
commit3eb252ab0e64583668cbfdd4c8aeebe14a766780 (patch)
treefa57892c596d510042d82a771ed951da1cd00bdf
parentd5908083b4c4cdfb34bbdd8e381c1e419c094702 (diff)
[IMP] account, payment form view: add a button to open payment matching
button will only be visible if the move_line are not reconciled yet This button will allow user to register a payment and then reconcile it with multiple invoices in the payment matching view. Was PR #15157
-rw-r--r--addons/account/models/account_payment.py24
-rw-r--r--addons/account/views/account_payment_view.xml4
2 files changed, 28 insertions, 0 deletions
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 @@
<button class="oe_stat_button" name="button_invoices"
string="Invoices" type="object"
attrs="{'invisible':[('has_invoices','=',False)]}" icon="fa-bars"/>
+ <button class="oe_stat_button" name="open_payment_matching_screen"
+ string="Payment Matching" type="object"
+ attrs="{'invisible':[('move_reconciled','=',True)]}" icon="fa-university"/>
<field name="has_invoices" invisible="1"/>
+ <field name="move_reconciled" invisible="1"/>
</div>
<field name="id" invisible="1"/>
<div class="oe_title" attrs="{'invisible': [('state', '=', 'draft')]}">