Skip to content

Commit

Permalink
Move sale_timesheet_custom_fields from onesteinbv/ProjectManagement
Browse files Browse the repository at this point in the history
  • Loading branch information
tarteo committed Dec 10, 2024
1 parent 8bef5ca commit fbbbdac
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 0 deletions.
1 change: 1 addition & 0 deletions sale_timesheet_custom_fields/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions sale_timesheet_custom_fields/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Timesheet Custom Fields",
"version": "16.0.1.0.0",
"summary": "Adds custom fields and related filters",
"author": "Onestein",
"license": "AGPL-3",
"website": "https://www.onestein.nl",
"category": "Human Resources",
"depends": [
"sale_timesheet",
],
"data": [
"views/hr_timesheet_views.xml",
],
"installable": True,
}
42 changes: 42 additions & 0 deletions sale_timesheet_custom_fields/i18n/nl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_timesheet_custom_fields
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-03-26 12:39+0000\n"
"PO-Revision-Date: 2024-03-26 12:39+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: sale_timesheet_custom_fields
#: model_terms:ir.ui.view,arch_db:sale_timesheet_custom_fields.hr_timesheet_line_search
msgid "Day"
msgstr "Dag"

#. module: sale_timesheet_custom_fields
#: model_terms:ir.ui.view,arch_db:sale_timesheet_custom_fields.hr_timesheet_line_search
msgid "Group By"
msgstr "Groepeer op"

#. module: sale_timesheet_custom_fields
#: model:ir.model.fields,field_description:sale_timesheet_custom_fields.field_account_analytic_line__project_user_id
#: model_terms:ir.ui.view,arch_db:sale_timesheet_custom_fields.hr_timesheet_line_search
msgid "Project Manager"
msgstr "Projectleider"

#. module: sale_timesheet_custom_fields
#: model_terms:ir.ui.view,arch_db:sale_timesheet_custom_fields.hr_timesheet_line_search
msgid "Week"
msgstr ""

#. module: sale_timesheet_custom_fields
#: model:ir.model.fields,field_description:sale_timesheet_custom_fields.field_account_analytic_line__week_number
msgid "Week Number"
msgstr "Weeknummer"
3 changes: 3 additions & 0 deletions sale_timesheet_custom_fields/models/__init__.py
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).

from . import account_analytic_line
19 changes: 19 additions & 0 deletions sale_timesheet_custom_fields/models/account_analytic_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"

@api.depends("date")
def _compute_week_number(self):
for line in self:
week_number = line.date.isocalendar()
line.week_number = "W%s %s" % (str(week_number[1]), (str(week_number[0])))

project_user_id = fields.Many2one(
"res.users", related="project_id.user_id", store=True
)
week_number = fields.Char(compute="_compute_week_number", store=True)
28 changes: 28 additions & 0 deletions sale_timesheet_custom_fields/views/hr_timesheet_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_timesheet_line_tree" model="ir.ui.view">
<field name="name">account.analytic.line.tree</field>
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='unit_amount']" position="after">
<field name="week_number" optional="show" />
</xpath>
</field>
</record>

<record id="hr_timesheet_line_search" 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">
<xpath expr="/search" position="inside">
<group string="Group By" name="groupby">
<filter name="groupby_project_manager" string="Project Manager" context="{'group_by': 'project_user_id'}"/>
<filter name="groupby_week_number" string="Week" context="{'group_by': 'week_number'}"/>
<filter name="groupby_day" string="Day" context="{'group_by': 'date:day'}"/>
</group>
</xpath>
</field>
</record>

</odoo>

0 comments on commit fbbbdac

Please sign in to comment.