|
@ -4,6 +4,7 @@ |
|
|
# Copyright 2016 Camptocamp SA |
|
|
# Copyright 2016 Camptocamp SA |
|
|
# Copyright 2017 Akretion - Alexis de Lattre |
|
|
# Copyright 2017 Akretion - Alexis de Lattre |
|
|
# Copyright 2017 Eficent Business and IT Consulting Services, S.L. |
|
|
# Copyright 2017 Eficent Business and IT Consulting Services, S.L. |
|
|
|
|
|
# Copyright 2020 Druidoo |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -57,8 +58,10 @@ class GeneralLedgerReportWizard(models.TransientModel): |
|
|
show_analytic_tags = fields.Boolean( |
|
|
show_analytic_tags = fields.Boolean( |
|
|
string='Show analytic tags', |
|
|
string='Show analytic tags', |
|
|
) |
|
|
) |
|
|
receivable_accounts_only = fields.Boolean() |
|
|
|
|
|
payable_accounts_only = fields.Boolean() |
|
|
|
|
|
|
|
|
account_type_ids = fields.Many2many( |
|
|
|
|
|
'account.account.type', |
|
|
|
|
|
string='Account Types', |
|
|
|
|
|
) |
|
|
partner_ids = fields.Many2many( |
|
|
partner_ids = fields.Many2many( |
|
|
comodel_name='res.partner', |
|
|
comodel_name='res.partner', |
|
|
string='Filter partners', |
|
|
string='Filter partners', |
|
@ -133,8 +136,8 @@ class GeneralLedgerReportWizard(models.TransientModel): |
|
|
lambda p: p.company_id == self.company_id or |
|
|
lambda p: p.company_id == self.company_id or |
|
|
not p.company_id) |
|
|
not p.company_id) |
|
|
if self.company_id and self.account_ids: |
|
|
if self.company_id and self.account_ids: |
|
|
if self.receivable_accounts_only or self.payable_accounts_only: |
|
|
|
|
|
self.onchange_type_accounts_only() |
|
|
|
|
|
|
|
|
if self.account_type_ids: |
|
|
|
|
|
self._onchange_account_type_ids() |
|
|
else: |
|
|
else: |
|
|
self.account_ids = self.account_ids.filtered( |
|
|
self.account_ids = self.account_ids.filtered( |
|
|
lambda a: a.company_id == self.company_id) |
|
|
lambda a: a.company_id == self.company_id) |
|
@ -180,18 +183,11 @@ class GeneralLedgerReportWizard(models.TransientModel): |
|
|
_('The Company in the General Ledger Report Wizard and in ' |
|
|
_('The Company in the General Ledger Report Wizard and in ' |
|
|
'Date Range must be the same.')) |
|
|
'Date Range must be the same.')) |
|
|
|
|
|
|
|
|
@api.onchange('receivable_accounts_only', 'payable_accounts_only') |
|
|
|
|
|
def onchange_type_accounts_only(self): |
|
|
|
|
|
"""Handle receivable/payable accounts only change.""" |
|
|
|
|
|
if self.receivable_accounts_only or self.payable_accounts_only: |
|
|
|
|
|
domain = [('company_id', '=', self.company_id.id)] |
|
|
|
|
|
if self.receivable_accounts_only and self.payable_accounts_only: |
|
|
|
|
|
domain += [('internal_type', 'in', ('receivable', 'payable'))] |
|
|
|
|
|
elif self.receivable_accounts_only: |
|
|
|
|
|
domain += [('internal_type', '=', 'receivable')] |
|
|
|
|
|
elif self.payable_accounts_only: |
|
|
|
|
|
domain += [('internal_type', '=', 'payable')] |
|
|
|
|
|
self.account_ids = self.env['account.account'].search(domain) |
|
|
|
|
|
|
|
|
@api.onchange('account_type_ids') |
|
|
|
|
|
def _onchange_account_type_ids(self): |
|
|
|
|
|
if self.account_type_ids: |
|
|
|
|
|
self.account_ids = self.env['account.account'].search([ |
|
|
|
|
|
('user_type_id', 'in', self.account_type_ids.ids)]) |
|
|
else: |
|
|
else: |
|
|
self.account_ids = None |
|
|
self.account_ids = None |
|
|
|
|
|
|
|
@ -199,9 +195,12 @@ class GeneralLedgerReportWizard(models.TransientModel): |
|
|
def onchange_partner_ids(self): |
|
|
def onchange_partner_ids(self): |
|
|
"""Handle partners change.""" |
|
|
"""Handle partners change.""" |
|
|
if self.partner_ids: |
|
|
if self.partner_ids: |
|
|
self.receivable_accounts_only = self.payable_accounts_only = True |
|
|
|
|
|
|
|
|
self.account_type_ids = self.env['account.account.type'].search([ |
|
|
|
|
|
('type', 'in', ['receivable', 'payable'])]) |
|
|
else: |
|
|
else: |
|
|
self.receivable_accounts_only = self.payable_accounts_only = False |
|
|
|
|
|
|
|
|
self.account_type_ids = None |
|
|
|
|
|
# Somehow this is required to force onchange on _default_partners() |
|
|
|
|
|
self._onchange_account_type_ids() |
|
|
|
|
|
|
|
|
@api.multi |
|
|
@api.multi |
|
|
def button_export_html(self): |
|
|
def button_export_html(self): |
|
|