Merge PR #1363 into 17.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2024-10-16 10:11:11 +00:00
18 changed files with 625 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
=================================
Quality Control - Timesheet (OCA)
=================================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c2e64dc6606c845bb75e06ed854b15fc84a222c2d97408272e22e530092f5b86
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/17.0/quality_control_oca_timesheet
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-17-0/manufacture-17-0-quality_control_oca_timesheet
: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/manufacture&target_branch=17.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module integrates timesheet tracking with quality control
inspections. It adds a "Timesheets" tab to the quality control
inspection form, allowing users to log and track the time spent on each
inspection through timesheet entries. Users can record detailed
timesheet data, such as the project, task, date, and duration for each
inspection. Additionally, the module automatically calculates the total
hours spent on inspections and displays this information in both the
form view and the list view of quality control inspections.
**Table of contents**
.. contents::
:local:
Usage
=====
When creating or editing a quality control inspection, you will find a
new Timesheets tab within the inspection form. In this tab, you can log
and track the time spent on the inspection by adding timesheet entries.
Each entry allows you to specify the project, task, date, and the time
spent on the inspection in hours and minutes.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/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/manufacture/issues/new?body=module:%20quality_control_oca_timesheet%0Aversion:%2017.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
-------
* APSL-Nagarro
Contributors
------------
- `APSL-Nagarro <https://apsl.tech>`__:
- Patryk Pyczko <ppyczko@apsl.net>
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.
.. |maintainer-ppyczko| image:: https://github.com/ppyczko.png?size=40px
:target: https://github.com/ppyczko
:alt: ppyczko
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-ppyczko|
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/17.0/quality_control_oca_timesheet>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models

View File

@@ -0,0 +1,16 @@
# Copyright 2024 Patryk Pyczko (APSL-Nagarro)<ppyczko@apsl.net>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Quality Control - Timesheet (OCA)",
"version": "17.0.1.0.0",
"category": "Quality Control",
"website": "https://github.com/OCA/manufacture",
"author": "APSL-Nagarro, Odoo Community Association (OCA)",
"maintainers": ["ppyczko"],
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["quality_control_oca", "hr_timesheet"],
"data": ["views/qc_inspection_view.xml"],
}

View File

@@ -0,0 +1,59 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * quality_control_oca_timesheet
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-15 11:09+0000\n"
"PO-Revision-Date: 2024-10-15 11:09+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: quality_control_oca_timesheet
#: model:ir.model,name:quality_control_oca_timesheet.model_account_analytic_line
msgid "Analytic Line"
msgstr "Línia analítica"
#. module: quality_control_oca_timesheet
#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit
msgid "Duration (Hour(s))"
msgstr "Durada (Hora/es)"
#. module: quality_control_oca_timesheet
#: model:ir.model,name:quality_control_oca_timesheet.model_qc_inspection
msgid "Quality control inspection"
msgstr "Inspecció de control de qualitat"
#. module: quality_control_oca_timesheet
#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_account_analytic_line__qc_inspection_id
msgid "Related QC Inspection"
msgstr "Inspecció de QC relacionada"
#. module: quality_control_oca_timesheet
#: model:ir.model.fields,help:quality_control_oca_timesheet.field_account_analytic_line__qc_inspection_id
msgid "The quality control inspection related to this timesheet entry."
msgstr "La inspecció de control de qualitat relacionada amb aquesta entrada de full d'hores."
#. module: quality_control_oca_timesheet
#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_qc_inspection__timesheet_ids
#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit
msgid "Timesheets"
msgstr "Fulls d'hores"
#. module: quality_control_oca_timesheet
#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_qc_inspection__timesheet_total_hours
#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit
#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_tree_view_timesheet_inherit
msgid "Total Hours"
msgstr "Hores totals"
#. module: quality_control_oca_timesheet
#: model:ir.model.fields,help:quality_control_oca_timesheet.field_qc_inspection__timesheet_total_hours
msgid "Total hours spent on this quality control inspection."
msgstr "Hores totals dedicades a aquesta inspecció de control de qualitat."

View File

