Skip to content

Commit

Permalink
[ADD] hr_timesheet_stop_button: In Timesheets new fields: Start Date,…
Browse files Browse the repository at this point in the history
… and End Date. Also new button "Put end date".
  • Loading branch information
alfredoavanzosc committed Dec 21, 2021
1 parent b561306 commit 1773384
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 0 deletions.
30 changes: 30 additions & 0 deletions hr_timesheet_stop_button/README.rst
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.
3 changes: 3 additions & 0 deletions hr_timesheet_stop_button/__init__.py
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
17 changes: 17 additions & 0 deletions hr_timesheet_stop_button/__manifest__.py
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,
}
45 changes: 45 additions & 0 deletions hr_timesheet_stop_button/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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 13:42+0000\n"
"PO-Revision-Date: 2021-12-21 13:42+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_inh_stop_button
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"

45 changes: 45 additions & 0 deletions hr_timesheet_stop_button/i18n/hr_timesheet_stop_button.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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 13:41+0000\n"
"PO-Revision-Date: 2021-12-21 13:41+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_inh_stop_button
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 ""

1 change: 1 addition & 0 deletions hr_timesheet_stop_button/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_analytic_line
22 changes: 22 additions & 0 deletions hr_timesheet_stop_button/models/account_analytic_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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


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')

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})
36 changes: 36 additions & 0 deletions hr_timesheet_stop_button/views/account_analytic_line_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<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" readonly="1"/>
<field name="end_date" readonly="1"/>
</field>
<field name="unit_amount" position="after">
<button name="action_end_button" string="Put end date" type="object" icon="fa-check text-success"/>
</field>
</field>
</record>
</odoo>

0 comments on commit 1773384

Please sign in to comment.