Skip to content

Commit

Permalink
Merge pull request #379 from ecosoft-odoo/14.0-fix-budget_control_ope…
Browse files Browse the repository at this point in the history
…rating_unit-20230308

[ENH] Filter operating unit in actual budget move report
  • Loading branch information
newtratip authored Mar 8, 2023
2 parents db8ddb1 + a326ac2 commit 2dd7cd0
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ class PurchaseRequestLineMakePurchaseRequisition(models.TransientModel):
def _prepare_purchase_requisition_line(self, pr, item):
"""Convert analytic_tags from [1,2,3] to [6, 0, [1,2,3]]"""
pr_line_dict = super()._prepare_purchase_requisition_line(pr, item)
pr_line_dict["analytic_tag_ids"] = [(6, 0, pr_line_dict["analytic_tag_ids"] or [])]
pr_line_dict["analytic_tag_ids"] = [
(6, 0, pr_line_dict["analytic_tag_ids"] or [])
]
return pr_line_dict
1 change: 1 addition & 0 deletions budget_control_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from . import operating_unit
from . import base_budget_move
from . import account_analytic_account
from . import account_budget_move
from . import budget_control
from . import budget_transfer_item
from . import budget_transfer
Expand Down
19 changes: 19 additions & 0 deletions budget_control_operating_unit/models/account_budget_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


class AccountBudgetMove(models.Model):
_inherit = "account.budget.move"

def _get_operating_unit(self):
return self.env.user.operating_unit_ids

@api.model
def _view_account_budget_move(self):
res = super()._view_account_budget_move()
# Domain operating unit
operating_unit_ids = self._get_operating_unit()
res["domain"] = [("operating_unit_id", "in", operating_unit_ids.ids)]
return res
1 change: 1 addition & 0 deletions budget_control_operating_unit_access_all/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import report
from . import models
3 changes: 3 additions & 0 deletions budget_control_operating_unit_access_all/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import account_budget_move
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models


class AccountBudgetMove(models.Model):
_inherit = "account.budget.move"

def _get_operating_unit(self):
ou_id = super()._get_operating_unit()
all_ou = self.env.user.has_group(
"budget_control_operating_unit_access_all.group_all_ou_budget_control"
)
if all_ou:
ou_id = self.env["operating.unit"].sudo().search([])
return ou_id

0 comments on commit 2dd7cd0

Please sign in to comment.