Browse Source

[IMP] account_financial_report: select accounts between two codes

pull/682/head
Joan Sisquella 5 years ago
parent
commit
5f93bdcfdb
  1. 4
      account_financial_report/tests/test_vat_report.py
  2. 54
      account_financial_report/wizard/aged_partner_balance_wizard.py
  3. 18
      account_financial_report/wizard/aged_partner_balance_wizard_view.xml
  4. 28
      account_financial_report/wizard/general_ledger_wizard.py
  5. 34
      account_financial_report/wizard/general_ledger_wizard_view.xml
  6. 54
      account_financial_report/wizard/open_items_wizard.py
  7. 18
      account_financial_report/wizard/open_items_wizard_view.xml
  8. 28
      account_financial_report/wizard/trial_balance_wizard.py
  9. 16
      account_financial_report/wizard/trial_balance_wizard_view.xml

4
account_financial_report/tests/test_vat_report.py

@ -173,8 +173,8 @@ class TestVATReport(common.TransactionCase):
line_form.price_unit = 250.0
line_form.account_id = self.income_account
line_form.tax_ids.add(self.tax_20)
self.cbinvoice = move_form.save()
self.cbinvoice.post()
invoice = move_form.save()
invoice.post()
def _get_report_lines(self, taxgroups=False):
based_on = "taxtags"

54
account_financial_report/wizard/aged_partner_balance_wizard.py

@ -27,9 +27,9 @@ class AgedPartnerBalanceWizard(models.TransientModel):
default="posted",
)
account_ids = fields.Many2many(
comodel_name='account.account',
string='Filter accounts',
domain=[('reconcile', '=', True)],
comodel_name="account.account",
string="Filter accounts",
domain=[("reconcile", "=", True)],
required=True,
)
receivable_accounts_only = fields.Boolean()
@ -37,6 +37,44 @@ class AgedPartnerBalanceWizard(models.TransientModel):
partner_ids = fields.Many2many(comodel_name="res.partner", string="Filter partners")
show_move_line_details = fields.Boolean()
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
)
@api.onchange("account_code_from", "account_code_to")
def on_change_account_range(self):
if (
self.account_code_from
and self.account_code_from.code.isdigit()
and self.account_code_to
and self.account_code_to.code.isdigit()
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search(
[
("code", "in", [x for x in range(start_range, end_range + 1)]),
("reconcile", "=", True),
]
)
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
)
return {
"domain": {
"account_code_from": [("reconcile", "=", True)],
"account_code_to": [("reconcile", "=", True)],
}
}
@api.onchange("company_id")
def onchange_company_id(self):
"""Handle company change."""
@ -59,11 +97,11 @@ class AgedPartnerBalanceWizard(models.TransientModel):
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
return res
@api.onchange('account_ids')
@api.onchange("account_ids")
def onchange_account_ids(self):
return {'domain': {'account_ids': [('reconcile', '=', True)]}}
return {"domain": {"account_ids": [("reconcile", "=", True)]}}
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
@api.onchange("receivable_accounts_only", "payable_accounts_only")
def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change."""
domain = [("company_id", "=", self.company_id.id)]
@ -73,8 +111,8 @@ class AgedPartnerBalanceWizard(models.TransientModel):
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)
domain += [("internal_type", "=", "payable")]
self.account_ids = self.env["account.account"].search(domain)
else:
self.account_ids = None

18
account_financial_report/wizard/aged_partner_balance_wizard_view.xml

@ -35,6 +35,24 @@
<label for="account_ids" colspan="4" />
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<label for="account_code_from" string="From Code" />
<div>
<div class="o_row">
<field
name="account_code_from"
class="oe_inline"
options="{'no_create': True}"
/>
<span class="oe_inline">
To
</span>
<field
name="account_code_to"
class="oe_inline"
options="{'no_create': True}"
/>
</div>
</div>
<field
name="account_ids"
nolabel="1"

28
account_financial_report/wizard/general_ledger_wizard.py

@ -75,6 +75,34 @@ class GeneralLedgerReportWizard(models.TransientModel):
"will display initial and final balance in that currency.",
default=lambda self: self._default_foreign_currency(),
)
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
)
@api.onchange("account_code_from", "account_code_to")
def on_change_account_range(self):
if (
self.account_code_from
and self.account_code_from.code.isdigit()
and self.account_code_to
and self.account_code_to.code.isdigit()
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search(
[("code", "in", [x for x in range(start_range, end_range + 1)])]
)
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
)
def _init_date_from(self):
"""set start date to begin of current year if fiscal year running"""

34
account_financial_report/wizard/general_ledger_wizard_view.xml

@ -33,16 +33,36 @@
</group>
<notebook>
<page string="Filter accounts">
<group col="4">
<group name="account_filter" col="4">
<label for="account_ids" colspan="4" />
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<label for="account_code_from" string="From Code" />
<div>
<div class="o_row">
<field
name="account_code_from"
class="oe_inline"
options="{'no_create': True}"
/>
<span class="oe_inline">
To
</span>
<field
name="account_code_to"
class="oe_inline"
options="{'no_create': True}"
/>
</div>
</div>
<field
name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"
/>
</group>
<field
name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
/>
</page>
<page string="Filter partners">
<field

54
account_financial_report/wizard/open_items_wizard.py

@ -28,9 +28,9 @@ class OpenItemsReportWizard(models.TransientModel):
default="posted",
)
account_ids = fields.Many2many(
comodel_name='account.account',
string='Filter accounts',
domain=[('reconcile', '=', True)],
comodel_name="account.account",
string="Filter accounts",
domain=[("reconcile", "=", True)],
required=True,
)
hide_account_at_0 = fields.Boolean(
@ -55,6 +55,44 @@ class OpenItemsReportWizard(models.TransientModel):
"will display initial and final balance in that currency.",
default=lambda self: self._default_foreign_currency(),
)
show_partner_details = fields.Boolean(string="Show Partner Details", default=True,)
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
)
@api.onchange("account_code_from", "account_code_to")
def on_change_account_range(self):
if (
self.account_code_from
and self.account_code_from.code.isdigit()
and self.account_code_to
and self.account_code_to.code.isdigit()
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search(
[
("code", "in", [x for x in range(start_range, end_range + 1)]),
("reconcile", "=", True),
]
)
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
)
return {
"domain": {
"account_code_from": [("reconcile", "=", True)],
"account_code_to": [("reconcile", "=", True)],
}
}
def _default_foreign_currency(self):
return self.env.user.has_group("base.group_multi_currency")
@ -81,11 +119,11 @@ class OpenItemsReportWizard(models.TransientModel):
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
return res
@api.onchange('account_ids')
@api.onchange("account_ids")
def onchange_account_ids(self):
return {'domain': {'account_ids': [('reconcile', '=', True)]}}
return {"domain": {"account_ids": [("reconcile", "=", True)]}}
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
@api.onchange("receivable_accounts_only", "payable_accounts_only")
def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change."""
domain = [("company_id", "=", self.company_id.id)]
@ -95,8 +133,8 @@ class OpenItemsReportWizard(models.TransientModel):
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)
domain += [("internal_type", "=", "payable")]
self.account_ids = self.env["account.account"].search(domain)
else:
self.account_ids = None

