[IMP] account_financial_report: select accounts between two codes
parent
20dd57c240
commit
8f1c150c39
|
@ -173,8 +173,8 @@ class TestVATReport(common.TransactionCase):
|
||||||
line_form.price_unit = 250.0
|
line_form.price_unit = 250.0
|
||||||
line_form.account_id = self.income_account
|
line_form.account_id = self.income_account
|
||||||
line_form.tax_ids.add(self.tax_20)
|
line_form.tax_ids.add(self.tax_20)
|
||||||
self.cbinvoice = move_form.save()
|
invoice = move_form.save()
|
||||||
self.cbinvoice.post()
|
invoice.post()
|
||||||
|
|
||||||
def _get_report_lines(self, taxgroups=False):
|
def _get_report_lines(self, taxgroups=False):
|
||||||
based_on = "taxtags"
|
based_on = "taxtags"
|
||||||
|
|
|
@ -27,9 +27,9 @@ class AgedPartnerBalanceWizard(models.TransientModel):
|
||||||
default="posted",
|
default="posted",
|
||||||
)
|
)
|
||||||
account_ids = fields.Many2many(
|
account_ids = fields.Many2many(
|
||||||
comodel_name='account.account',
|
comodel_name="account.account",
|
||||||
string='Filter accounts',
|
string="Filter accounts",
|
||||||
domain=[('reconcile', '=', True)],
|
domain=[("reconcile", "=", True)],
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
receivable_accounts_only = fields.Boolean()
|
receivable_accounts_only = fields.Boolean()
|
||||||
|
@ -37,6 +37,44 @@ class AgedPartnerBalanceWizard(models.TransientModel):
|
||||||
partner_ids = fields.Many2many(comodel_name="res.partner", string="Filter partners")
|
partner_ids = fields.Many2many(comodel_name="res.partner", string="Filter partners")
|
||||||
show_move_line_details = fields.Boolean()
|
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")
|
@api.onchange("company_id")
|
||||||
def onchange_company_id(self):
|
def onchange_company_id(self):
|
||||||
"""Handle company change."""
|
"""Handle company change."""
|
||||||
|
@ -59,11 +97,11 @@ class AgedPartnerBalanceWizard(models.TransientModel):
|
||||||
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
|
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.onchange('account_ids')
|
@api.onchange("account_ids")
|
||||||
def onchange_account_ids(self):
|
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):
|
def onchange_type_accounts_only(self):
|
||||||
"""Handle receivable/payable accounts only change."""
|
"""Handle receivable/payable accounts only change."""
|
||||||
domain = [("company_id", "=", self.company_id.id)]
|
domain = [("company_id", "=", self.company_id.id)]
|
||||||
|
@ -73,8 +111,8 @@ class AgedPartnerBalanceWizard(models.TransientModel):
|
||||||
elif self.receivable_accounts_only:
|
elif self.receivable_accounts_only:
|
||||||
domain += [("internal_type", "=", "receivable")]
|
domain += [("internal_type", "=", "receivable")]
|
||||||
elif self.payable_accounts_only:
|
elif self.payable_accounts_only:
|
||||||
domain += [('internal_type', '=', 'payable')]
|
domain += [("internal_type", "=", "payable")]
|
||||||
self.account_ids = self.env['account.account'].search(domain)
|
self.account_ids = self.env["account.account"].search(domain)
|
||||||
else:
|
else:
|
||||||
self.account_ids = None
|
self.account_ids = None
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,24 @@
|
||||||
<label for="account_ids" colspan="4" />
|
<label for="account_ids" colspan="4" />
|
||||||
<field name="receivable_accounts_only" />
|
<field name="receivable_accounts_only" />
|
||||||
<field name="payable_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
|
<field
|
||||||
name="account_ids"
|
name="account_ids"
|
||||||
nolabel="1"
|
nolabel="1"
|
||||||
|
|
|
@ -75,6 +75,34 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||||
"will display initial and final balance in that currency.",
|
"will display initial and final balance in that currency.",
|
||||||
default=lambda self: self._default_foreign_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):
|
def _init_date_from(self):
|
||||||
"""set start date to begin of current year if fiscal year running"""
|
"""set start date to begin of current year if fiscal year running"""
|
||||||
|
|
|
@ -33,16 +33,36 @@
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="Filter accounts">
|
<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="receivable_accounts_only" />
|
||||||
<field name="payable_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>
|
</group>
|
||||||
<field
|
|
||||||
name="account_ids"
|
|
||||||
nolabel="1"
|
|
||||||
widget="many2many_tags"
|
|
||||||
options="{'no_create': True}"
|
|
||||||
/>
|
|
||||||
</page>
|
</page>
|
||||||
<page string="Filter partners">
|
<page string="Filter partners">
|
||||||
<field
|
<field
|
||||||
|
|
|
@ -28,9 +28,9 @@ class OpenItemsReportWizard(models.TransientModel):
|
||||||
default="posted",
|
default="posted",
|
||||||
)
|
)
|
||||||
account_ids = fields.Many2many(
|
account_ids = fields.Many2many(
|
||||||
comodel_name='account.account',
|
comodel_name="account.account",
|
||||||
string='Filter accounts',
|
string="Filter accounts",
|
||||||
domain=[('reconcile', '=', True)],
|
domain=[("reconcile", "=", True)],
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
hide_account_at_0 = fields.Boolean(
|
hide_account_at_0 = fields.Boolean(
|
||||||
|
@ -55,6 +55,44 @@ class OpenItemsReportWizard(models.TransientModel):
|
||||||
"will display initial and final balance in that currency.",
|
"will display initial and final balance in that currency.",
|
||||||
default=lambda self: self._default_foreign_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):
|
def _default_foreign_currency(self):
|
||||||
return self.env.user.has_group("base.group_multi_currency")
|
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()
|
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.onchange('account_ids')
|
@api.onchange("account_ids")
|
||||||
def onchange_account_ids(self):
|
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):
|
def onchange_type_accounts_only(self):
|
||||||
"""Handle receivable/payable accounts only change."""
|
"""Handle receivable/payable accounts only change."""
|
||||||
domain = [("company_id", "=", self.company_id.id)]
|
domain = [("company_id", "=", self.company_id.id)]
|
||||||
|
@ -95,8 +133,8 @@ class OpenItemsReportWizard(models.TransientModel):
|
||||||
elif self.receivable_accounts_only:
|
elif self.receivable_accounts_only:
|
||||||
domain += [("internal_type", "=", "receivable")]
|
domain += [("internal_type", "=", "receivable")]
|
||||||
elif self.payable_accounts_only:
|
elif self.payable_accounts_only:
|
||||||
domain += [('internal_type', '=', 'payable')]
|
domain += [("internal_type", "=", "payable")]
|
||||||
self.account_ids = self.env['account.account'].search(domain)
|
self.account_ids = self.env["account.account"].search(domain)
|
||||||
else:
|
else:
|
||||||
self.account_ids = None
|
self.account_ids = None
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,24 @@
|
||||||
<group name="account_filter" col="4">
|
<group name="account_filter" col="4">
|
||||||
<field name="receivable_accounts_only" />
|
<field name="receivable_accounts_only" />
|
||||||
<field name="payable_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
|
<field
|
||||||
name="account_ids"
|
name="account_ids"
|
||||||
nolabel="1"
|
nolabel="1"
|
||||||
|
|
|
@ -77,6 +77,34 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||||
"account currency is not setup through chart of accounts "
|
"account currency is not setup through chart of accounts "
|
||||||
"will display initial and final balance in that currency.",
|
"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")
|
@api.constrains("hierarchy_on", "show_hierarchy_level")
|
||||||
def _check_show_hierarchy_level(self):
|
def _check_show_hierarchy_level(self):
|
||||||
|
|
|
@ -73,6 +73,22 @@
|
||||||
<label for="account_ids" colspan="4" />
|
<label for="account_ids" colspan="4" />
|
||||||
<field name="receivable_accounts_only" />
|
<field name="receivable_accounts_only" />
|
||||||
<field name="payable_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
|
<field
|
||||||
name="account_ids"
|
name="account_ids"
|
||||||
nolabel="1"
|
nolabel="1"
|
||||||
|
|
Loading…
Reference in New Issue