Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] sale_timesheet_rounded: Migration to 17.0 #659

Merged
merged 15 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions sale_timesheet_rounded/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
======================
Sale Timesheet Rounded
======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1978ba49c441473463786ded6958a21b6876f6b317a72dde30b11512afa456a8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Ftimesheet-lightgray.png?logo=github
:target: https://github.com/OCA/timesheet/tree/17.0/sale_timesheet_rounded
:alt: OCA/timesheet
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/timesheet-17-0/timesheet-17-0-sale_timesheet_rounded
: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/timesheet&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Round timesheet lines amounts in sales based on project' settings.

A typical use case is: you work 5 minutes but you want to invoice 15
minutes.

With this module you can configure a rounding unit or factor on the
project and all the lines tracked on this project's tasks will show a
rounded amount.

If you want you can override the value manually on each entry.

The delivered quantity on the sale order line - and by consequence on
the invoice - will be computed using the rounded amount. Therefore,
expense lines and other non-timesheet lines will be updated with a
rounded amount that is equal to the amount.

WARNING: This module cannot be used with timesheet_grid without further
adapation as an update of an existing timesheet line will NOT update the
rounded amount. To achieve this, you need to override adjust_grid
function to pass the force_compute context key.

**Table of contents**

.. contents::
:local:

Configuration
=============

Go to a project and set the following fields according to your needs:

- Timesheet rounding unit

Defines the rounding unit. For instance, if you want to round to 1 hour,
you can set 1.0. If you want to round to 15 min set 0.25.

- Timesheet rounding method

Options: "No" (default), "Closest", "Up", "Down".

Please refer to odoo.tools.float_utils.float_round to understand the
difference.

- Timesheet rounding factor (percentage)

When round unit is not defined you can round by a fixed %.

When using both a unit and a factor, the factor will be applied first:

result = round(amount \* percentage, unit)

Known issues / Roadmap
======================

- improve test coverage

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/timesheet/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/timesheet/issues/new?body=module:%20sale_timesheet_rounded%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
-------

* Camptocamp

Contributors
------------

- Simone Orsi <simone.orsi@camptocamp.com>
- Thomas Nowicki <thomas.nowicki@camptocamp.com>
- Akim Juillerat <akim.juillerat@camptocamp.com>
- Foram Shah <foram.shah@initos.com>
- Phuc Kieu <phuckh@trobz.com>
- Son Ho <sonhd@trobz.com>

Other credits
-------------

The migration of this sale_timesheet_rounded from 16.0 to 17.0 was
financially supported by Camptocamp

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.

This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/17.0/sale_timesheet_rounded>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions sale_timesheet_rounded/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import models
from .hooks import pre_init_hook
from . import wizard
21 changes: 21 additions & 0 deletions sale_timesheet_rounded/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2019 Camptocamp SA
# Copyright 2020 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "Sale Timesheet Rounded",
"summary": "Round timesheet entries amount based on project settings.",
"version": "17.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Sales",
"website": "https://github.com/OCA/timesheet",
"depends": ["project", "hr_timesheet", "sale_timesheet"],
"data": [
# Views
"views/account_analytic_line.xml",
"views/project_project.xml",
"views/project_task.xml",
],
"installable": True,
"pre_init_hook": "pre_init_hook",
}
28 changes: 28 additions & 0 deletions sale_timesheet_rounded/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2019 Camptocamp SA
# Copyright 2020 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

import logging

from psycopg2 import sql

_logger = logging.getLogger(__name__)


