[IMP] project_working_time_task_portal: display billable_remaining_hours instead of remaining_hours in project kanban view #25
@@ -25,7 +25,8 @@
|
|||||||
"data": [
|
"data": [
|
||||||
"views/hr_timesheet_portal.xml",
|
"views/hr_timesheet_portal.xml",
|
||||||
"views/hr_timesheet_view_task_form2.xml",
|
"views/hr_timesheet_view_task_form2.xml",
|
||||||
"views/portal_tasks_list.xml"
|
"views/portal_tasks_list.xml",
|
||||||
|
"views/project_views.xml"
|
||||||
],
|
],
|
||||||
"assets": {
|
"assets": {
|
||||||
"web.assets_frontend": [
|
"web.assets_frontend": [
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api
|
||||||
from odoo.tools.float_utils import float_compare
|
from odoo.tools.float_utils import float_compare
|
||||||
|
|
||||||
|
|
||||||
@@ -84,4 +84,20 @@ class Task(models.Model):
|
|||||||
else:
|
else:
|
||||||
task.billable_progress = round(100.0 * task_total_hours / task.planned_hours, 2)
|
task.billable_progress = round(100.0 * task_total_hours / task.planned_hours, 2)
|
||||||
else:
|
else:
|
||||||
task.billable_progress = 0.0
|
task.billable_progress = 0.0
|
||||||
|
|
||||||
|
|
||||||
|
class Project(models.Model):
|
||||||
|
_inherit = "project.project"
|
||||||
|
|
||||||
|
billable_remaining_hours = fields.Float(
|
||||||
|
compute="_compute_project_billable_remaining_hours",
|
||||||
|
string="Billable Remaining Hours",
|
||||||
|
store=True,
|
||||||
|
help="Total Billable remaining time (without exclude_from_sale_order timesheet lines)."
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends("task_ids.billable_remaining_hours")
|
||||||
|
def _compute_project_billable_remaining_hours(self):
|
||||||
|
for project in self:
|
||||||
|
project.billable_remaining_hours = sum(task.billable_remaining_hours for task in project.task_ids)
|
||||||
|
19
project_working_time_task_portal/views/project_views.xml
Normal file
19
project_working_time_task_portal/views/project_views.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="project_working_time_view_project_kanban" model="ir.ui.view">
|
||||||
|
<field name="name">project.working.time.view.project.kanban</field>
|
||||||
|
<field name="model">project.project</field>
|
||||||
|
<field name="inherit_id" ref="hr_timesheet.view_project_kanban_inherited" />
|
||||||
|
<field name="priority" eval="999" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//div[hasclass('o_project_kanban_boxes')]/following-sibling::div[1]" position="replace">
|
||||||
|
<t t-set="badgeColor" t-value="'border-success'"/>
|
||||||
|
<t t-set="badgeColor" t-value="'border-danger'" t-if="record.billable_remaining_hours.raw_value < 0"/>
|
||||||
|
<div t-if="record.allow_timesheets.raw_value and record.allocated_hours.raw_value > 0"
|
||||||
|
t-attf-class="oe_kanban_align badge border {{ badgeColor }}" title="Billable remaining hours" groups="hr_timesheet.group_hr_timesheet_user">
|
||||||
|
<field name="billable_remaining_hours" widget="timesheet_uom"/>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
Reference in New Issue
Block a user