From d3eef1e5a5b592d99442bd464771c8c379979291 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 21 Dec 2016 21:13:40 +0100 Subject: [PATCH] Add start_date and end_date on bank statements --- account_usability/account.py | 27 ++++++++++++++++-- account_usability/account_view.xml | 46 ++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/account_usability/account.py b/account_usability/account.py index 8293dcd..7acbbc7 100644 --- a/account_usability/account.py +++ b/account_usability/account.py @@ -43,7 +43,8 @@ class AccountInvoice(models.Model): fiscal_position = fields.Many2one(track_visibility='onchange') @api.multi - def onchange_payment_term_date_invoice(self, payment_term_id, date_invoice): + def onchange_payment_term_date_invoice( + self, payment_term_id, date_invoice): res = super(AccountInvoice, self).onchange_payment_term_date_invoice( payment_term_id, date_invoice) if res and isinstance(res, dict) and 'value' in res: @@ -54,8 +55,8 @@ class AccountInvoice(models.Model): # generated from customer invoices linked to the partners' account because: # 1) the label of an account move line is an important field, we can't # write a rubbish '/' in it ! - # 2) the 'name' field of the account.move.line is used in the overdue letter, - # and '/' is not meaningful for our customer ! + # 2) the 'name' field of the account.move.line is used in the overdue + # letter and '/' is not meaningful for our customer ! @api.multi def action_number(self): res = super(AccountInvoice, self).action_number() @@ -164,6 +165,25 @@ class AccountMoveLine(models.Model): self.credit = amount_company_currency +class AccountBankStatement(models.Model): + _inherit = 'account.bank.statement' + + start_date = fields.Date( + compute='_compute_dates', string='Start Date', readonly=True, + store=True) + end_date = fields.Date( + compute='_compute_dates', string='End Date', readonly=True, + store=True) + + @api.multi + @api.depends('line_ids.date') + def _compute_dates(self): + for st in self: + dates = [line.date for line in st.line_ids] + st.start_date = dates and min(dates) or False + st.end_date = dates and max(dates) or False + + class AccountBankStatementLine(models.Model): _inherit = 'account.bank.statement.line' @@ -210,6 +230,7 @@ class AccountBankStatementLine(models.Model): raise UserError(_( 'No journal entry linked to this bank statement line.')) + class ResPartner(models.Model): _inherit = 'res.partner' diff --git a/account_usability/account_view.xml b/account_usability/account_view.xml index 49a68a9..0104632 100644 --- a/account_usability/account_view.xml +++ b/account_usability/account_view.xml @@ -200,6 +200,52 @@ string="View Account Move" icon="gtk-redo" attrs="{'invisible': [('journal_entry_id', '=', False)]}"/> + + + + + + + + + usability.account.bank.statement.tree + account.bank.statement + + + + 1 + + + 1 + + + + + + + + + + usability.account.bank.statement.search + account.bank.statement + + + + 1 + + + 1 + + + + + + + + +