Initial commit: OCA Mrp packages (117 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:05 +02:00
commit 277e84fd7a
4403 changed files with 395154 additions and 0 deletions

View file

@ -0,0 +1,48 @@
# Sale Timesheet Rounded
Odoo addon: sale_timesheet_rounded
## Installation
```bash
pip install odoo-bringout-oca-timesheet-sale_timesheet_rounded
```
## Dependencies
This addon depends on:
- project
- hr_timesheet
- sale_timesheet
## Manifest Information
- **Name**: Sale Timesheet Rounded
- **Version**: 16.0.1.0.0
- **Category**: Sales
- **License**: AGPL-3
- **Installable**: True
## Source
Based on [OCA/timesheet](https://github.com/OCA/timesheet) branch 16.0, addon `sale_timesheet_rounded`.
## License
This package maintains the original AGPL-3 license from the upstream Odoo project.
## Documentation
- Overview: doc/OVERVIEW.md
- Architecture: doc/ARCHITECTURE.md
- Models: doc/MODELS.md
- Controllers: doc/CONTROLLERS.md
- Wizards: doc/WIZARDS.md
- Reports: doc/REPORTS.md
- Security: doc/SECURITY.md
- Install: doc/INSTALL.md
- Usage: doc/USAGE.md
- Configuration: doc/CONFIGURATION.md
- Dependencies: doc/DEPENDENCIES.md
- Troubleshooting: doc/TROUBLESHOOTING.md
- FAQ: doc/FAQ.md

View file

@ -0,0 +1,32 @@
# Architecture
```mermaid
flowchart TD
U[Users] -->|HTTP| V[Views and QWeb Templates]
V --> C[Controllers]
V --> W[Wizards Transient Models]
C --> M[Models and ORM]
W --> M
M --> R[Reports]
DX[Data XML] --> M
S[Security ACLs and Groups] -. enforces .-> M
subgraph Sale_timesheet_rounded Module - sale_timesheet_rounded
direction LR
M:::layer
W:::layer
C:::layer
V:::layer
R:::layer
S:::layer
DX:::layer
end
classDef layer fill:#eef8ff,stroke:#6ea8fe,stroke-width:1px
```
Notes
- Views include tree/form/kanban templates and report templates.
- Controllers provide website/portal routes when present.
- Wizards are UI flows implemented with `models.TransientModel`.
- Data XML loads data/demo records; Security defines groups and access.

View file

@ -0,0 +1,3 @@
# Configuration
Refer to Odoo settings for sale_timesheet_rounded. Configure related models, access rights, and options as needed.

View file

@ -0,0 +1,3 @@
# Controllers
This module does not define custom HTTP controllers.

View file

@ -0,0 +1,7 @@
# Dependencies
This addon depends on:
- [project](../../odoo-bringout-oca-ocb-project)
- [hr_timesheet](../../odoo-bringout-oca-ocb-hr_timesheet)
- [sale_timesheet](../../odoo-bringout-oca-ocb-sale_timesheet)

View file

@ -0,0 +1,4 @@
# FAQ
- Q: Which Odoo version? A: 16.0 (OCA/OCB packaged).
- Q: How to enable? A: Start server with --addon sale_timesheet_rounded or install in UI.

View file

@ -0,0 +1,7 @@
# Install
```bash
pip install odoo-bringout-oca-timesheet-sale_timesheet_rounded"
# or
uv pip install odoo-bringout-oca-timesheet-sale_timesheet_rounded"
```

View file

@ -0,0 +1,15 @@
# Models
Detected core models and extensions in sale_timesheet_rounded.
```mermaid
classDiagram
class account_analytic_line
class account_move
class project_project
class sale_order_line
```
Notes
- Classes show model technical names; fields omitted for brevity.
- Items listed under _inherit are extensions of existing models.

View file

@ -0,0 +1,6 @@
# Overview
Packaged Odoo addon: sale_timesheet_rounded. Provides features documented in upstream Odoo 16 under this addon.
- Source: OCA/OCB 16.0, addon sale_timesheet_rounded
- License: LGPL-3

View file

@ -0,0 +1,3 @@
# Reports
This module does not define custom reports.

View file

@ -0,0 +1,8 @@
# Security
This module does not define custom security rules or access controls beyond Odoo defaults.
Default Odoo security applies:
- Base user access through standard groups
- Model access inherited from dependencies
- No custom row-level security rules

View file

@ -0,0 +1,5 @@
# Troubleshooting
- Ensure Python and Odoo environment matches repo guidance.
- Check database connectivity and logs if startup fails.
- Validate that dependent addons listed in DEPENDENCIES.md are installed.

View file

@ -0,0 +1,7 @@
# Usage
Start Odoo including this addon (from repo root):
```bash
python3 scripts/nix_odoo_web_server.py --db-name mydb --addon sale_timesheet_rounded
```

View file

@ -0,0 +1,8 @@
# Wizards
Transient models exposed as UI wizards in sale_timesheet_rounded.
```mermaid
classDiagram
class SaleAdvancePaymentInv
```

View file

@ -0,0 +1,44 @@
[project]
name = "odoo-bringout-oca-timesheet-sale_timesheet_rounded"
version = "16.0.0"
description = "Sale Timesheet Rounded - Round timesheet entries amount based on project settings."
authors = [
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
]
dependencies = [
"odoo-bringout-oca-ocb-project>=16.0.0",
"odoo-bringout-oca-ocb-hr_timesheet>=16.0.0",
"odoo-bringout-oca-timesheet-sale_timesheet>=16.0.0",
"requests>=2.25.1"
]
readme = "README.md"
requires-python = ">= 3.11"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Office/Business",
]
[project.urls]
homepage = "https://github.com/bringout/0"
repository = "https://github.com/bringout/0"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.metadata]
allow-direct-references = true
[tool.hatch.build.targets.wheel]
packages = ["sale_timesheet_rounded"]
[tool.rye]
managed = true
dev-dependencies = [
"pytest>=8.4.1",
]

