Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions sale_timesheet_rounded/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

======================
Sale Timesheet Rounded
======================
Expand All @@ -17,7 +13,7 @@ Sale Timesheet Rounded
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github
Expand Down
7 changes: 6 additions & 1 deletion sale_timesheet_rounded/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
"license": "AGPL-3",
"category": "Sales",
"website": "https://github.com/OCA/timesheet",
"depends": ["project", "hr_timesheet", "sale_timesheet"],
"depends": [
"project",
"hr_timesheet",
"sale_timesheet",
],
"data": [
# Views
"views/account_analytic_line.xml",
"views/project_project.xml",
"views/project_task.xml",
"views/sale_order.xml",
],
"installable": True,
"pre_init_hook": "pre_init_hook",
Expand Down
4 changes: 3 additions & 1 deletion sale_timesheet_rounded/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from . import account_analytic_line
from . import project_project
from . import sale
from . import project_task
from . import sale_order_line
from . import sale_order
from . import account_move
75 changes: 75 additions & 0 deletions sale_timesheet_rounded/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2026 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import api, fields, models


class ProjectTask(models.Model):
_inherit = "project.task"

effective_hours_rounded = fields.Float(
string="Rounded Time Spent",
compute="_compute_effective_hours_rounded",
compute_sudo=True,
store=True,
)
subtask_effective_hours_rounded = fields.Float(
string="Rounded Subtasks Time Spent",
compute="_compute_subtask_effective_hours_rounded",
recursive=True,
store=True,
)
remaining_hours_rounded = fields.Float(
string="Rounded Time Remaining",
compute="_compute_remaining_hours_rounded",
compute_sudo=True,
store=True,
)
total_hours_spent_rounded = fields.Float(
string="Rounded Total Time Spent",
compute="_compute_total_hours_spent_rounded",
store=True,
)

@api.depends("timesheet_ids.unit_amount_rounded")
def _compute_effective_hours_rounded(self):
timesheet_rg = self.env["account.analytic.line"]._read_group(
[("task_id", "in", self.ids)],
["task_id"],
["unit_amount_rounded:sum"],
)
per_task = {task.id: amount for task, amount in timesheet_rg}
for task in self:
task.effective_hours_rounded = per_task.get(task.id, 0.0)

@api.depends(
"child_ids.effective_hours_rounded", "child_ids.subtask_effective_hours_rounded"
)
def _compute_subtask_effective_hours_rounded(self):
for task in self.with_context(active_test=False):
task.subtask_effective_hours_rounded = sum(
child_task.effective_hours_rounded
+ child_task.subtask_effective_hours_rounded
for child_task in task.child_ids
)

@api.depends(
"effective_hours_rounded", "subtask_effective_hours_rounded", "allocated_hours"
)
def _compute_remaining_hours_rounded(self):
for task in self:
if not task.allocated_hours:
task.remaining_hours_rounded = 0.0
else:
task.remaining_hours_rounded = (
task.allocated_hours
- task.effective_hours_rounded
- task.subtask_effective_hours_rounded
)

@api.depends("effective_hours_rounded", "subtask_effective_hours_rounded")
def _compute_total_hours_spent_rounded(self):
for task in self:
task.total_hours_spent_rounded = (
task.effective_hours_rounded + task.subtask_effective_hours_rounded
)
30 changes: 30 additions & 0 deletions sale_timesheet_rounded/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2026 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

timesheet_total_duration_rounded = fields.Integer(
string="Rounded Timesheet Total Duration",
compute="_compute_timesheet_total_duration_rounded",
compute_sudo=True,
groups="hr_timesheet.group_hr_timesheet_user",
)

def _compute_timesheet_total_duration_rounded(self):
group_data = self.env["account.analytic.line"]._read_group(
[("order_id", "in", self.ids), ("project_id", "!=", False)],
["order_id"],
["unit_amount_rounded:sum"],
)
rounded_dict = {order.id: rounded for order, rounded in group_data}
for sale_order in self:
total_time = sale_order.company_id.project_time_mode_id._compute_quantity(
rounded_dict.get(sale_order.id, 0.0),
sale_order.timesheet_encode_uom_id,
rounding_method="HALF-UP",
)
sale_order.timesheet_total_duration_rounded = round(total_time)
30 changes: 12 additions & 18 deletions sale_timesheet_rounded/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Sale Timesheet Rounded</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="sale-timesheet-rounded">
<h1 class="title">Sale Timesheet Rounded</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="sale-timesheet-rounded">
<h1>Sale Timesheet Rounded</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3f8de5508660cc47eee65838db0f7c781e16aec0b0dacd6be04bbdf4020d979b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/timesheet/tree/18.0/sale_timesheet_rounded"><img alt="OCA/timesheet" src="https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/timesheet-18-0/timesheet-18-0-sale_timesheet_rounded"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/timesheet&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/timesheet/tree/18.0/sale_timesheet_rounded"><img alt="OCA/timesheet" src="https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/timesheet-18-0/timesheet-18-0-sale_timesheet_rounded"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/timesheet&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Round timesheet lines amounts in sales based on project’ settings.</p>
<p>A typical use case is: you work 5 minutes but you want to invoice 15
minutes.</p>
Expand Down Expand Up @@ -406,7 +401,7 @@ <h1>Sale Timesheet Rounded</h1>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>Go to a project and set the following fields according to your needs:</p>
<ul class="simple">
<li>Timesheet rounding unit</li>
Expand All @@ -428,29 +423,29 @@ <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
result = round(amount * percentage, unit)</blockquote>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>improve test coverage</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/timesheet/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/timesheet/issues/new?body=module:%20sale_timesheet_rounded%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>Camptocamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a>&gt;</li>
<li>Thomas Nowicki &lt;<a class="reference external" href="mailto:thomas.nowicki&#64;camptocamp.com">thomas.nowicki&#64;camptocamp.com</a>&gt;</li>
Expand All @@ -461,12 +456,12 @@ <h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
</ul>
</div>
<div class="section" id="other-credits">
<h3><a class="toc-backref" href="#toc-entry-7">Other credits</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2>
<p>The migration of this sale_timesheet_rounded from 16.0 to 17.0 was
financially supported by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -479,6 +474,5 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
Loading
Loading