Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr journal subtype allowed journals #17

Merged
merged 6 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions account_journal_subtype/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2023 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models
17 changes: 17 additions & 0 deletions account_journal_subtype/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Account Journal Subtype",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"author": "Onestein",
"website": "https://www.onestein.nl",
"depends": [
"account",
],
"data": [
"views/account_journal_views.xml",
],
"license": "LGPL-3",
}
3 changes: 3 additions & 0 deletions account_journal_subtype/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2023 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import account_journal
21 changes: 21 additions & 0 deletions account_journal_subtype/models/account_journal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountJournal(models.Model):
_inherit = "account.journal"

subtype = fields.Selection(
selection=[
("general_misc", "Miscellaneous"),
("general_depr", "Deprecation"),
("general_accr", "Accrual"),
("general_tax", "Taxes"),
("general_wag", "Wages"),
("general_stj", "Inventory revaluation"),
("general_fcr", "Foreign currency revaluation"),
("general_exch", "Exchange difference"),
]
)
24 changes: 24 additions & 0 deletions account_journal_subtype/views/account_journal_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record model="ir.ui.view" id="view_account_journal_form">
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.view_account_journal_form" />
<field name="arch" type="xml">
<field name="type" position="after">
<field name="subtype" attrs="{'invisible': [('type','!=','general')], 'required':[('type','=','general')]}"/>
</field>
</field>
</record>

<record model="ir.ui.view" id="view_account_journal_tree">
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.view_account_journal_tree" />
<field name="arch" type="xml">
<field name="type" position="after">
<field name="subtype" optional="hide"/>
</field>
</field>
</record>