18
account_financial_report/wizard/open_items_wizard_view.xml

@ -36,6 +36,24 @@
<group name="account_filter" col="4">
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<label for="account_code_from" string="From Code" />
<div>
<div class="o_row">
<field
name="account_code_from"
class="oe_inline"
options="{'no_create': True}"
/>
<span class="oe_inline">
To
</span>
<field
name="account_code_to"
class="oe_inline"
options="{'no_create': True}"
/>
</div>
</div>
<field
name="account_ids"
nolabel="1"

28
account_financial_report/wizard/trial_balance_wizard.py

@ -77,6 +77,34 @@ class TrialBalanceReportWizard(models.TransientModel):
"account currency is not setup through chart of accounts "
"will display initial and final balance in that currency.",
)
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
)
@api.onchange("account_code_from", "account_code_to")
def on_change_account_range(self):
if (
self.account_code_from
and self.account_code_from.code.isdigit()
and self.account_code_to
and self.account_code_to.code.isdigit()
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search(
[("code", "in", [x for x in range(start_range, end_range + 1)])]
)
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
)
@api.constrains("hierarchy_on", "show_hierarchy_level")
def _check_show_hierarchy_level(self):

16
account_financial_report/wizard/trial_balance_wizard_view.xml

@ -73,6 +73,22 @@
<label for="account_ids" colspan="4" />
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<label for="account_code_from" string="From Code" />
<div>
<div class="o_row">
<field
name="account_code_from"
class="oe_inline"
options="{'no_create': True}"
/>
<span class="oe_inline">To</span>
<field
name="account_code_to"
class="oe_inline"
options="{'no_create': True}"
/>
</div>
</div>
<field
name="account_ids"
nolabel="1"

Loading…
Cancel
Save