-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by andhit-r
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ | |
risk_analysis_item, | ||
risk_analysis_worksheet_type, | ||
risk_analysis_worksheet, | ||
mixin_risk_analysis, | ||
) |
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,38 @@ | ||
# Copyright 2022 OpenSynergy Indonesia | ||
# Copyright 2022 PT. Simetri Sinergi Indonesia | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class MixinRiskAnalysis(models.AbstractModel): | ||
_name = "mixin.risk_analysis" | ||
_description = "Mixin for Object With Risk Analysis" | ||
|
||
risk_analysis_id = fields.Many2one( | ||
string="# Risk Analysis", | ||
comodel_name="risk_analysis", | ||
) | ||
risk_analysis_state = fields.Selection( | ||
related="risk_analysis_id.state", | ||
store=True, | ||
) | ||
risk_analysis_result_id = fields.Many2one( | ||
string="Risk Analysis Result", | ||
comodel_name="risk_analysis_result", | ||
compute="_compute_risk_analysis_result_id", | ||
store=True, | ||
) | ||
|
||
@api.depends( | ||
"risk_analysis_id", | ||
"risk_analysis_id.state", | ||
"risk_analysis_id.result_id", | ||
) | ||
def _compute_risk_analysis_result_id(self): | ||
for record in self: | ||
result = False | ||
if record.risk_analysis_id and record.risk_analysis_id.state == "done": | ||
result = record.risk_analysis_id.result_id | ||
record.risk_analysis_result_id = result |