</odoo>
2 changes: 1 addition & 1 deletion l10n_nl_rgs/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"category": "Accounting/Localizations/Account Charts",
"author": "Onestein",
"website": "https://www.onestein.nl",
"depends": ["account", "l10n_nl", "l10n_multilang"],
"depends": ["account", "l10n_nl", "l10n_multilang", "account_journal_subtype"],
"data": [
"data/account_account_tag.xml",
"data/account_chart_template.xml",
Expand Down
61 changes: 30 additions & 31 deletions l10n_nl_rgs/data/account_group_template.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<data noupdate="0">

<record id="account_group_B" model="account.group.template">
<field name="name">BALANS</field>
Expand Down Expand Up @@ -73,7 +73,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC</field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -233,7 +233,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC</field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -730,7 +730,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -1000,7 +1000,7 @@
<field name="rgs_basic"></field>
<field name="rgs_extended">1</field>
<field name="rgs_ez"></field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -1486,7 +1486,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez"></field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type">purchase,bank</field>
Expand Down Expand Up @@ -1522,7 +1522,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type">purchase,bank</field>
Expand Down Expand Up @@ -1612,7 +1612,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -2134,7 +2134,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -2188,7 +2188,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type"></field>
Expand All @@ -2206,7 +2206,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -2242,7 +2242,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -2296,7 +2296,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez"></field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -2530,7 +2530,7 @@
<field name="rgs_basic"></field>
<field name="rgs_extended">1</field>
<field name="rgs_ez"></field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -2602,9 +2602,9 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC,WAG</field>
<field name="rgs_allowed_journals_code">MISC,WAG,TAX</field>
<field name="rgs_allowed_journals_type">sale,purchase,bank</field>
<field name="code_prefix_start">11020</field>
<field name="code_prefix_end">11020</field>
Expand Down Expand Up @@ -2818,7 +2818,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC</field>
<field name="rgs_allowed_journals_type">sale,purchase,bank</field>
Expand Down Expand Up @@ -2874,7 +2874,7 @@
<field name="rgs_ez">1</field>
<field name="rgs_zzp">1</field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC</field>
<field name="rgs_allowed_journals_code">MISC,EXCH</field>
<field name="rgs_allowed_journals_type">purchase,bank</field>
<field name="code_prefix_start">12030</field>
<field name="code_prefix_end">12030</field>
Expand Down Expand Up @@ -2928,7 +2928,7 @@
<field name="rgs_ez">1</field>
<field name="rgs_zzp">1</field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC,WAG</field>
<field name="rgs_allowed_journals_code">MISC,WAG,TAX</field>
<field name="rgs_allowed_journals_type">sale,purchase,bank</field>
<field name="code_prefix_start">120501</field>
<field name="code_prefix_end">120800</field>
Expand Down Expand Up @@ -2962,7 +2962,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez"></field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC</field>
<field name="rgs_allowed_journals_type">sale,purchase,bank</field>
Expand Down Expand Up @@ -3361,7 +3361,7 @@
<field name="rgs_zzp"></field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">WAG</field>
<field name="rgs_allowed_journals_type"></field>
<field name="rgs_allowed_journals_type">purchase</field>
<field name="code_prefix_start">40040</field>
<field name="code_prefix_end">40040</field>
<field name="chart_template_id" ref="l10n_nl_rgs.l10nnl_rgs_chart_template"/>
Expand Down Expand Up @@ -3484,7 +3484,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">DEPR,ACCR</field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -3684,7 +3684,7 @@
<field name="rgs_ez">1</field>
<field name="rgs_zzp">1</field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC,ACCR</field>
<field name="rgs_allowed_journals_code">MISC,ACCR,WAG</field>
<field name="rgs_allowed_journals_type">purchase</field>
<field name="code_prefix_start">4204</field>
<field name="code_prefix_end">4204</field>
Expand All @@ -3702,7 +3702,7 @@
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC,ACCR</field>
<field name="rgs_allowed_journals_code">MISC,ACCR,WAG</field>
<field name="rgs_allowed_journals_type">purchase</field>
<field name="code_prefix_start">4205</field>
<field name="code_prefix_end">4205</field>
Expand Down Expand Up @@ -3756,7 +3756,7 @@
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC,ACCR</field>
<field name="rgs_allowed_journals_code">MISC,ACCR,WAG</field>
<field name="rgs_allowed_journals_type">purchase</field>
<field name="code_prefix_start">4208</field>
<field name="code_prefix_end">4208</field>
Expand Down Expand Up @@ -3792,7 +3792,7 @@
<field name="rgs_ez">1</field>
<field name="rgs_zzp">1</field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC,FCR,ACCR</field>
<field name="rgs_allowed_journals_code">MISC,FCR,ACCR,EXCH</field>
<field name="rgs_allowed_journals_type">purchase,bank</field>
<field name="code_prefix_start">4210</field>
<field name="code_prefix_end">4210</field>
Expand Down Expand Up @@ -3882,7 +3882,7 @@
<field name="rgs_ez">1</field>
<field name="rgs_zzp">1</field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">MISC,ACCR</field>
<field name="rgs_allowed_journals_code">MISC,ACCR,TAX</field>
<field name="rgs_allowed_journals_type">purchase</field>
<field name="code_prefix_start">4215</field>
<field name="code_prefix_end">4215</field>
Expand Down Expand Up @@ -4384,7 +4384,7 @@
<field name="rgs_basic">1</field>
<field name="rgs_extended">1</field>
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_zzp"> </field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code">ACCR</field>
<field name="rgs_allowed_journals_type"></field>
Expand Down Expand Up @@ -5484,7 +5484,7 @@
<field name="rgs_ez">1</field>
<field name="rgs_zzp"></field>
<field name="rgs_bv"></field>
<field name="rgs_allowed_journals_code"></field>
<field name="rgs_allowed_journals_code">EXCH</field>
<field name="rgs_allowed_journals_type"></field>
<field name="code_prefix_start">8407</field>
<field name="code_prefix_end">8407</field>
Expand Down Expand Up @@ -5940,6 +5940,5 @@
<field name="code_prefix_end">99991</field>
<field name="chart_template_id" ref="l10n_nl_rgs.l10nnl_rgs_chart_template"/>
<field name="parent_id" ref="l10n_nl_rgs.account_group_90"/>
</record>
</data>
</record> </data>
</odoo>
21 changes: 18 additions & 3 deletions l10n_nl_rgs/models/account_account.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

# Copyright (C) 2016 Onestein (<http://www.onestein.eu>).
from odoo import fields, models
from odoo import api, fields, models


class AccountAccount(models.Model):
Expand All @@ -13,13 +13,28 @@ 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
and acc.group_id
and acc.group_id.referentiecode
):
rec.referentiecode = rec.group_id.referentiecode

if not self._context.get("group_allowed_journal_change"):
self.group_set_allowed_journals()
return resp

def group_set_allowed_journals(self):
for rec in self:
if rec.group_id and rec.group_id.auto_allowed_journals:
rec.with_context(
group_allowed_journal_change=True
).allowed_journal_ids = rec.group_id.active_allowed_journal_ids

@api.model_create_multi
def create(self, vals_list):
records = super().create(vals_list)
if not self._context.get("group_allowed_journal_change"):
records.group_set_allowed_journals()
return records
Loading
Loading