[IMP] Use of account.account.type instead of hardcoded receivable and payable booleans
parent
453c013d94
commit
3169ba2255
|
@ -4,6 +4,7 @@
|
|||
# Copyright 2016 Camptocamp SA
|
||||
# Copyright 2017 Akretion - Alexis de Lattre
|
||||
# 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).
|
||||
|
||||
|
||||
|
@ -57,8 +58,10 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
|||
show_analytic_tags = fields.Boolean(
|
||||
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(
|
||||
comodel_name='res.partner',
|
||||
string='Filter partners',
|
||||
|
@ -133,8 +136,8 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
|||
lambda p: p.company_id == self.company_id or
|
||||
not p.company_id)
|
||||
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:
|
||||
self.account_ids = self.account_ids.filtered(
|
||||
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 '
|
||||
'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:
|
||||
self.account_ids = None
|
||||
|
||||
|
@ -199,9 +195,12 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
|||
def onchange_partner_ids(self):
|
||||
"""Handle partners change."""
|
||||
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:
|
||||
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
|
||||
def button_export_html(self):
|
||||
|
|
|
@ -28,14 +28,14 @@
|
|||
</group>
|
||||
<notebook>
|
||||
<page string="Filter accounts">
|
||||
<group col="4">
|
||||
<field name="receivable_accounts_only"/>
|
||||
<field name="payable_accounts_only"/>
|
||||
<group>
|
||||
<group>
|
||||
<field name="account_type_ids" widget="many2many_checkboxes" nolabel="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="account_ids" widget="many2many_tags" options="{'no_create': True}" nolabel="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<field name="account_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"/>
|
||||
</page>
|
||||
<page string="Filter partners">
|
||||
<field name="partner_ids" nolabel="1"
|
||||
|
@ -91,10 +91,6 @@
|
|||
res_model="general.ledger.report.wizard"
|
||||
src_model="res.partner"
|
||||
view_mode="form"
|
||||
context="{
|
||||
'default_receivable_accounts_only':1,
|
||||
'default_payable_accounts_only':1,
|
||||
}"
|
||||
groups="account.group_account_manager"
|
||||
key2="client_action_multi"
|
||||
target="new" />
|
||||
|
|
Loading…
Reference in New Issue