-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] hr_timesheet_stop_button: In Timesheets new fields: Start Date,…
… and End Date. Also new button "Put end date".
- Loading branch information
1 parent
b561306
commit c75f6ac
Showing
8 changed files
with
251 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,30 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
======================== | ||
Hr timesheet stop button | ||
======================== | ||
|
||
* In Timesheets new fields: Start Date, and End Date. Also new button "Put end | ||
date". | ||
* When the new button is clicked, the difference between the new dates is | ||
calculated. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/avanzosc/hr-addons/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smash it by providing detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
* Ana Juaristi <[email protected]> | ||
* Alfredo de la Fuente <[email protected]> | ||
|
||
Do not contact contributors directly about support or help with technical issues. |
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 @@ | ||
# Copyright 2019 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.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,17 @@ | ||
# Copyright 2021 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
{ | ||
"name": "Hr Timesheet Stop Button", | ||
"version": "12.0.1.0.0", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"hr_timesheet", | ||
], | ||
"author": "AvanzOSC", | ||
"website": "http://www.avanzosc.es", | ||
"category": "Human Resources", | ||
"data": [ | ||
"views/account_analytic_line_views.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,55 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * hr_timesheet_stop_button | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2021-12-21 14:36+0000\n" | ||
"PO-Revision-Date: 2021-12-21 14:36+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model:ir.model,name:hr_timesheet_stop_button.model_account_analytic_line | ||
msgid "Analytic Line" | ||
msgstr "Línea Analítica" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model:ir.model.fields,field_description:hr_timesheet_stop_button.field_account_analytic_line__customer_id | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_search_inh_stop_button | ||
msgid "Customer" | ||
msgstr "Cliente" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model:ir.model.fields,field_description:hr_timesheet_stop_button.field_account_analytic_line__end_date | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_search_inh_stop_button | ||
msgid "End date" | ||
msgstr "Fecha fin" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_tree_user | ||
msgid "Put end date" | ||
msgstr "Poner fecha fin" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model:ir.model.fields,field_description:hr_timesheet_stop_button.field_account_analytic_line__start_date | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_search_inh_stop_button | ||
msgid "Start date" | ||
msgstr "Fecha inicio" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_tree_user | ||
msgid "Timesheet Activities" | ||
msgstr "Actividades del parte de horas" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_tree_user | ||
msgid "Total" | ||
msgstr "" | ||
|
55 changes: 55 additions & 0 deletions
55
hr_timesheet_stop_button/i18n/hr_timesheet_stop_button.pot
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,55 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * hr_timesheet_stop_button | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2021-12-21 14:35+0000\n" | ||
"PO-Revision-Date: 2021-12-21 14:35+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model:ir.model,name:hr_timesheet_stop_button.model_account_analytic_line | ||
msgid "Analytic Line" | ||
msgstr "" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model:ir.model.fields,field_description:hr_timesheet_stop_button.field_account_analytic_line__customer_id | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_search_inh_stop_button | ||
msgid "Customer" | ||
msgstr "" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model:ir.model.fields,field_description:hr_timesheet_stop_button.field_account_analytic_line__end_date | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_search_inh_stop_button | ||
msgid "End date" | ||
msgstr "" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_tree_user | ||
msgid "Put end date" | ||
msgstr "" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model:ir.model.fields,field_description:hr_timesheet_stop_button.field_account_analytic_line__start_date | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_search_inh_stop_button | ||
msgid "Start date" | ||
msgstr "" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_tree_user | ||
msgid "Timesheet Activities" | ||
msgstr "" | ||
|
||
#. module: hr_timesheet_stop_button | ||
#: model_terms:ir.ui.view,arch_db:hr_timesheet_stop_button.hr_timesheet_line_tree_user | ||
msgid "Total" | ||
msgstr "" | ||
|
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 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,32 @@ | ||
# Copyright 2021 Alfredo de la fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from odoo import models, fields, api | ||
|
||
|
||
class AccountAnalyticLine(models.Model): | ||
_inherit = 'account.analytic.line' | ||
|
||
customer_id = fields.Many2one( | ||
string='Customer', comodel_name='res.partner') | ||
start_date = fields.Datetime( | ||
string='Start date', default=fields.datetime.now()) | ||
end_date = fields.Datetime( | ||
string='End date') | ||
|
||
@api.onchange('start_date', 'end_date') | ||
def _onchange_start_end_date(self): | ||
self.unit_amount = 0 | ||
if self.start_date: | ||
self.date = self.start_date.date() | ||
if (self.start_date and self.end_date and | ||
self.end_date > self.start_date): | ||
delta = self.end_date - self.start_date | ||
self.unit_amount = delta.total_seconds() / 3600.0 | ||
|
||
def action_end_button(self): | ||
if self.start_date: | ||
end_date = fields.datetime.now() | ||
delta = end_date - self.start_date | ||
duration = delta.total_seconds() / 3600.0 | ||
self.write({'end_date': end_date, | ||
'unit_amount': duration}) |
58 changes: 58 additions & 0 deletions
58
hr_timesheet_stop_button/views/account_analytic_line_views.xml
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,58 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="hr_timesheet_line_tree_user" model="ir.ui.view"> | ||
<field name="name">account.analytic.line.tree.user</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="arch" type="xml"> | ||
<tree editable="top" string="Timesheet Activities" import="false"> | ||
<field name="date"/> | ||
<field name="name"/> | ||
<field name="project_id" required="1"/> | ||
<field name="customer_id" domain="[('customer','=',True)]"/> | ||
<field name="task_id" context="{'default_project_id': project_id}" domain="[('project_id', '=', project_id)]"/> | ||
<field name="start_date" invisible="1"/> | ||
<field name="end_date" invisible="1"/> | ||
<field name="unit_amount" widget="timesheet_uom" sum="Total"/> | ||
<button name="action_end_button" string="Put end date" type="object" icon="fa-check text-success"/> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="hr_timesheet_line_search_inh_stop_button" model="ir.ui.view"> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_search" /> | ||
<field name="arch" type="xml"> | ||
<field name="employee_id" position="after"> | ||
<field name="customer_id" /> | ||
</field> | ||
<filter name="groupby_employee" position="after"> | ||
<filter string="Customer" name="groupby_customer" domain="[]" context="{'group_by':'customer_id'}"/> | ||
</filter> | ||
<filter name="groupby_date" position="after"> | ||
<filter string="Start date" name="groupby_startdate" domain="[]" context="{'group_by':'start_date'}" /> | ||
<filter string="End date" name="groupby_enddate" domain="[]" context="{'group_by':'end_date'}" /> | ||
</filter> | ||
</field> | ||
</record> | ||
|
||
<record id="hr_timesheet_line_tree_inh_stop_button" model="ir.ui.view"> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="project_id" position="before"> | ||
<field name="customer_id" domain="[('customer','=',True)]"/> | ||
</field> | ||
<field name="unit_amount" position="before"> | ||
<field name="start_date" /> | ||
<field name="end_date" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="hr_timesheet.act_hr_timesheet_line_view_tree" model="ir.actions.act_window.view"> | ||
<field name="view_mode">tree</field> | ||
<field name="sequence" eval="4"/> | ||
<field name="view_id" ref="hr_timesheet_line_tree_user"/> | ||
<field name="act_window_id" ref="hr_timesheet.act_hr_timesheet_line"/> | ||
</record> | ||
</odoo> |