account_move_line_filter_wizard: improve to add direct access to general ledger or open items report
This commit is contained in:
@@ -19,7 +19,11 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
|
|||||||
""",
|
""",
|
||||||
'author': 'Akretion',
|
'author': 'Akretion',
|
||||||
'website': 'http://www.akretion.com',
|
'website': 'http://www.akretion.com',
|
||||||
'depends': ['account_usability'],
|
'depends': [
|
||||||
|
'account_usability',
|
||||||
|
'account_financial_report_qweb',
|
||||||
|
'account_fiscal_year',
|
||||||
|
],
|
||||||
'data': ['wizard/account_move_line_filter_view.xml'],
|
'data': ['wizard/account_move_line_filter_view.xml'],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,16 @@
|
|||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api, _
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
class AccountMoveLineFilterWizard(models.TransientModel):
|
class AccountMoveLineFilterWizard(models.TransientModel):
|
||||||
_name = 'account.move.line.filter.wizard'
|
_name = 'account.move.line.filter.wizard'
|
||||||
_description = 'Wizard for easy and fast access to account move lines'
|
_description = 'Wizard for easy and fast access to account move lines'
|
||||||
|
|
||||||
|
date_range_id = fields.Many2one(
|
||||||
|
'date.range', string='Date Range (only for General Ledger)')
|
||||||
partner_id = fields.Many2one(
|
partner_id = fields.Many2one(
|
||||||
'res.partner', string='Partner', domain=[('parent_id', '=', False)])
|
'res.partner', string='Partner', domain=[('parent_id', '=', False)])
|
||||||
account_id = fields.Many2one(
|
account_id = fields.Many2one(
|
||||||
@@ -23,6 +26,27 @@ class AccountMoveLineFilterWizard(models.TransientModel):
|
|||||||
# ('partial_reconciled', 'Partially Reconciled'),
|
# ('partial_reconciled', 'Partially Reconciled'),
|
||||||
], string='Reconciliation Filter')
|
], string='Reconciliation Filter')
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def default_get(self, fields_list):
|
||||||
|
res = super(AccountMoveLineFilterWizard, self).default_get(fields_list)
|
||||||
|
today = fields.Date.context_today(self)
|
||||||
|
fy_type_id = self.env.ref('account_fiscal_year.fiscalyear').id
|
||||||
|
dro = self.env['date.range']
|
||||||
|
date_range = dro.search([
|
||||||
|
('type_id', '=', fy_type_id),
|
||||||
|
('company_id', '=', self.env.user.company_id.id),
|
||||||
|
('date_start', '<=', today),
|
||||||
|
('date_end', '>=', today)
|
||||||
|
], limit=1)
|
||||||
|
if not date_range:
|
||||||
|
date_range = dro.search([
|
||||||
|
('type_id', '=', fy_type_id),
|
||||||
|
('company_id', '=', self.env.user.company_id.id),
|
||||||
|
], order='date_start desc', limit=1)
|
||||||
|
if date_range:
|
||||||
|
res['date_range_id'] = date_range.id
|
||||||
|
return res
|
||||||
|
|
||||||
@api.onchange('partner_id')
|
@api.onchange('partner_id')
|
||||||
def partner_id_change(self):
|
def partner_id_change(self):
|
||||||
if self.partner_id:
|
if self.partner_id:
|
||||||
@@ -44,3 +68,33 @@ class AccountMoveLineFilterWizard(models.TransientModel):
|
|||||||
if self.reconcile:
|
if self.reconcile:
|
||||||
action['context']['search_default_%s' % self.reconcile] = True
|
action['context']['search_default_%s' % self.reconcile] = True
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
def show_report_general_ledger(self):
|
||||||
|
self.ensure_one()
|
||||||
|
if self.account_reconcile:
|
||||||
|
assert self.reconcile != 'unreconciled'
|
||||||
|
if not self.date_range_id:
|
||||||
|
raise UserError(_(
|
||||||
|
"Select a date range to show the General Ledger report."))
|
||||||
|
wvals = {
|
||||||
|
'account_ids': [(6, 0, [self.account_id.id])],
|
||||||
|
'date_from': self.date_range_id.date_start,
|
||||||
|
'date_to': self.date_range_id.date_end,
|
||||||
|
}
|
||||||
|
if self.partner_id:
|
||||||
|
wvals['partner_ids'] = [(6, 0, [self.partner_id.id])]
|
||||||
|
wiz = self.env['general.ledger.report.wizard'].create(wvals)
|
||||||
|
action = wiz.button_export_html()
|
||||||
|
return action
|
||||||
|
|
||||||
|
def show_report_open_items(self):
|
||||||
|
self.ensure_one()
|
||||||
|
assert self.account_reconcile and self.reconcile == 'unreconciled'
|
||||||
|
wvals = {
|
||||||
|
'account_ids': [(6, 0, [self.account_id.id])],
|
||||||
|
}
|
||||||
|
if self.partner_id:
|
||||||
|
wvals['partner_ids'] = [(6, 0, [self.partner_id.id])]
|
||||||
|
wiz = self.env['open.items.report.wizard'].create(wvals)
|
||||||
|
action = wiz.button_export_html()
|
||||||
|
return action
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright (C) 2016-2018 Akretion (http://www.akretion.com/)
|
Copyright (C) 2016-2019 Akretion (http://www.akretion.com/)
|
||||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
@@ -19,9 +19,12 @@
|
|||||||
<field name="account_reconcile" invisible="1"/>
|
<field name="account_reconcile" invisible="1"/>
|
||||||
<field name="reconcile"
|
<field name="reconcile"
|
||||||
attrs="{'invisible': [('account_reconcile', '!=', True)]}"/>
|
attrs="{'invisible': [('account_reconcile', '!=', True)]}"/>
|
||||||
|
<field name="date_range_id" attrs="{'invisible': [('account_reconcile', '=', True), ('reconcile', '=', 'unreconciled')]}"/>
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button type="object" name="go" string="Go" class="btn-primary"/>
|
<button type="object" name="show_report_general_ledger" string="General Ledger Report" class="btn-primary" attrs="{'invisible': [('account_reconcile', '=', True), ('reconcile', '=', 'unreconciled')]}"/>
|
||||||
|
<button type="object" name="show_report_open_items" string="Open Items Report" class="btn-primary" attrs="{'invisible': ['|', ('account_reconcile', '=', False), ('reconcile', '!=', 'unreconciled')]}"/>
|
||||||
|
<button type="object" name="go" string="Journal Items" class="btn-primary"/>
|
||||||
<button special="cancel" string="Cancel" class="btn-default"/>
|
<button special="cancel" string="Cancel" class="btn-default"/>
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
@@ -29,7 +32,7 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="account_move_line_filter_wizard_action" model="ir.actions.act_window">
|
<record id="account_move_line_filter_wizard_action" model="ir.actions.act_window">
|
||||||
<field name="name">Journal Items of Account</field>
|
<field name="name">Show Account</field>
|
||||||
<field name="res_model">account.move.line.filter.wizard</field>
|
<field name="res_model">account.move.line.filter.wizard</field>
|
||||||
<field name="view_mode">form</field>
|
<field name="view_mode">form</field>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
|
|||||||
Reference in New Issue
Block a user