-
-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] contract_timesheet_invoice_type
- Loading branch information
Showing
16 changed files
with
671 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
================== | ||
Contract Timesheet | ||
================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:7dda3119071689c61cea26bb92ceabe337c1a6d207437833caa853f9170c5ab0 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/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%2Fcontract-lightgray.png?logo=github | ||
:target: https://github.com/OCA/contract/tree/16.0/contract_timesheet_invoice_type | ||
:alt: OCA/contract | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/contract-16-0/contract-16-0-contract_timesheet_invoice_type | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This modules adds a Contract field on projects, and sets the timesheet | ||
invoice type based on the product that is used on the contract line. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Use Cases / Context | ||
=================== | ||
|
||
Timesheets have a ``timesheet_invoice_type`` field which tells if they | ||
are billable or not, and if billable of which type. In the | ||
``sale_timesheet`` module, this field gets a billable type only when the | ||
timesheet are linked to a sale order line. | ||
|
||
When billing with recurring invoices using the OCA ``contract`` module, | ||
we often work without sale order. So this module is useful to allow | ||
correctly categorizing as billable timesheets on projects that are | ||
billed using recurring contracts. | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
- A link between tasks and contract lines could be added, similar to | ||
what is done for sale order line. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/contract/issues>`_. | ||
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 | ||
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20contract_timesheet_invoice_type%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* ACSONE SA/NV | ||
|
||
Contributors | ||
------------ | ||
|
||
- Stéphane Bidoul [email protected] | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/16.0/contract_timesheet_invoice_type>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Contract Timesheet", | ||
"summary": """ | ||
Link projects to sale contracts""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "ACSONE SA/NV,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/contract", | ||
"depends": [ | ||
"contract", | ||
"sale_project", | ||
"sale_timesheet", | ||
], | ||
"data": [ | ||
"views/project_project.xml", | ||
], | ||
"maintainer": ["sbidoul"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import account_analytic_line | ||
from . import project_project |
41 changes: 41 additions & 0 deletions
41
contract_timesheet_invoice_type/models/account_analytic_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2024 ASCONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountAnalyticLine(models.Model): | ||
_inherit = "account.analytic.line" | ||
|
||
contract_line_id = fields.Many2one( | ||
related="project_id.contract_line_id", | ||
) | ||
|
||
@api.depends("contract_line_id.product_id", "amount") | ||
def _compute_timesheet_invoice_type(self): # pylint: disable=missing-return | ||
super()._compute_timesheet_invoice_type() | ||
for rec in self: | ||
if rec.so_line: | ||
# billed via the sale order | ||
continue | ||
if not rec.contract_line_id: | ||
# no contract, let the default algo do it's job | ||
continue | ||
# From here, similar algorithm as in sale_timesheet | ||
product_id = rec.contract_line_id.product_id | ||
if product_id.type != "service": | ||
continue | ||
if product_id.invoice_policy == "delivery": | ||
service_type = product_id.service_type | ||
if service_type == "timesheet": | ||
rec.timesheet_invoice_type = ( | ||
"timesheet_revenues" if rec.amount > 0 else "billable_time" | ||
) | ||
else: | ||
rec.timesheet_invoice_type = ( | ||
f"billable_{service_type}" | ||
if service_type in ["milestones", "manual"] | ||
else "billable_fixed" | ||
) | ||
elif product_id.invoice_policy == "order": | ||
rec.timesheet_invoice_type = "billable_fixed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2024 ASCONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProjectProject(models.Model): | ||
_inherit = "project.project" | ||
|
||
contract_line_id = fields.Many2one( | ||
"contract.line", | ||
"Contract Item", | ||
copy=False, | ||
index="btree_not_null", | ||
domain=( | ||
"[('partner_id', '=?', partner_id), " | ||
"'|', ('company_id', '=', False), ('company_id', '=', company_id)]" | ||
), | ||
help=( | ||
"Recurring invoicing contract item that will be used to " | ||
"determine the timesheet invoicing type." | ||
), | ||
) | ||
contract_id = fields.Many2one( | ||
related="contract_line_id.contract_id", | ||
readonly=True, | ||
help="Recurring invoicing contract", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Timesheets have a `timesheet_invoice_type` field which tells if they are | ||
billable or not, and if billable of which type. In the `sale_timesheet` module, | ||
this field gets a billable type only when the timesheet are linked to a sale | ||
order line. | ||
|
||
When billing with recurring invoices using the OCA `contract` module, we often | ||
work without sale order. So this module is useful to allow correctly | ||
categorizing as billable timesheets on projects that are billed using recurring | ||
contracts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Stéphane Bidoul <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This modules adds a Contract field on projects, and sets the timesheet invoice | ||
type based on the product that is used on the contract line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- A link between tasks and contract lines could be added, similar to what is done | ||
for sale order line. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.