[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
This commit is contained in:
qdp-odoo
2017-04-12 16:22:40 +02:00
parent d5908083b4
commit 3eb252ab0e
2 changed files with 28 additions and 0 deletions
+24
View File
@@ -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')
@@ -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')]}">