Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from brainbeanapps/12.0-add-hr_timesheet_task…
…_domain [12.0][ADD] hr_timesheet_task_domain: task domain depends on project
- Loading branch information
Showing
10 changed files
with
659 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,86 @@ | ||
=============================== | ||
Task Log: limit Task by Project | ||
=============================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/12.0/hr_timesheet_task_domain | ||
:alt: OCA/timesheet | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/timesheet-12-0/timesheet-12-0-hr_timesheet_task_domain | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/117/12.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module adjusts the domain applied to task field in order to limit task | ||
selection to currently-selected project. If `project_stage_closed` module is | ||
installed, also limits selection to tasks in any of "Open" stages in order to | ||
accommodate a project flow. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
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 smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/timesheet/issues/new?body=module:%20hr_timesheet_task_domain%0Aversion:%2012.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 | ||
~~~~~~~ | ||
|
||
* Tecnativa | ||
* Brainbean Apps | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* Pedro M. Baeza | ||
* Antonio Espinosa | ||
* Carlos Dauden | ||
* Sergio Teruel | ||
* Luis M. ontalba | ||
* Ernesto Tejeda | ||
|
||
* Alexey Pelykh <alexey.pelykh@brainbeanapps.com> | ||
|
||
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/12.0/hr_timesheet_task_domain>`_ 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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
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,26 @@ | ||
# Copyright 2016 Tecnativa - Antonio Espinosa | ||
# Copyright 2016 Tecnativa - Sergio Teruel | ||
# Copyright 2016-2018 Tecnativa - Pedro M. Baeza | ||
# Copyright 2018 Tecnativa - Ernesto Tejeda | ||
# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
'name': 'Task Log: limit Task by Project', | ||
'version': '12.0.1.0.0', | ||
'category': 'Human Resources', | ||
'website': 'https://github.com/OCA/hr-timesheet', | ||
'author': | ||
'Tecnativa, ' | ||
'Brainbean Apps, ' | ||
'Odoo Community Association (OCA)', | ||
'license': 'AGPL-3', | ||
'installable': True, | ||
'application': False, | ||
'summary': ( | ||
'Limit task selection to tasks on currently-selected project' | ||
), | ||
'depends': [ | ||
'hr_timesheet', | ||
], | ||
} |
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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import account_analytic_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,47 @@ | ||
# Copyright 2016 Tecnativa - Antonio Espinosa | ||
# Copyright 2016 Tecnativa - Sergio Teruel | ||
# Copyright 2016-2018 Tecnativa - Pedro M. Baeza | ||
# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models, api | ||
|
||
|
||
class AccountAnalyticLine(models.Model): | ||
_inherit = 'account.analytic.line' | ||
|
||
@api.onchange('project_id') | ||
def onchange_project_id(self): | ||
# Check if 'closed' field exists (provided by project_stage_closed) | ||
project_stage_closed = 'project.stage' in self.env \ | ||
and 'closed' in self.env['project.stage']._fields | ||
|
||
task = self.task_id | ||
res = super().onchange_project_id() | ||
if res is None: | ||
res = {} | ||
if self.project_id: # Show only opened tasks | ||
task_domain = [ | ||
('project_id', '=', self.project_id.id), | ||
] | ||
if project_stage_closed: | ||
task_domain = task_domain + [ | ||
('stage_id.closed', '=', False), | ||
] | ||
res_domain = res.setdefault('domain', {}) | ||
res_domain.update({ | ||
'task_id': task_domain, | ||
}) | ||
else: # Reset domain for allowing selection of any task | ||
res['domain'] = {'task_id': []} | ||
if task.project_id == self.project_id: | ||
# Restore previous task if belongs to the same project | ||
self.task_id = task | ||
return res | ||
|
||
@api.onchange('task_id') | ||
def _onchange_task_id(self): | ||
super()._onchange_task_id() | ||
|
||
if self.task_id: | ||
self.project_id = self.task_id.project_id |
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,10 @@ | ||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* Pedro M. Baeza | ||
* Antonio Espinosa | ||
* Carlos Dauden | ||
* Sergio Teruel | ||
* Luis M. ontalba | ||
* Ernesto Tejeda | ||
|
||
* Alexey Pelykh <alexey.pelykh@brainbeanapps.com> |
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 @@ | ||
This module adjusts the domain applied to task field in order to limit task | ||
selection to currently-selected project. If `project_stage_closed` module is | ||
installed, also limits selection to tasks in any of "Open" stages in order to | ||
accommodate a project flow. |
Oops, something went wrong.