access statement from payment
parent
0fb063da14
commit
932dcff807
@ -1,3 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import cash_statement, account_journal_dashboard
|
||||
from . import cash_statement, account_journal_dashboard, account_payment
|
@ -0,0 +1,47 @@
|
||||
from odoo import models, api, _, fields
|
||||
from odoo.exceptions import ValidationError
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class AccountPayment(models.Model):
|
||||
_inherit = "account.payment"
|
||||
|
||||
reconciled_statement_ids = fields.Many2many(
|
||||
comodel_name='account.bank.statement',
|
||||
string="Reconciled Statements",
|
||||
compute='_compute_stat_statement_button',
|
||||
help="Statements matched to this payment",
|
||||
)
|
||||
reconciled_statement_count = fields.Integer(
|
||||
string="# Reconciled Statement",
|
||||
compute="_compute_stat_statement_button",
|
||||
)
|
||||
|
||||
@api.depends('reconciled_statement_line_ids')
|
||||
def _compute_stat_statement_button(self):
|
||||
for pay in self:
|
||||
#statement_ids = { line.statement_id.id for line in pay.reconciled_statement_line_ids }
|
||||
statement_ids = {line.statement_id.id for line in pay.reconciled_statement_line_ids if line.statement_id}
|
||||
pay.reconciled_statement_ids = [(6, 0, list(statement_ids))]
|
||||
pay.reconciled_statement_count = len(statement_ids)
|
||||
|
||||
|
||||
def button_open_statements(self):
|
||||
self.ensure_one()
|
||||
action = {
|
||||
'name': _("Statements"),
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'account.bank.statement',
|
||||
'context': {'create': False, 'journal_type': 'cash'},
|
||||
}
|
||||
if len(self.reconciled_statement_ids) == 1:
|
||||
action.update({
|
||||
'views': [[self.env.ref('gn_cash.view_cash_statement_form').id, "form"]],
|
||||
'res_id': self.reconciled_statement_ids.id,
|
||||
})
|
||||
else:
|
||||
action.update({
|
||||
'views': [[False, "list"], [self.env.ref('gn_cash.view_cash_statement_form').id, "form"]],
|
||||
'domain': [('id', 'in', self.reconciled_statement_ids.ids)],
|
||||
})
|
||||
return action
|
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="gn_cash.view_account_payment_form" model="ir.ui.view">
|
||||
<field name="name">gn_cash.account.payment.form</field>
|
||||
<field name="inherit_id" ref="account.view_account_payment_form"/>
|
||||
<field name="model">account.payment</field>
|
||||
<field name="priority">100</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='button_open_statement_lines']" position="before">
|
||||
<button name="button_open_statements" type="object" class="oe_stat_button" icon="fa-bars" attrs="{'invisible': [('is_matched','=', False)]}">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<field name="reconciled_statement_count"/>
|
||||
<span> Relevé</span>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
Loading…
Reference in New Issue