Skip to content

Commit

Permalink
[FIX] account_operating_unit: do not show inter-OU balance journals a…
Browse files Browse the repository at this point in the history
…s invoice lines
  • Loading branch information
AaronHForgeFlow committed Feb 11, 2025
1 parent dfd2681 commit 4600b94
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion account_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Accounting with Operating Units",
"summary": "Introduces Operating Unit (OU) in invoices and "
"Accounting Entries with clearing account",
"version": "17.0.1.0.0",
"version": "17.0.1.1.0",
"author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd.,"
"WilldooIT Pty Ltd,"
Expand Down
19 changes: 19 additions & 0 deletions account_operating_unit/migrations/17.0.1.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 ForgeFlow S.L. <https://www.forgeflow.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move_line aml0 SET display_type = 'ou_balance'
FROM account_move_line aml
INNER JOIN res_company rc ON rc.id = aml.company_id
WHERE aml.name = 'OU-Balancing'
AND aml.account_id = rc.inter_ou_clearing_account_id
AND rc.ou_is_self_balanced = true
AND aml0.id = aml.id
""",
)
7 changes: 7 additions & 0 deletions account_operating_unit/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def _prepare_inter_ou_balancing_move_line(self, move, ou_id, ou_balances):
"operating_unit_id": ou_id,
"partner_id": move.partner_id and move.partner_id.id or False,
"account_id": move.company_id.inter_ou_clearing_account_id.id,
"display_type": "ou_balance",
}

if ou_balances[ou_id] < 0.0:
Expand Down Expand Up @@ -249,3 +250,9 @@ def _check_journal_operating_unit(self):
_("The OU in the Move and in Journal must be the same.")
)
return True

def button_draft(self):
res = super().button_draft()
for rec in self:
rec.line_ids.filtered(lambda l: l.display_type == "ou_balance").unlink()
return res
11 changes: 11 additions & 0 deletions account_operating_unit/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@
}
</attribute>
</field>
<xpath
expr="//field[@name='line_ids']/tree//field[@name='account_id']"
position="after"
>
<field
name="operating_unit_id"
options="{'no_create': True}"
optional="show"
groups="operating_unit.group_multi_operating_unit"
/>
</xpath>
<xpath
expr="//field[@name='invoice_line_ids']/tree//field[@name='account_id']"
position="after"
Expand Down

0 comments on commit 4600b94

Please sign in to comment.