@@ -0,0 +1,59 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * quality_control_oca_timesheet
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-15 11:10+0000\n"
"PO-Revision-Date: 2024-10-15 11:10+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: quality_control_oca_timesheet
#: model:ir.model,name:quality_control_oca_timesheet.model_account_analytic_line
msgid "Analytic Line"
msgstr "Línea analítica"
#. module: quality_control_oca_timesheet
#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit
msgid "Duration (Hour(s))"
msgstr "Duración (Hora/s)"
#. module: quality_control_oca_timesheet
#: model:ir.model,name:quality_control_oca_timesheet.model_qc_inspection
msgid "Quality control inspection"
msgstr "Inspección del control de calidad"
#. module: quality_control_oca_timesheet
#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_account_analytic_line__qc_inspection_id
msgid "Related QC Inspection"
msgstr "Inspección de QC relacionada"
#. module: quality_control_oca_timesheet
#: model:ir.model.fields,help:quality_control_oca_timesheet.field_account_analytic_line__qc_inspection_id
msgid "The quality control inspection related to this timesheet entry."
msgstr "La inspección de control de calidad relacionada con esta entrada de parte de horas."
#. module: quality_control_oca_timesheet
#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_qc_inspection__timesheet_ids
#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit
msgid "Timesheets"
msgstr "Partes de horas"
#. module: quality_control_oca_timesheet
#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_qc_inspection__timesheet_total_hours
#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit
#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_tree_view_timesheet_inherit
msgid "Total Hours"
msgstr "Horas totales"
#. module: quality_control_oca_timesheet
#: model:ir.model.fields,help:quality_control_oca_timesheet.field_qc_inspection__timesheet_total_hours
msgid "Total hours spent on this quality control inspection."
msgstr "Horas totales dedicadas a esta inspección de control de calidad."

View File

@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import qc_inspection
from . import hr_timesheet

View File

@@ -0,0 +1,14 @@
# Copyright 2024 Patryk Pyczko (APSL-Nagarro)<ppyczko@apsl.net>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"
qc_inspection_id = fields.Many2one(
"qc.inspection",
string="Related QC Inspection",
help="The quality control inspection related to this timesheet entry.",
)

View File

@@ -0,0 +1,28 @@
# Copyright 2024 Patryk Pyczko (APSL-Nagarro)<ppyczko@apsl.net>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class QcInspection(models.Model):
_inherit = "qc.inspection"
timesheet_ids = fields.One2many(
"account.analytic.line",
"qc_inspection_id",
string="Timesheets",
)
timesheet_total_hours = fields.Float(
string="Total Hours",
compute="_compute_timesheet_total_hours",
store=True,
help="Total hours spent on this quality control inspection.",
)
@api.depends("timesheet_ids.unit_amount")
def _compute_timesheet_total_hours(self):
for inspection in self:
inspection.timesheet_total_hours = sum(
inspection.timesheet_ids.mapped("unit_amount")
)

View File

