[IMP] account_financial_report: select accounts between two codes
This commit is contained in:
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user