diff --git a/contract_variable_qty_timesheet/README.rst b/contract_variable_qty_timesheet/README.rst new file mode 100644 index 000000000..a7eb6697c --- /dev/null +++ b/contract_variable_qty_timesheet/README.rst @@ -0,0 +1,116 @@ +=============================== +Contract Variable Qty Timesheet +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e5498feee850c8ae2cc09cbae0c07393069f065c83bca8823127e9eec40bbe1b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fcontract-lightgray.png?logo=github + :target: https://github.com/OCA/contract/tree/16.0/contract_variable_qty_timesheet + :alt: OCA/contract +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/contract-16-0/contract-16-0-contract_variable_qty_timesheet + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of contract_variable_quantity adding +several variable quantity formulas to allow to invoice lines from Timesheet +(Analytic Lines). + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Go to Invoicing > Sales > Contracts and select or create a new contract. +#. Check *Generate recurring invoices automatically*. +#. Add a new recurring invoicing line. +#. Select "Variable quantity" in column "Qty. type". +#. Select "Project Timesheets", "Tasks Timesheets" or "Analytic Same Product" + depending on your need. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Carlos Dauden + * Pedro M. Baeza + * Carolina Fernandez + +* `Guadaltech `_: + + * Fernando La Chica + +* `Coopdevs Treball `_: + + * Daniel Palomar + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-carlosdauden| image:: https://github.com/carlosdauden.png?size=40px + :target: https://github.com/carlosdauden + :alt: carlosdauden +.. |maintainer-pedrobaeza| image:: https://github.com/pedrobaeza.png?size=40px + :target: https://github.com/pedrobaeza + :alt: pedrobaeza +.. |maintainer-danypr92| image:: https://github.com/danypr92.png?size=40px + :target: https://github.com/danypr92 + :alt: danypr92 + +Current `maintainers `__: + +|maintainer-carlosdauden| |maintainer-pedrobaeza| |maintainer-danypr92| + +This module is part of the `OCA/contract `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/contract_variable_qty_timesheet/__init__.py b/contract_variable_qty_timesheet/__init__.py new file mode 100644 index 000000000..ef5ae3587 --- /dev/null +++ b/contract_variable_qty_timesheet/__init__.py @@ -0,0 +1 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). diff --git a/contract_variable_qty_timesheet/__manifest__.py b/contract_variable_qty_timesheet/__manifest__.py new file mode 100644 index 000000000..431a39eb7 --- /dev/null +++ b/contract_variable_qty_timesheet/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2018 Tecnativa - Carlos Dauden +# Copyright 2019 Tecnativa - Pedro M. Baeza +# Copyright 2023 Tecnativa - Carolina Fernandez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Contract Variable Qty Timesheet", + "summary": "Add formula to invoice ", + "version": "16.0.1.0.0", + "category": "Contract Management", + "website": "https://github.com/OCA/contract", + "author": "Tecnativa, " "Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["contract_variable_quantity", "hr_timesheet"], + "data": ["data/contract_line_qty_formula_data.xml"], + "maintainers": ["carlosdauden", "pedrobaeza", "danypr92"], +} diff --git a/contract_variable_qty_timesheet/data/contract_line_qty_formula_data.xml b/contract_variable_qty_timesheet/data/contract_line_qty_formula_data.xml new file mode 100644 index 000000000..6be69b9e9 --- /dev/null +++ b/contract_variable_qty_timesheet/data/contract_line_qty_formula_data.xml @@ -0,0 +1,56 @@ + + + + + Project Timesheets + +account_analytic_ids = line.analytic_distribution and [int(_id) for _id in list(line.analytic_distribution.keys())] or [] +group = env['account.analytic.line'].read_group([ + ('account_id', 'in', account_analytic_ids), + ('product_id', '=', False), + ('project_id', '!=', False), + ('date', '>=', period_first_date), + ('date', '<=', period_last_date), +], fields=['unit_amount'], groupby=[]) +result = group and group[0]['unit_amount'] or 0.0 + + + + Task Timesheets + +account_analytic_ids = line.analytic_distribution and [int(_id) for _id in list(line.analytic_distribution.keys())] or [] +group = env['account.analytic.line'].read_group([ + ('account_id', 'in', account_analytic_ids), + ('product_id', '=', False), + ('task_id', '!=', False), + ('date', '>=', period_first_date), + ('date', '<=', period_last_date), +], fields=['unit_amount'], groupby=[]) +result = group and group[0]['unit_amount'] or 0.0 + + + + Analytic Same Product + +account_analytic_ids = line.analytic_distribution and [int(_id) for _id in list(line.analytic_distribution.keys())] or [] +group = env['account.analytic.line'].read_group([ + ('account_id', 'in', account_analytic_ids), + ('product_id', '=', line.product_id.id), + ('date', '>=', period_first_date), + ('date', '<=', period_last_date), +], fields=['unit_amount'], groupby=[]) +result = group and group[0]['unit_amount'] or 0.0 + + + diff --git a/contract_variable_qty_timesheet/i18n/contract_variable_qty_timesheet.pot b/contract_variable_qty_timesheet/i18n/contract_variable_qty_timesheet.pot new file mode 100644 index 000000000..fb5a5693a --- /dev/null +++ b/contract_variable_qty_timesheet/i18n/contract_variable_qty_timesheet.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * contract_variable_qty_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_analytic_same_product +msgid "Analytic Same Product" +msgstr "" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_project_timesheet +msgid "Project Timesheets" +msgstr "" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_task_timesheet +msgid "Task Timesheets" +msgstr "" diff --git a/contract_variable_qty_timesheet/i18n/de.po b/contract_variable_qty_timesheet/i18n/de.po new file mode 100644 index 000000000..cc574369e --- /dev/null +++ b/contract_variable_qty_timesheet/i18n/de.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * contract_variable_qty_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-03-07 15:53+0000\n" +"Last-Translator: Maria Sparenberg \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.4\n" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_analytic_same_product +msgid "Analytic Same Product" +msgstr "Gleiches Produkt" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_project_timesheet +msgid "Project Timesheets" +msgstr "Projekt-Zeiterfassungen" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_task_timesheet +msgid "Task Timesheets" +msgstr "Aufgaben-Zeiterfassungen" diff --git a/contract_variable_qty_timesheet/i18n/es.po b/contract_variable_qty_timesheet/i18n/es.po new file mode 100644 index 000000000..7281d4ce1 --- /dev/null +++ b/contract_variable_qty_timesheet/i18n/es.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * contract_variable_qty_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-29 11:13+0200\n" +"PO-Revision-Date: 2018-03-29 11:21+0200\n" +"Last-Translator: Carlos Dauden \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 1.8.7.1\n" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_analytic_same_product +msgid "Analytic Same Product" +msgstr "Analítica mismo producto" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_project_timesheet +msgid "Project Timesheets" +msgstr "Partes de horas de proyectos" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_task_timesheet +msgid "Task Timesheets" +msgstr "Partes de horas de tareas" diff --git a/contract_variable_qty_timesheet/i18n/fr.po b/contract_variable_qty_timesheet/i18n/fr.po new file mode 100644 index 000000000..4b87abfdd --- /dev/null +++ b/contract_variable_qty_timesheet/i18n/fr.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * contract_variable_qty_timesheet +# +# Translators: +# Quentin THEURET , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-06 21:09+0000\n" +"PO-Revision-Date: 2018-04-06 21:09+0000\n" +"Last-Translator: Quentin THEURET , 2018\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\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" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_analytic_same_product +msgid "Analytic Same Product" +msgstr "Même produit analytique" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_project_timesheet +msgid "Project Timesheets" +msgstr "Feuilles de temps du projet" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_task_timesheet +msgid "Task Timesheets" +msgstr "Feuille de temps de la tâche" diff --git a/contract_variable_qty_timesheet/i18n/it.po b/contract_variable_qty_timesheet/i18n/it.po new file mode 100644 index 000000000..185f083cb --- /dev/null +++ b/contract_variable_qty_timesheet/i18n/it.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * contract_variable_qty_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2018-12-24 23:58+0000\n" +"Last-Translator: Sergio Zanchetta \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 3.3\n" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_analytic_same_product +msgid "Analytic Same Product" +msgstr "" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_project_timesheet +msgid "Project Timesheets" +msgstr "Fogli ore progetto" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_task_timesheet +msgid "Task Timesheets" +msgstr "Fogli ore attività" diff --git a/contract_variable_qty_timesheet/i18n/pt.po b/contract_variable_qty_timesheet/i18n/pt.po new file mode 100644 index 000000000..a71681434 --- /dev/null +++ b/contract_variable_qty_timesheet/i18n/pt.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * contract_variable_qty_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-02-17 19:13+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\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: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_analytic_same_product +msgid "Analytic Same Product" +msgstr "Analítica Mesmo Produto" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_project_timesheet +msgid "Project Timesheets" +msgstr "Folhas de Horas de Projetos" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_task_timesheet +msgid "Task Timesheets" +msgstr "Folhas de horas de Tarefas" diff --git a/contract_variable_qty_timesheet/i18n/pt_BR.po b/contract_variable_qty_timesheet/i18n/pt_BR.po new file mode 100644 index 000000000..57f16b7b1 --- /dev/null +++ b/contract_variable_qty_timesheet/i18n/pt_BR.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * contract_variable_qty_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-10-12 03:42+0000\n" +"Last-Translator: Douglas Custódio \n" +"Language-Team: none\n" +"Language: pt_BR\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: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_analytic_same_product +msgid "Analytic Same Product" +msgstr "Mesmo Produto Analítico" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_project_timesheet +msgid "Project Timesheets" +msgstr "Apontamentos de horas do Projeto" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_task_timesheet +msgid "Task Timesheets" +msgstr "Planilhas de Tempo da Tarefa" diff --git a/contract_variable_qty_timesheet/i18n/zh.po b/contract_variable_qty_timesheet/i18n/zh.po new file mode 100644 index 000000000..95285088b --- /dev/null +++ b/contract_variable_qty_timesheet/i18n/zh.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * contract_variable_qty_timesheet +# +# Translators: +# DIT INTL , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-27 01:12+0000\n" +"PO-Revision-Date: 2018-04-27 01:12+0000\n" +"Last-Translator: DIT INTL , 2018\n" +"Language-Team: Chinese (https://www.transifex.com/oca/teams/23907/zh/)\n" +"Language: zh\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_analytic_same_product +msgid "Analytic Same Product" +msgstr "分析同一产品" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_project_timesheet +msgid "Project Timesheets" +msgstr "项目时间表" + +#. module: contract_variable_qty_timesheet +#: model:contract.line.qty.formula,name:contract_variable_qty_timesheet.contract_line_qty_formula_task_timesheet +msgid "Task Timesheets" +msgstr "任务时间表" diff --git a/contract_variable_qty_timesheet/readme/CONTRIBUTORS.rst b/contract_variable_qty_timesheet/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..b87de8df6 --- /dev/null +++ b/contract_variable_qty_timesheet/readme/CONTRIBUTORS.rst @@ -0,0 +1,13 @@ +* `Tecnativa `_: + + * Carlos Dauden + * Pedro M. Baeza + * Carolina Fernandez + +* `Guadaltech `_: + + * Fernando La Chica + +* `Coopdevs Treball `_: + + * Daniel Palomar diff --git a/contract_variable_qty_timesheet/readme/DESCRIPTION.rst b/contract_variable_qty_timesheet/readme/DESCRIPTION.rst new file mode 100644 index 000000000..0b238e9b7 --- /dev/null +++ b/contract_variable_qty_timesheet/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module extends the functionality of contract_variable_quantity adding +several variable quantity formulas to allow to invoice lines from Timesheet +(Analytic Lines). diff --git a/contract_variable_qty_timesheet/readme/USAGE.rst b/contract_variable_qty_timesheet/readme/USAGE.rst new file mode 100644 index 000000000..9e73d24c6 --- /dev/null +++ b/contract_variable_qty_timesheet/readme/USAGE.rst @@ -0,0 +1,8 @@ +To use this module, you need to: + +#. Go to Invoicing > Customers > Customer Contracts and select or create a new contract. +#. Check *Generate recurring invoices automatically*. +#. Add a new recurring invoicing line. +#. Select "Variable quantity" in column "Qty. type". +#. Select "Project Timesheets", "Tasks Timesheets" or "Analytic Same Product" + depending on your need. diff --git a/contract_variable_qty_timesheet/setup/.setuptools-odoo-make-default-ignore b/contract_variable_qty_timesheet/setup/.setuptools-odoo-make-default-ignore new file mode 100644 index 000000000..207e61533 --- /dev/null +++ b/contract_variable_qty_timesheet/setup/.setuptools-odoo-make-default-ignore @@ -0,0 +1,2 @@ +# addons listed in this file are ignored by +# setuptools-odoo-make-default (one addon per line) diff --git a/contract_variable_qty_timesheet/setup/README b/contract_variable_qty_timesheet/setup/README new file mode 100644 index 000000000..a63d633e8 --- /dev/null +++ b/contract_variable_qty_timesheet/setup/README @@ -0,0 +1,2 @@ +To learn more about this directory, please visit +https://pypi.python.org/pypi/setuptools-odoo diff --git a/contract_variable_qty_timesheet/static/description/icon.png b/contract_variable_qty_timesheet/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/contract_variable_qty_timesheet/static/description/icon.png differ diff --git a/contract_variable_qty_timesheet/static/description/index.html b/contract_variable_qty_timesheet/static/description/index.html new file mode 100644 index 000000000..ee708dc18 --- /dev/null +++ b/contract_variable_qty_timesheet/static/description/index.html @@ -0,0 +1,450 @@ + + + + + +Contract Variable Qty Timesheet + + + +
+

