diff --git a/contract_variable_qty_timesheet/README.rst b/contract_variable_qty_timesheet/README.rst new file mode 100644 index 000000000..651aea9ac --- /dev/null +++ b/contract_variable_qty_timesheet/README.rst @@ -0,0 +1,108 @@ +=============================== +Contract Variable Qty Timesheet +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5ac85c806a69d7e4ecd65ddf220774240d8f64392b79b10183460c3a01d4d572 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |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/13.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-13-0/contract-13-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=13.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 + +* `Guadaltech `_: + + * Fernando La Chica + +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 + +Current `maintainers `__: + +|maintainer-carlosdauden| |maintainer-pedrobaeza| + +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..7448dd8cc --- /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": "15.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"], +} 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..6ee6d1636 --- /dev/null +++ b/contract_variable_qty_timesheet/data/contract_line_qty_formula_data.xml @@ -0,0 +1,50 @@ + + + + + Project Timesheets + group = env['account.analytic.line'].read_group([ + ('account_id', '=', line.analytic_account_id.id), + ('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 + group = env['account.analytic.line'].read_group([ + ('account_id', '=', line.analytic_account_id.id), + ('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 + group = env['account.analytic.line'].read_group([ + ('account_id', '=', line.analytic_account_id.id), + ('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..290e919b5 --- /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 13.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..f0f322638 --- /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..938e1c85f --- /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..4df8fa1b4 --- /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..e58d51e7b --- /dev/null +++ b/contract_variable_qty_timesheet/readme/CONTRIBUTORS.rst @@ -0,0 +1,9 @@ +* `Tecnativa `_: + + * Carlos Dauden + * Pedro M. Baeza + * Carolina Fernandez + +* `Guadaltech `_: + + * Fernando La Chica 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..3ca264dc0 --- /dev/null +++ b/contract_variable_qty_timesheet/readme/USAGE.rst @@ -0,0 +1,8 @@ +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. 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..dd2a6c052 --- /dev/null +++ b/contract_variable_qty_timesheet/static/description/index.html @@ -0,0 +1,447 @@ + + + + + + +Contract Variable Qty Timesheet + + + +
+

Contract Variable Qty Timesheet

+ + +

Production/Stable 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

+

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..684a9e406 --- /dev/null +++ b/contract_variable_qty_timesheet/tests/test_contract_variable_qty_timesheet.py @@ -0,0 +1,90 @@ +# 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 import common + + +class TestContractVariableQtyTimesheet(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner = cls.env["res.partner"].create({"name": "Test partner"}) + cls.analytic_account = cls.env["account.analytic.account"].create( + {"name": "Test analytic account"} + ) + cls.contract = cls.env["contract.contract"].create( + {"name": "Test contract", "partner_id": cls.partner.id} + ) + cls.product = cls.env["product.product"].create({"name": "Test product"}) + contract_line_vals = { + "contract_id": cls.contract.id, + "analytic_account_id": cls.analytic_account.id, + "product_id": cls.product.id, + "uom_id": cls.product.uom_id.id, + "name": "Test line contract", + "recurring_interval": 1, + "recurring_rule_type": "monthly", + "recurring_invoicing_type": "pre-paid", + "date_start": "2020-01-01", + "recurring_next_date": "2020-01-01", + "qty_type": "variable", + "qty_formula_id": cls.env.ref( + "contract_variable_qty_timesheet." + "contract_line_qty_formula_project_timesheet" + ).id, + } + 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} + ) + cls.task = cls.env["project.task"].create( + {"project_id": cls.project.id, "name": "Test task"} + ) + + 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": "Test {} {}".format(date, unit_amount), + "date": date, + "product_id": product and product.id, + "unit_amount": unit_amount, + } + ) + + 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_invoicing(self.contract) + 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_invoicing(self.contract) + 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_invoicing(self.contract) + 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, +)