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

[ADD] account_operating_unit: add operating unit in account analytic line #733

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions account_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"views/company_view.xml",
"views/account_payment_view.xml",
"views/account_invoice_report_view.xml",
"views/account_analytic_line_view.xml",
],
}
1 change: 1 addition & 0 deletions account_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from . import account_move
from . import account_partial_reconcile
from . import account_payment
from . import account_analytic_line
14 changes: 14 additions & 0 deletions account_operating_unit/models/account_analytic_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2025 Jarsa
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import fields, models


class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"

operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
string="Operating Unit",
check_company=True,
)
10 changes: 10 additions & 0 deletions account_operating_unit/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@
}
return move_vals

def _prepare_analytic_distribution_line(
self, distribution, account_ids, distribution_on_each_plan
):
res = super()._prepare_analytic_distribution_line(

Check warning on line 106 in account_operating_unit/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_operating_unit/models/account_move.py#L106

Added line #L106 was not covered by tests
distribution, account_ids, distribution_on_each_plan
)
if self.operating_unit_id:
res["operating_unit_id"] = self.operating_unit_id.id
return res

Check warning on line 111 in account_operating_unit/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_operating_unit/models/account_move.py#L110-L111

Added lines #L110 - L111 were not covered by tests


class AccountMove(models.Model):
_inherit = "account.move"
Expand Down
59 changes: 59 additions & 0 deletions account_operating_unit/views/account_analytic_line_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--© 2025 Jarsa-->
<!--License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).-->
<odoo>

<record id="account_analytic_line_view_form" model="ir.ui.view">
<field name="name">account.analytic.line.view.form</field>
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="analytic.view_account_analytic_line_form" />
<field name="arch" type="xml">
<xpath expr="//group[@name='analytic_item']" position="inside">
<field
name="operating_unit_id"
groups="operating_unit.group_multi_operating_unit"
/>
</xpath>
</field>
</record>

<record id="account_analytic_line_view_tree" model="ir.ui.view">
<field name="name">account.analytic.line.view.tree</field>
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="analytic.view_account_analytic_line_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field
name="operating_unit_id"
groups="operating_unit.group_multi_operating_unit"
optional="show"
/>
</xpath>
</field>
</record>

<record id="account_analytic_line_view_search" model="ir.ui.view">
<field name="name">account.analytic.line.view.search</field>
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="analytic.view_account_analytic_line_filter" />
<field name="arch" type="xml">
<xpath expr="//filter[@name='month']" position="after">
<field
name="operating_unit_id"
string="Operating Unit"
groups="operating_unit.group_multi_operating_unit"
/>
</xpath>
<xpath expr="//group[@name='groupby']" position="inside">
<separator />
<filter
name="operating_unit_id"
string="Operating Unit"
context="{'group_by':'operating_unit_id'}"
groups="operating_unit.group_multi_operating_unit"
/>
</xpath>
</field>
</record>

</odoo>
Loading