Skip to content

Commit a21fe81

Browse files
[ADD] contract_timesheet_monitoring
1 parent 110387a commit a21fe81

File tree

14 files changed

+645
-0
lines changed

14 files changed

+645
-0
lines changed
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
=============================
2+
Contract timesheet monitoring
3+
=============================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:00fb3cdc565442ffcd3351e97d0516ce6f4ceb55402981b183f7e717a1e23173
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Production/Stable
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Faddons-lightgray.png?logo=github
20+
:target: https://github.com/coopiteasy/addons/tree/16.0/contract_timesheet_monitoring
21+
:alt: coopiteasy/addons
22+
23+
|badge1| |badge2| |badge3|
24+
25+
Context
26+
=======
27+
28+
This module was developped for clients paying a subscription fee for
29+
functional support. We wanted to invoice a fixed amount per period, but
30+
invoice excess time. This module provide a way for the clients and the
31+
service provider to monitor the time spent to compare it with the
32+
threshold.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Known issues / Roadmap
40+
======================
41+
42+
Add a table to show the time spent on the previous periods. It should
43+
probably be easier to do this using the invoice lines from the contract,
44+
rather than the contract lines.
45+
46+
Bug Tracker
47+
===========
48+
49+
Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/addons/issues>`_.
50+
In case of trouble, please check there if your issue has already been reported.
51+
If you spotted it first, help us to smash it by providing a detailed and welcomed
52+
`feedback <https://github.com/coopiteasy/addons/issues/new?body=module:%20contract_timesheet_monitoring%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
53+
54+
Do not contact contributors directly about support or help with technical issues.
55+
56+
Credits
57+
=======
58+
59+
Authors
60+
-------
61+
62+
* Coop IT Easy SC
63+
64+
Maintainers
65+
-----------
66+
67+
This module is part of the `coopiteasy/addons <https://github.com/coopiteasy/addons/tree/16.0/contract_timesheet_monitoring>`_ project on GitHub.
68+
69+
You are welcome to contribute.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2017 Tecnativa - Luis M. Ontalba
2+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3+
4+
{
5+
"name": "Contract timesheet monitoring",
6+
"summary": "Compute time spent on service contracts",
7+
"version": "16.0.1.0.0",
8+
"category": "Sales",
9+
"author": "Coop IT Easy SC, Odoo Community Association (OCA)",
10+
"website": "https://github.com/coopiteasy/addons",
11+
"depends": ["contract", "hr_timesheet"],
12+
"development_status": "Production/Stable",
13+
"data": [
14+
"views/contract.xml",
15+
"views/contract_portal_templates.xml",
16+
],
17+
"license": "AGPL-3",
18+
"installable": True,
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import contract_line
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from odoo import fields, models
2+
3+
4+
class ContractLine(models.Model):
5+
_inherit = "contract.line"
6+
7+
time_spent = fields.Float(
8+
string="Time Spent this Period", compute="_compute_time_spent"
9+
)
10+
11+
def _compute_time_spent(self):
12+
if self.analytic_distribution:
13+
for analytic_account, percentage in self.analytic_distribution.items():
14+
analytic_account_id = int(analytic_account)
15+
analytic_account_lines = (
16+
self.env["account.analytic.account"]
17+
.browse(analytic_account_id)
18+
.line_ids
19+
)
20+
line_ids_time_spent = analytic_account_lines.filtered(
21+
# ensure the uom is the same as the one configure for the project
22+
# timesheets (hours or day)
23+
lambda x: (
24+
x.encoding_uom_id == x.project_id.timesheet_encode_uom_id
25+
)
26+
)
27+
period_start_date = self.last_date_invoiced or self.date_start
28+
line_ids_time_spent_in_period = line_ids_time_spent.filtered(
29+
lambda x: (x.date >= period_start_date)
30+
).mapped("unit_amount")
31+
# todo : account for percentage in analytic distribution
32+
self.time_spent = sum(line_ids_time_spent_in_period)
33+
else:
34+
self.time_spent = False
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Context
2+
3+
This module was developped for clients paying a subscription fee for functional support. We wanted to invoice a fixed amount per period, but invoice excess time.
4+
This module provide a way for the clients and the service provider to monitor the time spent to compare it with the threshold.
5+
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a table to show the time spent on the previous periods. It should probably be easier to do this using the invoice lines from the contract, rather than the contract lines.

0 commit comments

Comments
 (0)