def pre_init_hook(env):
"""Initialize the value of the given column for existing rows in a fast way."""
_logger.info(
"Initializing column `unit_amount_rounded` with the " "value of `unit_amount`"
)
table = sql.Identifier("account_analytic_line")
column = sql.Identifier("unit_amount_rounded")
env.cr.execute( # pylint: disable=E8103
sql.SQL("ALTER TABLE {} ADD COLUMN IF NOT EXISTS {} NUMERIC").format(
table, column
)
)
env.cr.execute( # pylint: disable=E8103
sql.SQL(
"UPDATE {table} SET {column} = unit_amount WHERE {column} IS NULL"
).format(table=table, column=column)
)
157 changes: 157 additions & 0 deletions sale_timesheet_rounded/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_timesheet_rounded
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2019-09-26 14:24+0000\n"
"Last-Translator: Akim Juillerat <akim.juillerat@camptocamp.com>\n"
"Language-Team: none\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.8\n"

#. module: sale_timesheet_rounded
#: model:ir.model.fields,help:sale_timesheet_rounded.field_project_project__timesheet_rounding_unit
msgid ""
"1.0 = hour\n"
" 0.25 = 15 min\n"
" 0.084 ~= 5 min\n"
" 0.017 ~= 1 min\n"
" "
msgstr ""
"1.0 = Stunde\n"
" 0.25 = 15 Min\n"
" 0.084 ~= 5 Min\n"
" 0.017 ~= 1 Min\n"
" "

#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_kanban_inherit
#, fuzzy
msgid ""
"<br/>\n"
" <strong>Rounded: </strong>"
msgstr ""
"<br/>\n"
" <strong>Gerundet: </strong>"

#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_analytic_line
msgid "Analytic Line"
msgstr "Kostenstellen Buchung"

#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__half_up
msgid "Closest"
msgstr "Am nächsten"

#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_account_analytic_line__display_name
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__display_name
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_sale_order_line__display_name
msgid "Display Name"
msgstr ""

#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__down
msgid "Down"
msgstr "Nach unten"

#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.hr_timesheet_view_task_form2_inherited_inherit
msgid "Duration (rounded)"
msgstr "Geleistete Stunden (gerundet)"

#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_account_analytic_line__id
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__id
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_sale_order_line__id
msgid "ID"
msgstr ""

#. module: sale_timesheet_rounded
#: model:ir.model.fields,help:sale_timesheet_rounded.field_project_project__timesheet_rounding_method
msgid ""
"If you activate the rounding of timesheet lines, only new entries will be "
"rounded (i.e. existing lines will not be rounded automatically)."
msgstr ""
"Wenn Sie die Rundung von Zeiterfassungszeilen aktivieren, werden nur neue "
"Einträge gerundet (d.h. bestehende Zeilen werden nicht automatisch gerundet)."

#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_account_analytic_line____last_update
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project____last_update
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_sale_order_line____last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__no
msgid "No rounding"
msgstr "Keine Rundung"

#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_project_project
msgid "Project"
msgstr "Projekt"

#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.view_account_analytic_line_form_inherit
msgid "Quantity Rounded"
msgstr "Gerundete Menge"

#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_account_analytic_line__unit_amount_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_hr_timesheet_switch__unit_amount_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Quantity rounded"
msgstr "Gerundete Menge"

#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_order_line
msgid "Sales Order Line"
msgstr "Auftragzeile"

#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.project_project_form_inherit
msgid "Time rounding"
msgstr "Zeit Rundung"

#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_factor
msgid "Timesheet rounding factor in percentage"
msgstr "Stundenzettel Rundungsfaktor (in Prozent)"

#. module: sale_timesheet_rounded
#: model:ir.model.constraint,message:sale_timesheet_rounded.constraint_project_project_check_timesheet_rounding_factor
msgid ""
"Timesheet rounding factor should stay between 0 and 500, endpoints included."
msgstr ""
"Der Stundezettel Rundungsfaktor muss inzwischen 0 und 500 sein, Endpunkte "
"inklusive."

#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_method
msgid "Timesheet rounding method"
msgstr "Stundenzettel Rundungsmethode"

#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_unit
msgid "Timesheet rounding unit"
msgstr "Stundenzettel Rundungseinheit"

#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Total quantity rounded"
msgstr "Total gerundete Menge"

#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__up
msgid "Up"
msgstr "Nach oben"
Loading
Loading