From 1773384f54c2e3ab11ea4278384fa68983816781 Mon Sep 17 00:00:00 2001 From: Thor Date: Tue, 21 Dec 2021 14:45:44 +0100 Subject: [PATCH] [ADD] hr_timesheet_stop_button: In Timesheets new fields: Start Date, and End Date. Also new button "Put end date". --- hr_timesheet_stop_button/README.rst | 30 +++++++++++++ hr_timesheet_stop_button/__init__.py | 3 ++ hr_timesheet_stop_button/__manifest__.py | 17 +++++++ hr_timesheet_stop_button/i18n/es.po | 45 +++++++++++++++++++ .../i18n/hr_timesheet_stop_button.pot | 45 +++++++++++++++++++ hr_timesheet_stop_button/models/__init__.py | 1 + .../models/account_analytic_line.py | 22 +++++++++ .../views/account_analytic_line_views.xml | 36 +++++++++++++++ 8 files changed, 199 insertions(+) create mode 100644 hr_timesheet_stop_button/README.rst create mode 100644 hr_timesheet_stop_button/__init__.py create mode 100644 hr_timesheet_stop_button/__manifest__.py create mode 100644 hr_timesheet_stop_button/i18n/es.po create mode 100644 hr_timesheet_stop_button/i18n/hr_timesheet_stop_button.pot create mode 100644 hr_timesheet_stop_button/models/__init__.py create mode 100644 hr_timesheet_stop_button/models/account_analytic_line.py create mode 100644 hr_timesheet_stop_button/views/account_analytic_line_views.xml diff --git a/hr_timesheet_stop_button/README.rst b/hr_timesheet_stop_button/README.rst new file mode 100644 index 00000000..1c18c90e --- /dev/null +++ b/hr_timesheet_stop_button/README.rst @@ -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 +`_. 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 +* Alfredo de la Fuente + +Do not contact contributors directly about support or help with technical issues. diff --git a/hr_timesheet_stop_button/__init__.py b/hr_timesheet_stop_button/__init__.py new file mode 100644 index 00000000..1fd704ff --- /dev/null +++ b/hr_timesheet_stop_button/__init__.py @@ -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 diff --git a/hr_timesheet_stop_button/__manifest__.py b/hr_timesheet_stop_button/__manifest__.py new file mode 100644 index 00000000..697d2692 --- /dev/null +++ b/hr_timesheet_stop_button/__manifest__.py @@ -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, +} diff --git a/hr_timesheet_stop_button/i18n/es.po b/hr_timesheet_stop_button/i18n/es.po new file mode 100644 index 00000000..398b28ff --- /dev/null +++ b/hr_timesheet_stop_button/i18n/es.po @@ -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" + diff --git a/hr_timesheet_stop_button/i18n/hr_timesheet_stop_button.pot b/hr_timesheet_stop_button/i18n/hr_timesheet_stop_button.pot new file mode 100644 index 00000000..4dddf224 --- /dev/null +++ b/hr_timesheet_stop_button/i18n/hr_timesheet_stop_button.pot @@ -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 "" + diff --git a/hr_timesheet_stop_button/models/__init__.py b/hr_timesheet_stop_button/models/__init__.py new file mode 100644 index 00000000..f69550ae --- /dev/null +++ b/hr_timesheet_stop_button/models/__init__.py @@ -0,0 +1 @@ +from . import account_analytic_line diff --git a/hr_timesheet_stop_button/models/account_analytic_line.py b/hr_timesheet_stop_button/models/account_analytic_line.py new file mode 100644 index 00000000..8d150ce2 --- /dev/null +++ b/hr_timesheet_stop_button/models/account_analytic_line.py @@ -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}) diff --git a/hr_timesheet_stop_button/views/account_analytic_line_views.xml b/hr_timesheet_stop_button/views/account_analytic_line_views.xml new file mode 100644 index 00000000..a291ae0d --- /dev/null +++ b/hr_timesheet_stop_button/views/account_analytic_line_views.xml @@ -0,0 +1,36 @@ + + + + account.analytic.line + + + + + + + + + + + + + + + + + account.analytic.line + + + + + + + + + + +