Skip to content

Commit

Permalink
[IMP] project_workload_timesheet_additions: Adapt unit sheet lines re…
Browse files Browse the repository at this point in the history
…lation for additional loads
  • Loading branch information
paradoxxxzero committed Sep 30, 2024
1 parent 3a8cec0 commit ff9dd40
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions project_workload_timesheet_additions/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import account_analytic_line
from . import hr_timesheet_sheet
from . import project_workload_unit
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Florian Mounier <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError


class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"

workload_unit_id = fields.Many2one(
comodel_name="project.workload.unit",
string="Workload Unit",
readonly=False,
compute="_compute_workload_unit_id",
store=True,
domain="["
"('week', '=', week), "
"('user_id', '=', user_id), "
"('project_id', '=', project_id), "
"'|', "
"'&', ('additional_task_id', '=', False), ('task_id', '=', task_id), "
"('additional_task_id', '=', task_id)"
"]",
)

def _get_available_workload_units_domain(self):
return [
("week", "=", self.week),
("user_id", "=", self.user_id.id),
("project_id", "=", self.project_id.id),
"|",
"&",
("additional_task_id", "=", False),
("task_id", "=", self.task_id.id),
("additional_task_id", "=", self.task_id.id),
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ class ProjectWorkloadUnit(models.Model):
"project.task.workload.addition",
"Additional Task Workload",
related="workload_id.additional_workload_id",
store=True,
)
additional_task_id = fields.Many2one(
"project.task",
"Additional Task",
related="workload_id.additional_workload_task_id",
store=True,
)

def _get_timesheeting_task(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
<odoo>
<record id="hr_timesheet_sheet_form_my" model="ir.ui.view">
<field name="model">hr_timesheet.sheet</field>
<field name="inherit_id" ref="project_workload_timesheet.hr_timesheet_sheet_form_my" />
<field
name="inherit_id"
ref="project_workload_timesheet.hr_timesheet_sheet_form_my"
/>
<field name="arch" type="xml">
<xpath expr="//field[@name='workload_unit_ids']/tree/field[@name='task_id']" position="after">
<xpath
expr="//field[@name='workload_unit_ids']/tree/field[@name='task_id']"
position="after"
>
<field name="additional_task_id" />
</xpath>
</field>
Expand Down

0 comments on commit ff9dd40

Please sign in to comment.