@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@@ -0,0 +1,3 @@
- [APSL-Nagarro](https://apsl.tech):
> - Patryk Pyczko \<<ppyczko@apsl.net>\>

View File

@@ -0,0 +1 @@
This module integrates timesheet tracking with quality control inspections. It adds a "Timesheets" tab to the quality control inspection form, allowing users to log and track the time spent on each inspection through timesheet entries. Users can record detailed timesheet data, such as the project, task, date, and duration for each inspection. Additionally, the module automatically calculates the total hours spent on inspections and displays this information in both the form view and the list view of quality control inspections.

View File

@@ -0,0 +1 @@
When creating or editing a quality control inspection, you will find a new Timesheets tab within the inspection form. In this tab, you can log and track the time spent on the inspection by adding timesheet entries. Each entry allows you to specify the project, task, date, and the time spent on the inspection in hours and minutes.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 45 KiB

View File

@@ -0,0 +1,124 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Module name</h2>
<p>This module was written to extend the functionality of ... to support ... and allow you to ...</p>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Installation</h2>
</div>
<div class="oe_span6">
<p class="oe_mt32">To install this module, you need to:
<ul>
<li>...</li>
</ul>
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<a href="https://www.odoo.com/saas_master/demo?lang=en_US&module=crm">
<img src="crm_sc_01.png">
</a>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Configuration</h2>
</div>
<div class="oe_span6">
<p class="oe_mt32">To configure this module, you need to:
<ul>
<li>...</li>
</ul>
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<a href="https://www.odoo.com/saas_master/demo?lang=en_US&module=crm">
<img src="crm_sc_01.png">
</a>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Usage</h2>
</div>
<div class="oe_span6">
<p class="oe_mt32">To use this module, you need to:
<ul>
<li>...</li>
</ul>
</p>
<p class="oe_mt32">For further information, please visit:
<ul>
<li><a href="https://www.odoo.com/forum/help-1">https://www.odoo.com/forum/help-1</a></li>
</ul>
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<a href="https://www.odoo.com/saas_master/demo?lang=en_US&module=crm">
<img src="crm_sc_01.png">
</a>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Known issues / Roadmap</h2>
</div>
<div class="oe_span6">
<p class="oe_mt32">
<ul>
<li>...</li>
</ul>
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<a href="https://www.odoo.com/saas_master/demo?lang=en_US&module=crm">
<img src="crm_sc_01.png">
</a>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row">
<div class="oe_span12">
<h2 class="oe_slogan">Credits</h2>
</div>
<div class="oe_span12">
<h3>Contributors</h3>
<ul>
<li>Firstname Lastname &lt;<a href="mailto:email.address@example.com">email.address@example.com</a>&gt;</li>
</ul>
</div>
<div class="oe_span12">
<h3>Maintainer</h3>
<p>
This module is maintained by the OCA.<br/>
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.<br/>
To contribute to this module, please visit <a href="http://odoo-community.org">http://odoo-community.org</a>.<br/>
<a href="http://odoo-community.org"><img class="oe_picture oe_centered" src="http://odoo-community.org/logo.png"></a>
</p>
</div>
</div>
</section>

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import test_quality_control_oca_timesheet

View File

@@ -0,0 +1,75 @@
# Copyright 2024 Patryk Pyczko (APSL-Nagarro)<ppyczko@apsl.net>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
class TestQcInspectionTimesheetTotalHours(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.qc_inspection = cls.env["qc.inspection"].create(
{
"name": "Test Inspection",
}
)
def test_no_timesheets(self):
"""Test total hours when no timesheets are associated"""
self.assertEqual(
self.qc_inspection.timesheet_total_hours,
0,
"Total hours should be 0 when there are no timesheets.",
)
def test_one_timesheet(self):
"""Test total hours with one timesheet"""
self.env["account.analytic.line"].create(
{
"qc_inspection_id": self.qc_inspection.id,
"unit_amount": 5.0,
"name": "Timesheet 1",
}
)
self.qc_inspection._compute_timesheet_total_hours()
self.assertEqual(
self.qc_inspection.timesheet_total_hours,
5.0,
"Total hours should be 5 with one timesheet entry.",
)
def test_multiple_timesheets(self):
"""Test total hours with multiple timesheets"""
self.env["account.analytic.line"].create(
{
"qc_inspection_id": self.qc_inspection.id,
"unit_amount": 3.0,
"name": "Timesheet 1",
}
)
self.env["account.analytic.line"].create(
{
"qc_inspection_id": self.qc_inspection.id,
"unit_amount": 2.5,
"name": "Timesheet 2",
}
)
self.env["account.analytic.line"].create(
{
"qc_inspection_id": self.qc_inspection.id,
"unit_amount": 1.5,
"name": "Timesheet 3",
}
)
self.qc_inspection._compute_timesheet_total_hours()
self.assertEqual(
self.qc_inspection.timesheet_total_hours,
7.0,
"Total hours should be 7 (3 + 2.5 + 1.5) with multiple timesheets.",
)

View File

@@ -0,0 +1,51 @@
<odoo>
<record id="qc_inspection_form_view_timesheet_inherit" model="ir.ui.view">
<field name="name">qc.inspection.form.view.timesheet</field>
<field name="model">qc.inspection</field>
<field name="inherit_id" ref="quality_control_oca.qc_inspection_form_view" />
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Timesheets">
<field name="timesheet_ids">
<tree editable="bottom" delete="true">
<field name="company_id" invisible="1" />
<field name="project_id" />
<field name="task_id" />
<field name="date" widget="date" />
<field name="user_id" required="1" />
<field name="name" required="0" />
<field
name="unit_amount"
string="Duration (Hour(s))"
widget="float_time"
/>
</tree>
</field>
<group class="oe_subtotal_footer oe_right">
<field
name="timesheet_total_hours"
widget="float_time"
string="Total Hours"
/>
</group>
</page>
</xpath>
</field>
</record>
<record id="qc_inspection_tree_view_timesheet_inherit" model="ir.ui.view">
<field name="name">qc.inspection.tree.view.timesheet.inherit</field>
<field name="model">qc.inspection</field>
<field name="inherit_id" ref="quality_control_oca.qc_inspection_tree_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='state']" position="after">
<field
name="timesheet_total_hours"
string="Total Hours"
widget="timesheet_uom"
/>
</xpath>
</field>
</record>
</odoo>