[MIG] account_financial_report: Migration to 18.0

This commit is contained in:
chaule97
2024-11-18 16:48:37 +07:00
parent c46e83a4a4
commit 01f22b8256
43 changed files with 292 additions and 220 deletions

View File

@@ -63,7 +63,7 @@ class AgedPartnerBalanceWizard(models.TransientModel):
)
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
lambda a: self.company_id in a.company_ids
)
return {
"domain": {
@@ -84,13 +84,15 @@ class AgedPartnerBalanceWizard(models.TransientModel):
self.onchange_type_accounts_only()
else:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
lambda a: self.company_id in a.company_ids
)
res = {"domain": {"account_ids": [], "partner_ids": []}}
if not self.company_id:
return res
else:
res["domain"]["account_ids"] += [("company_id", "=", self.company_id.id)]
res["domain"]["account_ids"] += [
("company_ids", "in", [self.company_id.id])
]
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
return res
@@ -101,7 +103,7 @@ class AgedPartnerBalanceWizard(models.TransientModel):
@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)]
domain = [("company_ids", "in", [self.company_id.id])]
if self.receivable_accounts_only or self.payable_accounts_only:
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [

View File

@@ -10,7 +10,7 @@
import time
from ast import literal_eval
from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools import date_utils
@@ -147,7 +147,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
count = self.env["account.account"].search_count(
[
("account_type", "=", "equity_unaffected"),
("company_id", "=", self.company_id.id or self.env.company.id),
("company_ids", "in", [self.company_id.id or self.env.company.id]),
]
)
return count == 1
@@ -226,7 +226,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
and rec.company_id != rec.date_range_id.company_id
):
raise ValidationError(
_(
self.env._(
"The Company in the General Ledger Report Wizard and in "
"Date Range must be the same."
)
@@ -236,7 +236,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
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)]
domain = [("company_ids", "in", [self.company_id.id])]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [
("account_type", "in", ("asset_receivable", "liability_payable"))
@@ -263,7 +263,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
record.unaffected_earnings_account = self.env["account.account"].search(
[
("account_type", "=", "equity_unaffected"),
("company_id", "=", record.company_id.id),
("company_ids", "in", [record.company_id.id]),
]
)

View File

@@ -1,7 +1,7 @@
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo import api, fields, models
class JournalLedgerReportWizard(models.TransientModel):
@@ -38,15 +38,19 @@ class JournalLedgerReportWizard(models.TransientModel):
@api.model
def _get_move_targets(self):
return [("all", _("All")), ("posted", _("Posted")), ("draft", _("Not Posted"))]
return [
("all", self.env._("All")),
("posted", self.env._("Posted")),
("draft", self.env._("Not Posted")),
]
@api.model
def _get_sort_options(self):
return [("move_name", _("Entry number")), ("date", _("Date"))]
return [("move_name", self.env._("Entry number")), ("date", self.env._("Date"))]
@api.model
def _get_group_options(self):
return [("journal", _("Journal")), ("none", _("No group"))]
return [("journal", self.env._("Journal")), ("none", self.env._("No group"))]
@api.onchange("date_range_id")
def onchange_date_range_id(self):

View File

@@ -120,7 +120,7 @@ class OpenItemsReportWizard(models.TransientModel):
@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)]
domain = [("company_ids", "in", [self.company_id.id])]
if self.receivable_accounts_only or self.payable_accounts_only:
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [

View File

@@ -4,7 +4,7 @@
# Copyright 2018 ForgeFlow, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.tools import date_utils
@@ -93,7 +93,7 @@ class TrialBalanceReportWizard(models.TransientModel):
)
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
lambda a: self.company_id in a.company_ids
)
@api.constrains("show_hierarchy", "show_hierarchy_level")
@@ -101,7 +101,9 @@ class TrialBalanceReportWizard(models.TransientModel):
for rec in self:
if rec.show_hierarchy and rec.show_hierarchy_level <= 0:
raise UserError(
_("The hierarchy level to filter on must be greater than 0.")
self.env._(
"The hierarchy level to filter on must be greater than 0."
)
)
@api.depends("date_from")
@@ -121,7 +123,7 @@ class TrialBalanceReportWizard(models.TransientModel):
count = self.env["account.account"].search_count(
[
("account_type", "=", "equity_unaffected"),
("company_id", "=", self.company_id.id or self.env.company.id),
("company_ids", "in", [self.company_id.id or self.env.company.id]),
]
)
return count == 1
@@ -151,7 +153,7 @@ class TrialBalanceReportWizard(models.TransientModel):
self.onchange_type_accounts_only()
else:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
lambda a: self.company_id in a.company_ids
)
res = {
"domain": {
@@ -189,7 +191,7 @@ class TrialBalanceReportWizard(models.TransientModel):
and rec.company_id != rec.date_range_id.company_id
):
raise ValidationError(
_(
self.env._(
"The Company in the Trial Balance Report Wizard and in "
"Date Range must be the same."
)
@@ -199,7 +201,7 @@ class TrialBalanceReportWizard(models.TransientModel):
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)]
domain = [("company_ids", "in", [self.company_id.id])]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [
("account_type", "in", ("asset_receivable", "liability_payable"))
@@ -227,7 +229,7 @@ class TrialBalanceReportWizard(models.TransientModel):
record.unaffected_earnings_account = self.env["account.account"].search(
[
("account_type", "=", "equity_unaffected"),
("company_id", "=", record.company_id.id),
("company_ids", "in", [record.company_id.id]),
]
)

View File

@@ -1,7 +1,7 @@
# Copyright 2018 Forest and Biomass Romania
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError
@@ -60,7 +60,7 @@ class VATReportWizard(models.TransientModel):
and rec.company_id != rec.date_range_id.company_id
):
raise ValidationError(
_(
self.env._(
"The Company in the Vat Report Wizard and in "
"Date Range must be the same."
)