Contract Variable Qty Timesheet

+ + +

Beta License: AGPL-3 OCA/contract Translate me on Weblate Try me on Runboat

+

This module extends the functionality of contract_variable_quantity adding +several variable quantity formulas to allow to invoice lines from Timesheet +(Analytic Lines).

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Invoicing > Sales > Contracts and select or create a new contract.
  2. +
  3. Check Generate recurring invoices automatically.
  4. +
  5. Add a new recurring invoicing line.
  6. +
  7. Select “Variable quantity” in column “Qty. type”.
  8. +
  9. Select “Project Timesheets”, “Tasks Timesheets” or “Analytic Same Product” +depending on your need.
  10. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainers:

+

carlosdauden pedrobaeza danypr92

+

This module is part of the OCA/contract project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/contract_variable_qty_timesheet/tests/__init__.py b/contract_variable_qty_timesheet/tests/__init__.py new file mode 100644 index 000000000..2bdf08124 --- /dev/null +++ b/contract_variable_qty_timesheet/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_contract_variable_qty_timesheet diff --git a/contract_variable_qty_timesheet/tests/test_contract_variable_qty_timesheet.py b/contract_variable_qty_timesheet/tests/test_contract_variable_qty_timesheet.py new file mode 100644 index 000000000..6f1f68212 --- /dev/null +++ b/contract_variable_qty_timesheet/tests/test_contract_variable_qty_timesheet.py @@ -0,0 +1,116 @@ +# Copyright 2019 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields +from odoo.tests.common import TransactionCase + + +class TestContractVariableQtyTimesheet(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.company = cls.env.company + cls.partner = cls.env["res.partner"].create( + {"name": "Test partner", "company_id": cls.company.id} + ) + cls.plan = cls.env["account.analytic.plan"].create({"name": "Test Plan"}) + cls.analytic_account = cls.env["account.analytic.account"].create( + { + "name": "Test analytic account", + "plan_id": cls.plan.id, + "company_id": cls.company.id, + } + ) + cls.contract = cls.env["contract.contract"].create( + { + "name": "Test contract", + "partner_id": cls.partner.id, + "company_id": cls.company.id, + } + ) + cls.product = cls.env["product.product"].create( + {"name": "Test product", "company_id": cls.company.id} + ) + cls.employee = cls.env["hr.employee"].create( + { + "name": "Test Employee", + "company_id": cls.company.id, + } + ) + contract_line_vals = { + "name": "Test contract line", + "contract_id": cls.contract.id, + "date_start": "2020-01-01", + "date_end": "2020-12-31", + "product_id": cls.product.id, + "qty_formula_id": cls.env.ref( + "contract_variable_qty_timesheet.contract_line_qty_formula_project_timesheet" + ).id, + "sequence": 10, + "state": "in-progress", + "company_id": cls.company.id, + "qty_type": "variable", + "analytic_distribution": {str(cls.analytic_account.id): 100}, + } + cls.contract_line = cls.env["contract.line"].create(contract_line_vals) + cls.project = cls.env["project.project"].create( + { + "name": "Test project", + "analytic_account_id": cls.analytic_account.id, + "company_id": cls.company.id, + } + ) + cls.task = cls.env["project.task"].create( + { + "project_id": cls.project.id, + "name": "Test task", + "company_id": cls.company.id, + } + ) + + def _contract_invoicing(self, contract): + date_ref = fields.Date.from_string("2020-01-01") + contract._recurring_create_invoice(date_ref) + return contract._get_related_invoices() + + def _create_analytic_line(self, project, task, date, product, unit_amount): + return self.env["account.analytic.line"].create( + { + "account_id": self.analytic_account.id, + "project_id": project and project.id, + "task_id": task and task.id, + "name": f"Test {date} {unit_amount}", + "date": date, + "product_id": product and product.id, + "unit_amount": unit_amount, + "employee_id": self.employee.id, + "company_id": self.company.id, + } + ) + + def test_project_timesheet(self): + self._create_analytic_line(self.project, self.task, "2020-01-01", False, 3) + self._create_analytic_line(False, False, "2020-01-01", False, 1) + invoice = self.contract._recurring_create_invoice() + self.assertEqual(len(invoice.invoice_line_ids), 1) + self.assertAlmostEqual(invoice.invoice_line_ids.quantity, 3) + + def test_task_timesheet(self): + self.contract_line.qty_formula_id = self.env.ref( + "contract_variable_qty_timesheet.contract_line_qty_formula_task_timesheet" + ).id + self._create_analytic_line(self.project, self.task, "2020-01-01", False, 3) + self._create_analytic_line(self.project, False, "2020-01-01", False, 1) + invoice = self.contract._recurring_create_invoice() + self.assertEqual(len(invoice.invoice_line_ids), 1) + self.assertAlmostEqual(invoice.invoice_line_ids.quantity, 3) + + def test_same_product(self): + self.contract_line.qty_formula_id = self.env.ref( + "contract_variable_qty_timesheet.contract_line_qty_formula_analytic_same_product" + ).id + self._create_analytic_line(False, False, "2020-01-01", self.product, 3) + self._create_analytic_line(self.project, False, "2020-01-01", False, 1) + invoice = self.contract._recurring_create_invoice() + self.assertEqual(len(invoice.invoice_line_ids), 1) + self.assertAlmostEqual(invoice.invoice_line_ids.quantity, 3) diff --git a/setup/contract_variable_qty_timesheet/odoo/addons/contract_variable_qty_timesheet b/setup/contract_variable_qty_timesheet/odoo/addons/contract_variable_qty_timesheet new file mode 120000 index 000000000..ce534c866 --- /dev/null +++ b/setup/contract_variable_qty_timesheet/odoo/addons/contract_variable_qty_timesheet @@ -0,0 +1 @@ +../../../../contract_variable_qty_timesheet \ No newline at end of file diff --git a/setup/contract_variable_qty_timesheet/setup.py b/setup/contract_variable_qty_timesheet/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/contract_variable_qty_timesheet/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)