generated from OCA/oca-addons-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #379 from ecosoft-odoo/14.0-fix-budget_control_ope…
…rating_unit-20230308 [ENH] Filter operating unit in actual budget move report
- Loading branch information
Showing
6 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
budget_control_operating_unit/models/account_budget_move.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
17 changes: 17 additions & 0 deletions
17
budget_control_operating_unit_access_all/models/account_budget_move.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |