-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][IMP] hr_timesheet_project_parent_enhanced
- Loading branch information
Showing
6 changed files
with
50 additions
and
8 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
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
17 changes: 12 additions & 5 deletions
17
hr_timesheet_project_parent_enhanced/models/project_project.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 |
---|---|---|
@@ -1,23 +1,30 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import api, models, _ | ||
from odoo import api, fields, models, _ | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class ProjectProject(models.Model): | ||
|
||
_inherit = "project.project" | ||
|
||
is_parent_editable = fields.Boolean( | ||
string="Allow Parent Project Edit", | ||
help="""If checked, allows modifying the parent project even | ||
if there are existing timesheet lines.""", | ||
) | ||
|
||
@api.constrains("parent_id") | ||
def _check_cannot_change_parent_while_existing_timesheet(self): | ||
analytic_line_env = self.env["account.analytic.line"] | ||
analytic_line = self.env["account.analytic.line"] | ||
for project in self: | ||
if analytic_line_env.search([("project_id", "=", project.id)], limit=1): | ||
if not project.is_parent_editable and analytic_line.search( | ||
[("project_id", "=", project.id)], limit=1 | ||
): | ||
raise ValidationError( | ||
_( | ||
"Timesheet already exists on this project, to update the Parent " | ||
"Project field, the Project " | ||
"must have no Timesheets." | ||
"Project field, the Project must have no Timesheets." | ||
) | ||
) |
Binary file added
BIN
+127 KB
hr_timesheet_project_parent_enhanced/static/description/project_form_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
21 changes: 21 additions & 0 deletions
21
hr_timesheet_project_parent_enhanced/views/project_project_views.xml
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,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="project_invoice_form" model="ir.ui.view"> | ||
<field name="name">Add timesheet time controls</field> | ||
<field name="model">project.project</field> | ||
<field name="inherit_id" ref="hr_timesheet.project_invoice_form" /> | ||
<field name="arch" type="xml"> | ||
<div id="timesheet_settings" position="inside" > | ||
<div class="o_setting_left_pane" attrs="{'invisible': [('allow_timesheets', '=', False)]}"> | ||
<field name="is_parent_editable" /> | ||
</div> | ||
<div class="o_setting_right_pane" attrs="{'invisible': [('allow_timesheets', '=', False)]}"> | ||
<label for="is_parent_editable" string="Allow Parent Project Edit" /> | ||
<div class="text-muted"> | ||
Allow modifying the parent project even if there are existing timesheet lines. | ||
</div> | ||
</div> | ||
</div> | ||
</field> | ||
</record> | ||
</odoo> |