-
-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD][16.0] module hr_timesheet_quick_add
- Loading branch information
Showing
17 changed files
with
743 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
====================== | ||
HR Timesheet Quick Add | ||
====================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:732c6e94ddd590e84afec2ba2b55fdc8ce00580ae7ad90563d87f992e5c653b9 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Ftimesheet-lightgray.png?logo=github | ||
:target: https://github.com/OCA/timesheet/tree/16.0/hr_timesheet_quick_add | ||
:alt: OCA/timesheet | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/timesheet-16-0/timesheet-16-0-hr_timesheet_quick_add | ||
: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/timesheet&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Add a field to select task among last used timesheet ones | ||
|
||
|
||
Here is `Timesheet candidates` field display tasks on which you recorded time recently. | ||
|
||
|
||
.. figure:: https://raw.githubusercontent.com/OCA/timesheet/16.0/hr_timesheet_quick_add/static/description/im1.png | ||
:alt: Timesheet candidates field | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
|
||
|
||
.. figure:: https://raw.githubusercontent.com/OCA/timesheet/16.0/hr_timesheet_quick_add/static/description/im2.png | ||
|
||
|
||
|
||
.. figure:: https://raw.githubusercontent.com/OCA/timesheet/16.0/hr_timesheet_quick_add/static/description/im3.png | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/timesheet/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/timesheet/issues/new?body=module:%20hr_timesheet_quick_add%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 | ||
~~~~~~~ | ||
|
||
* Akretion | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Akretion <https://www.akretion.com>`_: | ||
|
||
* David BEAL <[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/timesheet <https://github.com/OCA/timesheet/tree/16.0/hr_timesheet_quick_add>`_ 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,15 @@ | ||
# Copyright 2024 Akretion | ||
|
||
{ | ||
"name": "HR Timesheet Quick Add", | ||
"version": "16.0.1.0.0", | ||
"author": "Akretion, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"category": "Human Resources", | ||
"depends": ["hr_timesheet_sheet"], | ||
"website": "https://github.com/OCA/timesheet", | ||
"data": [ | ||
"views/hr_timesheet.xml", | ||
], | ||
"installable": True, | ||
} |
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 hr_timesheet_sheet |
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,67 @@ | ||
from datetime import timedelta | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class Hr_TimesheetSheet(models.Model): | ||
_inherit = "hr_timesheet.sheet" | ||
|
||
candidate_task_ids = fields.Many2many( | ||
comodel_name="project.task", | ||
string="Timesheet candidates", | ||
readonly=False, | ||
store=False, | ||
compute="_compute_recent_tasks", | ||
) | ||
default_hour = fields.Integer(default=1) | ||
default_name = fields.Char(default="/") | ||
|
||
@api.depends("timesheet_ids") | ||
def _compute_recent_tasks(self): | ||
"It get tasks on which you recorded time recently" | ||
recent = fields.Date.today() - timedelta(days=self._get_default_days_history()) | ||
for rec in self: | ||
tasks = self.env["account.analytic.line"].read_group( | ||
[ | ||
("employee_id", "=", rec.employee_id.id), | ||
("task_id", "not in", rec.timesheet_ids.mapped("task_id").ids), | ||
("sheet_id", "!=", rec.id), | ||
("date", ">", recent), | ||
], | ||
["task_id", "unit_amount"], | ||
["task_id"], | ||
) | ||
rec.candidate_task_ids = [ | ||
(6, 0, [x["task_id"] and x["task_id"][0] for x in tasks]) | ||
] | ||
|
||
def write(self, vals): | ||
residual_tasks = ( | ||
"candidate_task_ids" in vals and vals["candidate_task_ids"][0][2] | ||
) | ||
for rec in self: | ||
if residual_tasks or rec.candidate_task_ids: | ||
rec._add_timesheet_from_candidates(residual_tasks) | ||
return super().write(vals) | ||
|
||
def _add_timesheet_from_candidates(self, residual_tasks): | ||
self.ensure_one() | ||
task_ids = [x for x in self.candidate_task_ids.ids if x not in residual_tasks] | ||
values = self._prepare_empty_analytic_line() | ||
for task in self.env["project.task"].browse(task_ids): | ||
vals = values.copy() | ||
vals.update( | ||
{ | ||
"project_id": task.project_id.id, | ||
"task_id": task.id, | ||
"unit_amount": self.default_hour, | ||
"name": self.default_name or "/", | ||
} | ||
) | ||
date = fields.Date.today() | ||
if date >= self.date_start and date <= self.date_end: | ||
vals["date"] = date | ||
self.timesheet_ids |= self.env["account.analytic.line"]._sheet_create(vals) | ||
|
||
def _get_default_days_history(self): | ||
return 20 |
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,4 @@ | ||
* `Akretion <https://www.akretion.com>`_: | ||
|
||
* David BEAL <[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,8 @@ | ||
Add a field to select task among last used timesheet ones | ||
|
||
|
||
Here is `Timesheet candidates` field display tasks on which you recorded time recently. | ||
|
||
|
||
.. figure:: ../static/description/im1.png | ||
:alt: Timesheet candidates field |
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,7 @@ | ||
|
||
|
||
.. figure:: ../static/description/im2.png | ||
|
||
|
||
|
||
.. figure:: ../static/description/im3.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.