mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-25 02:52:02 +02:00
19.0 vanilla
This commit is contained in:
parent
a1137a1456
commit
e1d89e11e3
2789 changed files with 1093187 additions and 605897 deletions
|
|
@ -0,0 +1,39 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
class ProjectUpdate(models.Model):
|
||||
_inherit = "project.update"
|
||||
|
||||
display_timesheet_stats = fields.Boolean(compute="_compute_display_timesheet_stats", export_string_translation=False)
|
||||
allocated_time = fields.Integer("Allocated Time", readonly=True)
|
||||
timesheet_time = fields.Integer("Timesheet Time", readonly=True)
|
||||
timesheet_percentage = fields.Integer(compute="_compute_timesheet_percentage", export_string_translation=False)
|
||||
uom_id = fields.Many2one("uom.uom", "Unit", readonly=True, export_string_translation=False)
|
||||
|
||||
def _compute_timesheet_percentage(self):
|
||||
for update in self:
|
||||
update.timesheet_percentage = update.allocated_time and round(update.timesheet_time * 100 / update.allocated_time)
|
||||
|
||||
def _compute_display_timesheet_stats(self):
|
||||
for update in self:
|
||||
update.display_timesheet_stats = update.project_id.allow_timesheets
|
||||
|
||||
# ---------------------------------
|
||||
# ORM Override
|
||||
# ---------------------------------
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
updates = super().create(vals_list)
|
||||
encode_uom = self.env.company.timesheet_encode_uom_id
|
||||
ratio = self.env.ref("uom.product_uom_hour").factor / encode_uom.factor
|
||||
for update in updates:
|
||||
project = update.project_id
|
||||
project.sudo().last_update_id = update
|
||||
update.write({
|
||||
"uom_id": encode_uom,
|
||||
"allocated_time": round(project.allocated_hours * ratio),
|
||||
"timesheet_time": round(project.sudo().total_timesheet_time),
|
||||
})
|
||||
return updates
|
||||
Loading…
Add table
Add a link
Reference in a new issue