View file

@ -0,0 +1,132 @@
======================
Sale Timesheet Rounded
======================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f1f09259075a3ca4e8cd5a7fa904602230fff4d6f30a154dcb82c64d09479bfe
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/16.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-16-0/timesheet-16-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=16.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.
**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:%2016.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>
Other credits
~~~~~~~~~~~~~
The migration of this sale_timesheet_rounded from 15.0 to 16.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/16.0/sale_timesheet_rounded>`_ 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 @@
from . import models
from .hooks import pre_init_hook
from . import wizard

View file

@ -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": "16.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",
}

View file

@ -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(cr):
"""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")
cr.execute( # pylint: disable=E8103
sql.SQL("ALTER TABLE {} ADD COLUMN IF NOT EXISTS {} NUMERIC").format(
table, column
)
)
cr.execute( # pylint: disable=E8103
sql.SQL(
"UPDATE {table} SET {column} = unit_amount WHERE {column} IS NULL"
).format(table=table, column=column)
)

View file

@ -0,0 +1,130 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_timesheet_rounded
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \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_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 ""
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_kanban_inherit
msgid ""
"<br/>\n"
" <strong>Rounded: </strong>"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_analytic_line
msgid "Analytic Line"
msgstr "Analitička stavka"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__half_up
msgid "Closest"
msgstr "Najbliži"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__down
msgid "Down"
msgstr "Dolje"
#. 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 "Trajanje (zaokruženo)"
#. 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 ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_move
msgid "Journal Entry"
msgstr "Žurnal"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__no
msgid "No rounding"
msgstr "Bez zaokruživanja"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_project_project
msgid "Project"
msgstr "Projekat"
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.view_account_analytic_line_form_inherit
msgid "Quantity Rounded"
msgstr "Količina zaokružena"
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_account_analytic_line__unit_amount_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Quantity rounded"
msgstr "Količina zaokružena"
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_unit
msgid "Rounding Unit"
msgstr "Jedinica zaokruživanja"
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_method
msgid "Rounding method"
msgstr "Metod zaokruživanja"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_advance_payment_inv
msgid "Sales Advance Payment Invoice"
msgstr "Avansna faktura prodaje"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_order_line
msgid "Sales Order Line"
msgstr "Stavka prodajne narudžbe"
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.project_project_form_inherit
msgid "Time rounding"
msgstr "Zaokruživanje vremena"
#. 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 "Faktor zaokruživanja evidencije radnog vremena u postocima"
#. 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 ""
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Total quantity rounded"
msgstr "Ukupna količina zaokružena"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__up
msgid "Up"
msgstr "Gore"

View file

@ -0,0 +1,151 @@
# 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.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,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,name:sale_timesheet_rounded.model_account_move
msgid "Journal Entry"
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_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.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_unit
msgid "Rounding Unit"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_method
msgid "Rounding method"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_advance_payment_inv
msgid "Sales Advance Payment Invoice"
msgstr ""
#. 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_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"
#~ msgid "Timesheet rounding method"
#~ msgstr "Stundenzettel Rundungsmethode"
#~ msgid "Timesheet rounding unit"
#~ msgstr "Stundenzettel Rundungseinheit"

View file

@ -0,0 +1,152 @@
# 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: 2020-05-18 20:19+0000\n"
"Last-Translator: Josep M <jmyepes@mac.com>\n"
"Language-Team: none\n"
"Language: es\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.10\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 = hora\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>Redondeo: </strong>"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_analytic_line
msgid "Analytic Line"
msgstr "Línea analítica"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__half_up
msgid "Closest"
msgstr "Más cercano"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__down
msgid "Down"
msgstr "Abajo"
#. 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 "Duración (redondeado)"
#. 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 ""
"Si activa el redondeo de las líneas del parte de horas, solo se redondearán "
"las nuevas entradas (es decir, las líneas existentes no se redondearán "
"automáticamente)."
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_move
msgid "Journal Entry"
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 "Sin redondeo"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_project_project
msgid "Project"
msgstr "Proyecto"
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.view_account_analytic_line_form_inherit
msgid "Quantity Rounded"
msgstr "Cantidad redondeada"
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_account_analytic_line__unit_amount_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Quantity rounded"
msgstr "Cantidad redondeada"
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_unit
msgid "Rounding Unit"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_method
msgid "Rounding method"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_advance_payment_inv
msgid "Sales Advance Payment Invoice"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_order_line
msgid "Sales Order Line"
msgstr "Línea Pedido Venta"
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.project_project_form_inherit
msgid "Time rounding"
msgstr "Redondeo de tiempo"
#. 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 "Factor de redondeo del Parte de horas en porcentaje"
#. 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 ""
"El factor de redondeo del Parte de horas debe estar entre 0 y 500, incluidos "
"los puntos finales."
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Total quantity rounded"
msgstr "Cantidad total redondeada"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__up
msgid "Up"
msgstr "Arriba"
#~ msgid "Timesheet rounding method"
#~ msgstr "Método de redondeo del Parte de horas"
#~ msgid "Timesheet rounding unit"
#~ msgstr "Unidad de redondeo del Parte de horas"

View file

@ -0,0 +1,145 @@
# 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: 2024-03-12 10:36+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\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 4.17\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 = ora\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
msgid ""
"<br/>\n"
" <strong>Rounded: </strong>"
msgstr ""
"<br/>\n"
" <strong>Arrotondato: </strong>"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_analytic_line
msgid "Analytic Line"
msgstr "Riga analitica"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__half_up
msgid "Closest"
msgstr "Più vicino"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__down
msgid "Down"
msgstr "Giu"
#. 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 "Durata (arrotondata)"
#. 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 ""
"Se si attiva l'arrotondamento delle righe del foglio ore, solo le nuove "
"registrazioni verranno arrotondate (i.e. le righe inserite non verranno "
"arrotondate automaticamente)."
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_move
msgid "Journal Entry"
msgstr "Registrazione contabile"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__no
msgid "No rounding"
msgstr "Senza arrotondamento"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_project_project
msgid "Project"
msgstr "Progetto"
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.view_account_analytic_line_form_inherit
msgid "Quantity Rounded"
msgstr "Quantità arrotondata"
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_account_analytic_line__unit_amount_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Quantity rounded"
msgstr "Quantità arrotondata"
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_unit
msgid "Rounding Unit"
msgstr "Unità arrotondamento"
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_method
msgid "Rounding method"
msgstr "Metodo arrotondamento"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_advance_payment_inv
msgid "Sales Advance Payment Invoice"
msgstr "Fattura di vendita con pagamento anticipato"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_order_line
msgid "Sales Order Line"
msgstr "Riga ordine di vendita"
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.project_project_form_inherit
msgid "Time rounding"
msgstr "Arrotondamento orario"
#. 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 "Fattore arrotondamento foglio ore in percentuale"
#. 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 ""
"il fattore di arrotondamento del foglio ore deve stare tra 0 e 500, estremi "
"inclusi."
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Total quantity rounded"
msgstr "Totale quantità arrotondata"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__up
msgid "Up"
msgstr "Su"

View file

@ -0,0 +1,158 @@
# 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: 2021-04-22 17:47+0000\n"
"Last-Translator: Bosd <c5e2fd43-d292-4c90-9d1f-74ff3436329a@anonaddy.me>\n"
"Language-Team: none\n"
"Language: nl\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 4.3.2\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 = uur\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
msgid ""
"<br/>\n"
" <strong>Rounded: </strong>"
msgstr ""
"<br/>\n"
" <strong>Afgerond: </strong>"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_analytic_line
msgid "Analytic Line"
msgstr "Kostenplaatsregel"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__half_up
msgid "Closest"
msgstr "Ditchsbijzijnde"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__down
msgid "Down"
msgstr "Omlaag"
#. 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 "Tijdsduur (afgerond)"
#. 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 ""
"Wanner het afronden van tijdlijst regels is geactiveerd, zullen enkel nieuwe "
"invoeren worden afgerond. (Bestaande regels zullen niet automatisch worden "
"afgerond)."
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_move
msgid "Journal Entry"
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 "Geen afronding"
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_project_project
msgid "Project"
msgstr "Project"
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.view_account_analytic_line_form_inherit
msgid "Quantity Rounded"
msgstr "Aantal afgerond"
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_account_analytic_line__unit_amount_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Quantity rounded"
msgstr "Aantal afgerond"
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_unit
msgid "Rounding Unit"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_method
msgid "Rounding method"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_advance_payment_inv
msgid "Sales Advance Payment Invoice"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_order_line
msgid "Sales Order Line"
msgstr "Verkooporder regel"
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.project_project_form_inherit
msgid "Time rounding"
msgstr "Tijdsafronding"
#. 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 "Tijdlijst afrondingsfactor in percentage"
#. 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 "Tijdlijst afrondings factor zou moeten liggen tussen de 0 en 500."
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Total quantity rounded"
msgstr "Totaal aantal afgerond"
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__up
msgid "Up"
msgstr "Omhoog"
#~ msgid "Display Name"
#~ msgstr "Weergavenaam"
#~ msgid "ID"
#~ msgstr "ID"
#~ msgid "Last Modified on"
#~ msgstr "Laatst bijgewerkt op"
#~ msgid "Timesheet rounding method"
#~ msgstr "Tijdlijst afrondingsmethode"
#~ msgid "Timesheet rounding unit"
#~ msgstr "Tijdlijst afrondings eenheid"

View file

@ -0,0 +1,130 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_timesheet_rounded
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \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_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 ""
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_kanban_inherit
msgid ""
"<br/>\n"
" <strong>Rounded: </strong>"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_analytic_line
msgid "Analytic Line"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__half_up
msgid "Closest"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__down
msgid "Down"
msgstr ""
#. 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 ""
#. 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 ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_account_move
msgid "Journal Entry"
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 ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_project_project
msgid "Project"
msgstr ""
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.view_account_analytic_line_form_inherit
msgid "Quantity Rounded"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_account_analytic_line__unit_amount_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Quantity rounded"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_unit
msgid "Rounding Unit"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model.fields,field_description:sale_timesheet_rounded.field_project_project__timesheet_rounding_method
msgid "Rounding method"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_advance_payment_inv
msgid "Sales Advance Payment Invoice"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model,name:sale_timesheet_rounded.model_sale_order_line
msgid "Sales Order Line"
msgstr ""
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.project_project_form_inherit
msgid "Time rounding"
msgstr ""
#. 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 ""
#. 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 ""
#. module: sale_timesheet_rounded
#: model_terms:ir.ui.view,arch_db:sale_timesheet_rounded.account_analytic_line_tree_inherit
msgid "Total quantity rounded"
msgstr ""
#. module: sale_timesheet_rounded
#: model:ir.model.fields.selection,name:sale_timesheet_rounded.selection__project_project__timesheet_rounding_method__up
msgid "Up"
msgstr ""

View file

@ -0,0 +1,4 @@
from . import account_analytic_line
from . import project_project
from . import sale
from . import account_move

View file

@ -0,0 +1,115 @@
# Copyright 2019 Camptocamp SA
# Copyright 2020 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import api, fields, models
from odoo.tools.float_utils import float_round
class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"
unit_amount_rounded = fields.Float(
string="Quantity rounded",
compute="_compute_unit_rounded",
store=True,
readonly=False,
copy=False,
)
@api.depends("timesheet_invoice_id.state")
def _compute_project_id(self):
field_rounded = self._fields["unit_amount_rounded"]
if self._context.get("timesheet_no_recompute", False):
self.env.remove_to_compute(field_rounded, self)
return super()._compute_project_id()
@api.depends("project_id", "unit_amount")
def _compute_unit_rounded(self):
for record in self:
record.unit_amount_rounded = record._calc_unit_amount_rounded()
def _calc_unit_amount_rounded(self):
self.ensure_one()
project_rounding = (
self.project_id and self.project_id.timesheet_rounding_method != "NO"
)
if project_rounding:
return self._calc_rounded_amount(
self.project_id.timesheet_rounding_unit,
self.project_id.timesheet_rounding_method,
self.project_id.timesheet_rounding_factor,
self.unit_amount,
)
else:
return self.unit_amount
@staticmethod
def _calc_rounded_amount(rounding_unit, rounding_method, factor, amount):
factor = factor / 100.0
if rounding_unit:
unit_amount_rounded = float_round(
amount * factor,
precision_rounding=rounding_unit,
rounding_method=rounding_method,
)
else:
unit_amount_rounded = amount * factor
return unit_amount_rounded
####################################################
# ORM Overrides
####################################################
@api.model
def read_group(
self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True
):
"""Replace the value of unit_amount by unit_amount_rounded.
When context key `timesheet_rounding` is True
we change the value of unit_amount with the rounded one.
This affects `sale_order_line._compute_delivered_quantity`
which in turns compute the delivered qty on SO line.
"""
ctx_ts_rounded = self.env.context.get("timesheet_rounding")
fields_local = list(fields) if fields else []
if ctx_ts_rounded and "unit_amount_rounded" not in fields_local:
# To add the unit_amount_rounded value on read_group
fields_local.append("unit_amount_rounded")
res = super().read_group(
domain,
fields_local,
groupby,
offset=offset,
limit=limit,
orderby=orderby,
lazy=lazy,
)
if ctx_ts_rounded:
# To set the unit_amount_rounded value instead of unit_amount
for rec in res:
rec["unit_amount"] = rec["unit_amount_rounded"]
return res
def read(self, fields=None, load="_classic_read"):
"""Replace the value of unit_amount by unit_amount_rounded.
When context key `timesheet_rounding` is True
we change the value of unit_amount with the rounded one.
This affects `account_analytic_line._sale_determine_order_line`.
"""
ctx_ts_rounded = self.env.context.get("timesheet_rounding")
fields_local = list(fields) if fields else []
read_unit_amount = "unit_amount" in fields_local or not fields_local
if ctx_ts_rounded and read_unit_amount and fields_local:
if "unit_amount_rounded" not in fields_local:
# To add the unit_amount_rounded value on read
fields_local.append("unit_amount_rounded")
res = super().read(fields=fields_local, load=load)
if ctx_ts_rounded and read_unit_amount:
# To set the unit_amount_rounded value instead of unit_amount
for rec in res:
rec["unit_amount"] = rec["unit_amount_rounded"]
return res

View file

@ -0,0 +1,31 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import models
class AccountMove(models.Model):
_inherit = "account.move"
def _post(self, soft=True):
# We must avoid the recomputation of the unit amount rounded called by
# the compute_project_id (especially when project has not been changed)
return super(AccountMove, self.with_context(timesheet_no_recompute=True))._post(
soft=soft
)
def unlink(self):
return super(
AccountMove, self.with_context(timesheet_no_recompute=True)
).unlink()
def button_cancel(self):
return super(
AccountMove, self.with_context(timesheet_no_recompute=True)
).button_cancel()
def button_draft(self):
return super(
AccountMove, self.with_context(timesheet_no_recompute=True)
).button_draft()

View file

@ -0,0 +1,45 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import fields, models
class ProjectProject(models.Model):
_inherit = "project.project"
timesheet_rounding_unit = fields.Float(
string="Rounding Unit",
default=0.0,
help="""1.0 = hour
0.25 = 15 min
0.084 ~= 5 min
0.017 ~= 1 min
""",
)
timesheet_rounding_method = fields.Selection(
string="Rounding method",
selection=[
("NO", "No rounding"),
("UP", "Up"),
("HALF_UP", "Closest"),
("DOWN", "Down"),
],
default="NO",
required=True,
help="If you activate the rounding of timesheet lines, only new "
"entries will be rounded (i.e. existing lines will not be "
"rounded automatically).",
)
timesheet_rounding_factor = fields.Float(
string="Timesheet rounding factor in percentage", default=100.0
)
_sql_constraints = [
(
"check_timesheet_rounding_factor",
"CHECK(0 <= timesheet_rounding_factor "
"AND timesheet_rounding_factor <= 500)",
"Timesheet rounding factor should stay between 0 and 500,"
" endpoints included.",
)
]

View file

@ -0,0 +1,23 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import api, models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
def _get_delivered_quantity_by_analytic(self, additional_domain):
# If we land here is only because we are dealing w/ SO lines
# having `qty_delivered_method` equal to `analytic` or `timesheet`.
# The 1st case matches expenses lines the latter TS lines.
# Expenses are already discarded in our a.a.l. overrides
# so it's fine to set the ctx key here anyway.
return super(
SaleOrderLine, self.with_context(timesheet_rounding=True)
)._get_delivered_quantity_by_analytic(additional_domain)
@api.depends("analytic_line_ids.unit_amount_rounded")
def _compute_qty_delivered(self):
"""Adds the dependency on unit_amount_rounded."""
return super()._compute_qty_delivered()

View file

@ -0,0 +1,25 @@
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)

View file

@ -0,0 +1,5 @@
* 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>

View file

@ -0,0 +1 @@
The migration of this sale_timesheet_rounded from 15.0 to 16.0 was financially supported by Camptocamp

View file

@ -0,0 +1,18 @@
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.

View file

@ -0,0 +1 @@
* improve test coverage

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -0,0 +1,472 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Sale Timesheet Rounded</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="sale-timesheet-rounded">
<h1 class="title">Sale Timesheet Rounded</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f1f09259075a3ca4e8cd5a7fa904602230fff4d6f30a154dcb82c64d09479bfe
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/timesheet/tree/16.0/sale_timesheet_rounded"><img alt="OCA/timesheet" src="https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/timesheet-16-0/timesheet-16-0-sale_timesheet_rounded"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/timesheet&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Round timesheet lines amounts in sales based on project settings.</p>
<p>A typical use case is: you work 5 minutes but you want to invoice 15 minutes.</p>
<p>With this module you can configure a rounding unit or factor on the project
and all the lines tracked on this projects tasks will show a rounded amount.</p>
<p>If you want you can override the value manually on each entry.</p>
<p>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.</p>
<p>WARNING: This module cannot be used with <cite>timesheet_grid</cite> without further
adapation as an update of an existing timesheet line will NOT update the
rounded amount. To achieve this, you need to override <cite>adjust_grid</cite> function
to pass the <cite>force_compute</cite> context key.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id2">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="id7">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>Go to a project and set the following fields according to your needs:</p>
<ul class="simple">
<li>Timesheet rounding unit</li>
</ul>
<p>Defines the rounding unit.
For instance, if you want to round to 1 hour, you can set <cite>1.0</cite>.
If you want to round to 15 min set <cite>0.25</cite>.</p>
<ul class="simple">
<li>Timesheet rounding method</li>
</ul>
<p>Options: “No” (default), “Closest”, “Up”, “Down”.</p>
<p>Please refer to <cite>odoo.tools.float_utils.float_round</cite> to understand the difference.</p>
<ul class="simple">
<li>Timesheet rounding factor (percentage)</li>
</ul>
<p>When round unit is not defined you can round by a fixed %.</p>
<p>When using both a unit and a factor, the factor will be applied first:</p>
<blockquote>
result = round(amount * percentage, unit)</blockquote>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id2">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>improve test coverage</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/timesheet/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/timesheet/issues/new?body=module:%20sale_timesheet_rounded%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple">
<li>Camptocamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a>&gt;</li>
<li>Thomas Nowicki &lt;<a class="reference external" href="mailto:thomas.nowicki&#64;camptocamp.com">thomas.nowicki&#64;camptocamp.com</a>&gt;</li>
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li>
<li>Foram Shah &lt;<a class="reference external" href="mailto:foram.shah&#64;initos.com">foram.shah&#64;initos.com</a>&gt;</li>
<li>Phuc Kieu &lt;<a class="reference external" href="mailto:phuckh&#64;trobz.com">phuckh&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#id7">Other credits</a></h2>
<p>The migration of this sale_timesheet_rounded from 15.0 to 16.0 was financially supported by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/timesheet/tree/16.0/sale_timesheet_rounded">OCA/timesheet</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1 @@
from . import test_rounded

View file

@ -0,0 +1,324 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
import odoo
from odoo import fields
from odoo.addons.sale_timesheet.tests.common import TestCommonSaleTimesheet
@odoo.tests.tagged("post_install", "-at_install")
class TestRounded(TestCommonSaleTimesheet):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.sale_order = cls.env["sale.order"].create(
{
"analytic_account_id": cls.project_global.analytic_account_id.id,
"partner_id": cls.partner_a.id,
"partner_invoice_id": cls.partner_a.id,
"partner_shipping_id": cls.partner_a.id,
}
)
cls.env["sale.order.line"].create(
{
"order_id": cls.sale_order.id,
"name": cls.product_delivery_timesheet2.name,
"product_id": cls.product_delivery_timesheet2.id,
"product_uom_qty": 1,
"product_uom": cls.product_delivery_timesheet2.uom_id.id,
"price_unit": cls.product_delivery_timesheet2.list_price,
}
)
cls.sale_order.action_confirm()
cls.project_global.write(
{
"timesheet_rounding_unit": 0.25,
"timesheet_rounding_method": "UP",
"timesheet_rounding_factor": 200,
}
)
cls.product_expense = cls.env["product.product"].create(
{
"name": "Service delivered, EXPENSE",
"expense_policy": "cost",
"standard_price": 30,
"list_price": 90,
"type": "service",
"invoice_policy": "order",
"uom_id": cls.product_delivery_timesheet2.uom_id.id,
"uom_po_id": cls.product_delivery_timesheet2.uom_id.id,
}
)
cls.analytic_plan = cls.env["account.analytic.plan"].create(
{
"name": "Plan sale timesheet",
"company_id": False,
}
)
cls.avg_analytic_account = cls.env["account.analytic.account"].create(
{
"name": "AVG account",
"plan_id": cls.analytic_plan.id,
}
)
def create_analytic_line(self, **kw):
task = self.sale_order.tasks_ids[0]
values = {
"project_id": self.project_global.id,
"task_id": task.id,
"name": "Rounded test line",
"date": fields.Date.today(),
"unit_amount": 0,
"product_id": self.product_delivery_timesheet2.id,
"employee_id": self.employee_user.id,
}
values.update(kw)
return self.env["account.analytic.line"].create(values)
def test_analytic_line_init_no_rounding(self):
lines = self.env["account.analytic.line"].search([])
for line in lines:
self.assertEqual(line.unit_amount_rounded, line.unit_amount)
def test_analytic_line_create_no_rounding(self):
self.project_global.write({"timesheet_rounding_method": "NO"})
# no rounding enabled
line = self.create_analytic_line(unit_amount=1)
self.assertEqual(line.unit_amount, 1.0)
self.assertEqual(line.unit_amount_rounded, line.unit_amount)
def test_analytic_line_create(self):
line = self.create_analytic_line(unit_amount=1)
self.assertEqual(line.unit_amount_rounded, 2.0)
line = self.create_analytic_line(unit_amount=1, unit_amount_rounded=0)
self.assertEqual(line.unit_amount_rounded, 0.0)
def test_analytic_line_create_and_update_amount_rounded(self):
line = self.create_analytic_line(unit_amount=2)
self.assertEqual(line.unit_amount_rounded, 4.0)
line.write({"unit_amount_rounded": 5.0})
self.assertEqual(line.unit_amount_rounded, 5.0)
line.write({"unit_amount_rounded": 0.0})
self.assertEqual(line.unit_amount_rounded, 0.0)
def test_analytic_line_create_and_update_amount(self):
line = self.create_analytic_line(unit_amount=2)
self.assertEqual(line.unit_amount_rounded, 4.0)
line.unit_amount = 5.0
self.assertEqual(line.unit_amount_rounded, 10.0)
def test_analytic_line_read_group_override(self):
# Test of the read group with an without timesheet_rounding context
# without context the unit_amount should be the initial
# with the context the value of unit_amount should be replaced by the
# unit_amount_rounded
line = self.env["account.analytic.line"]
self.create_analytic_line(unit_amount=1)
domain = [("project_id", "=", self.project_global.id)]
fields_list = ["so_line", "unit_amount", "product_uom_id"]
groupby = ["product_uom_id", "so_line"]
data_ctx_f = line.read_group(
domain,
fields_list,
groupby,
)
self.assertEqual(data_ctx_f[0]["unit_amount"], 1.0)
data_ctx_t = line.with_context(timesheet_rounding=True).read_group(
domain,
fields_list,
groupby,
)
self.assertEqual(data_ctx_t[0]["unit_amount"], 2.0)
self.create_analytic_line(unit_amount=1.1)
data_ctx_f = line.with_context(timesheet_rounding=False).read_group(
domain,
fields_list,
groupby,
)
self.assertEqual(data_ctx_f[0]["unit_amount"], 2.1)
data_ctx_f = line.with_context(timesheet_rounding=True).read_group(
domain,
fields_list,
groupby,
)
self.assertEqual(data_ctx_f[0]["unit_amount"], 4.25)
def test_analytic_line_read_override(self):
# Cases for not rounding:
# * not linked to project -> no impact
# * is an expense -> no impact
# * ctx key for rounding is set to false -> no impact
# In all the other cases we check that unit amount is rounded.
load = "_classic_read"
fields = None
# context = False + project_id - product_expense
line = self.create_analytic_line(unit_amount=1)
unit_amount_ret = line.read(fields, load)[0]["unit_amount"]
self.assertEqual(unit_amount_ret, 1)
# context = True + project_id + product_expense
line = self.create_analytic_line(
unit_amount=1, product_id=self.product_expense.id
)
unit_amount_ret = line.with_context(timesheet_rounding=True).read(fields, load)[
0
]["unit_amount"]
self.assertEqual(unit_amount_ret, 2)
# context = True + project_id - product_expense
line = self.create_analytic_line(unit_amount=1)
unit_amount_ret = line.with_context(timesheet_rounding=True).read(fields, load)[
0
]["unit_amount"]
self.assertEqual(unit_amount_ret, 2)
def test_sale_order_qty_1(self):
# amount=1 -> should be rounded to 2 by the invoicing_factor
self.create_analytic_line(unit_amount=1)
self.assertAlmostEqual(self.sale_order.order_line.qty_delivered, 2.0)
self.assertAlmostEqual(self.sale_order.order_line.qty_to_invoice, 2.0)
self.assertAlmostEqual(self.sale_order.order_line.qty_invoiced, 0)
def test_sale_order_qty_2(self):
# force amount_rounded=4
self.create_analytic_line(unit_amount=1, unit_amount_rounded=4)
self.assertAlmostEqual(self.sale_order.order_line.qty_delivered, 4.0)
self.assertAlmostEqual(self.sale_order.order_line.qty_to_invoice, 4.0)
self.assertAlmostEqual(self.sale_order.order_line.qty_invoiced, 0)
def test_sale_order_qty_3(self):
# amount=0.9
# should be rounded to 2 by the invoicing_factor with the project
# timesheet_rounding_unit: 0.25
# timesheet_rounding_method: 'UP'
# timesheet_rounding_factor: 200
self.create_analytic_line(unit_amount=0.9)
self.assertAlmostEqual(self.sale_order.order_line.qty_delivered, 2.0)
self.assertAlmostEqual(self.sale_order.order_line.qty_to_invoice, 2.0)
self.assertAlmostEqual(self.sale_order.order_line.qty_invoiced, 0)
def test_sale_order_qty_4(self):
# amount=0.9
# should be rounded to 2 by the invoicing_factor with the project
# timesheet_rounding_unit: 0.25
# timesheet_rounding_method: 'UP'
# timesheet_rounding_factor: 200
self.project_global.timesheet_rounding_factor = 400
self.create_analytic_line(unit_amount=1.0)
self.assertAlmostEqual(self.sale_order.order_line.qty_delivered, 4.0)
self.assertAlmostEqual(self.sale_order.order_line.qty_to_invoice, 4.0)
self.assertAlmostEqual(self.sale_order.order_line.qty_invoiced, 0)
def test_calc_rounded_amount_method(self):
aal = self.env["account.analytic.line"]
rounding_unit = 0.25
rounding_method = "UP"
factor = 200
amount = 1
self.assertEqual(
aal._calc_rounded_amount(rounding_unit, rounding_method, factor, amount), 2
)
rounding_unit = 0.0
rounding_method = "UP"
factor = 200
amount = 1
self.assertEqual(
aal._calc_rounded_amount(rounding_unit, rounding_method, factor, amount), 2
)
rounding_unit = 0.25
rounding_method = "UP"
factor = 100
amount = 1.0
self.assertEqual(
aal._calc_rounded_amount(rounding_unit, rounding_method, factor, amount), 1
)
rounding_unit = 0.25
rounding_method = "UP"
factor = 200
amount = 0.9
self.assertEqual(
aal._calc_rounded_amount(rounding_unit, rounding_method, factor, amount), 2
)
rounding_unit = 1.0
rounding_method = "UP"
factor = 200
amount = 0.6
self.assertEqual(
aal._calc_rounded_amount(rounding_unit, rounding_method, factor, amount), 2
)
rounding_unit = 0.25
rounding_method = "HALF_UP"
factor = 200
amount = 1.01
self.assertEqual(
aal._calc_rounded_amount(rounding_unit, rounding_method, factor, amount), 2
)
def test_post_invoice_with_rounded_amount_unchanged(self):
"""Posting an invoice MUST NOT recompute rounded amount unit.
- invoicing the SO should not recompute and update the
unit_amount_rounded
- the invoiced qty should be the same as the aal.unit_amount_rounded
"""
unit_amount_rounded = 111
analytic_line = self.create_analytic_line(unit_amount=10)
analytic_line.unit_amount_rounded = unit_amount_rounded
account_move = self.sale_order._create_invoices()
prd_ts_id = self.product_delivery_timesheet2
account_move._post()
# the unit_amount_rounded is not changed
self.assertEqual(analytic_line.unit_amount_rounded, unit_amount_rounded)
# the invoiced qty remains the same
inv_line = account_move.line_ids.filtered(lambda l: l.product_id == prd_ts_id)
self.assertEqual(inv_line.quantity, unit_amount_rounded)
def test_draft_invoice_with_rounded_amount_unchanged(self):
"""Drafting an invoice MUST NOT recompute rounded amount unit.
- invoicing the SO should not recompute and update the
unit_amount_rounded
- the invoiced qty should be the same as the aal.unit_amount_rounded
"""
unit_amount_rounded = 0.12
analytic_line = self.create_analytic_line(unit_amount=10)
analytic_line.unit_amount_rounded = unit_amount_rounded
account_move = self.sale_order._create_invoices()
prd_ts_id = self.product_delivery_timesheet2
account_move.button_draft()
# the unit_amount_rounded is not changed
self.assertEqual(analytic_line.unit_amount_rounded, unit_amount_rounded)
# the invoiced qty remains the same
inv_line = account_move.line_ids.filtered(lambda l: l.product_id == prd_ts_id)
self.assertEqual(inv_line.quantity, unit_amount_rounded)
def test_cancel_invoice_with_rounded_amount_unchanged(self):
"""Cancelling an invoice MUST NOT recompute rounded amount unit.
- invoicing the SO should not recompute and update the
unit_amount_rounded
- the invoiced qty should be the same as the aal.unit_amount_rounded
"""
unit_amount_rounded_total = 15
analytic_line_1 = self.create_analytic_line(unit_amount=10)
analytic_line_2 = self.create_analytic_line(unit_amount=10)
analytic_line_1.unit_amount_rounded = unit_amount_rounded_total
analytic_line_2.unit_amount_rounded = 0
account_move = self.sale_order._create_invoices()
prd_ts_id = self.product_delivery_timesheet2
account_move.button_cancel()
# the unit_amount_rounded is not changed
self.assertEqual(analytic_line_1.unit_amount_rounded, unit_amount_rounded_total)
self.assertEqual(analytic_line_2.unit_amount_rounded, 0)
# the invoiced qty remains the same
inv_line = account_move.line_ids.filtered(lambda l: l.product_id == prd_ts_id)
self.assertEqual(inv_line.quantity, unit_amount_rounded_total)

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_account_analytic_line_form_inherit" model="ir.ui.view">
<field name="name">account.analytic.line.form.inherit</field>
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='unit_amount']" position="after">
<field
name="unit_amount_rounded"
string="Quantity Rounded"
widget="float_time"
/>
</xpath>
</field>
</record>
<record id="account_analytic_line_kanban_inherit" model="ir.ui.view">
<field name="name">account.analytic.line.kanban.inherit</field>
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="hr_timesheet.view_kanban_account_analytic_line" />
<field name="arch" type="xml">
<xpath expr="//field[@name='unit_amount']" position="after">
<br />
<strong>Rounded: </strong>
<field name="unit_amount_rounded" widget="float_time" />
</xpath>
</field>
</record>
<record id="account_analytic_line_tree_inherit" model="ir.ui.view">
<field name="name">account.analytic.line.tree.inherit</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="unit_amount_rounded"
string="Quantity rounded"
sum="Total quantity rounded"
widget="float_time"
/>
</xpath>
</field>
</record>
</odoo>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="project_project_form_inherit" model="ir.ui.view">
<field name="name">project.project.form.inherit</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project" />
<field name="arch" type="xml">
<xpath expr="//page[@name='settings']" position="inside">
<group name="rounding">
<group string="Time rounding" name="time_rounding_parameters">
<field name="timesheet_rounding_method" />
<field
name="timesheet_rounding_unit"
attrs="{'invisible': [('timesheet_rounding_method', '=', 'NO')]}"
/>
<field
name="timesheet_rounding_factor"
attrs="{'invisible': [('timesheet_rounding_method', '=', 'NO')]}"
/>
</group>
</group>
</xpath>
</field>
</record>
</odoo>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="hr_timesheet_view_task_form2_inherited_inherit" model="ir.ui.view">
<field name="name">hr.timesheet.view.task.form2.inherited.inherit</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited" />
<field name="arch" type="xml">
<xpath expr="//field[@name='unit_amount']" position="after">
<field
name="unit_amount_rounded"
string="Duration (rounded)"
widget="float_time"
/>
</xpath>
</field>
</record>
</odoo>

View file

@ -0,0 +1 @@
from . import sale_make_invoice_advance

View file

@ -0,0 +1,21 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import models
class SaleAdvancePaymentInv(models.TransientModel):
_inherit = "sale.advance.payment.inv"
def create_invoices(self):
"""Override method from sale/wizard/sale_make_invoice_advance.py
When the user want to invoice the timesheets to the SO
up to a specific period then we need to recompute the
qty_to_invoice for each product_id in sale.order.line,
before creating the invoice.
"""
return super(
SaleAdvancePaymentInv, self.with_context(timesheet_no_recompute=True)
).create_invoices()