diff --git a/account_operating_unit/__manifest__.py b/account_operating_unit/__manifest__.py index 9bddc3138d..e5ffff0cd4 100644 --- a/account_operating_unit/__manifest__.py +++ b/account_operating_unit/__manifest__.py @@ -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", ], } diff --git a/account_operating_unit/models/__init__.py b/account_operating_unit/models/__init__.py index 51a95d2831..0bd57addfa 100644 --- a/account_operating_unit/models/__init__.py +++ b/account_operating_unit/models/__init__.py @@ -6,3 +6,4 @@ from . import account_move from . import account_partial_reconcile from . import account_payment +from . import account_analytic_line diff --git a/account_operating_unit/models/account_analytic_line.py b/account_operating_unit/models/account_analytic_line.py new file mode 100644 index 0000000000..455568eaea --- /dev/null +++ b/account_operating_unit/models/account_analytic_line.py @@ -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, + ) diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 076eb30a6e..181c663c8b 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -100,6 +100,16 @@ def _prepare_inter_ou_balancing_move(self, journal): } return move_vals + def _prepare_analytic_distribution_line( + self, distribution, account_ids, distribution_on_each_plan + ): + res = super()._prepare_analytic_distribution_line( + distribution, account_ids, distribution_on_each_plan + ) + if self.operating_unit_id: + res["operating_unit_id"] = self.operating_unit_id.id + return res + class AccountMove(models.Model): _inherit = "account.move" diff --git a/account_operating_unit/views/account_analytic_line_view.xml b/account_operating_unit/views/account_analytic_line_view.xml new file mode 100644 index 0000000000..2f472920ad --- /dev/null +++ b/account_operating_unit/views/account_analytic_line_view.xml @@ -0,0 +1,59 @@ + + + + + + + account.analytic.line.view.form + account.analytic.line + + + + + + + + + + account.analytic.line.view.tree + account.analytic.line + + + + + + + + + + account.analytic.line.view.search + account.analytic.line + + + + + + + + + + + + +