Skip to content

Commit

Permalink
Fix No Allowed journals on Accounts / Comments Dennis
Browse files Browse the repository at this point in the history
  • Loading branch information
andreschenkels authored and tarteo committed May 7, 2024
1 parent 1788a41 commit c33d497
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion l10n_nl_rgs/models/account_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AccountAccount(models.Model):
sort_code = fields.Char(string="Sorting code")

def write(self, vals):
resp = super(AccountAccount, self).write(vals)
resp = super().write(vals)

for rec in self.filtered(
lambda acc: not acc.referentiecode
Expand Down
38 changes: 22 additions & 16 deletions l10n_nl_rgs/models/account_chart_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,23 @@ def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None):
for journal in resp_journals:
if journal["code"] == "CABA":
journal["active"] = False
if journal["type"] == "general" and journal["code"] == _("EXCH"):
journal["subtype"] = "general_exch"
if journal["type"] == "general" and journal["code"] == _("MISC"):
journal["subtype"] = "general_misc"
if journal["type"] == "general" and journal["code"] == _("ACCR"):
journal["subtype"] = "general_accr"
if journal["type"] == "general" and journal["code"] == _("DEPR"):
journal["subtype"] = "general_depr"
if journal["type"] == "general" and journal["code"] == _("FCR"):
journal["subtype"] = "general_fcr"
if journal["type"] == "general" and journal["code"] == _("WAG"):
journal["subtype"] = "general_wag"
if journal["type"] == "general" and journal["code"] == _("STJ"):
journal["subtype"] = "general_stj"
if journal["type"] == "general" and journal["code"] == _("TAX"):
journal["subtype"] = "general_tax"
if journal["type"] == "general":
subtype = "general_misc"
if journal["code"] == _("EXCH"):
subtype = "general_exch"
elif journal["code"] == _("ACCR"):
subtype = "general_accr"
elif journal["code"] == _("DEPR"):
subtype = "general_depr"
elif journal["code"] == _("FCR"):
subtype = "general_fcr"
elif journal["code"] == _("WAG"):
subtype = "general_wag"
elif journal["code"] == _("STJ"):
subtype = "general_stj"
elif journal["code"] == _("TAX"):
subtype = "general_tax"
journal["subtype"] = subtype
return resp_journals

@api.model
Expand Down Expand Up @@ -319,6 +320,11 @@ def add_account_group_allowed_journals(self, company):
if journals:
group.allowed_journal_ids = journals

# Set the accounts allowed journal
all_groups = self.env["account.group"].search([("company_id", "=", company.id)])
for group in all_groups:
group.accounts_set_allowed_journals()

def get_allowed_account_journals_based_on_type(self, all_journals, type_list):
return all_journals.filtered(lambda j: j.type in type_list)

Expand Down
9 changes: 3 additions & 6 deletions l10n_nl_rgs/models/account_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,10 @@ def create(self, vals_list):
return records

def accounts_set_allowed_journals(self):
for rec in self:
if rec.auto_allowed_journals:
rec.with_context(
group_allowed_journal_change=True
).account_ids.allowed_journal_ids = rec.active_allowed_journal_ids
for rec in self.filtered(lambda g: g.auto_allowed_journals):
rec.account_ids.group_set_allowed_journals()

@api.depends("parent_id", "parent_id.allowed_journal_ids")
@api.depends("parent_id", "parent_id.allowed_journal_ids", "allowed_journal_ids")
@api.onchange("parent_id", "allowed_journal_ids")
def _compute_active_allowed_journals(self):
for rec in self:
Expand Down

0 comments on commit c33d497

Please sign in to comment.