From 43d21a3a4a62ef8187f2bc9a11056026fb4ce778 Mon Sep 17 00:00:00 2001 From: Ted Salmon Date: Thu, 12 Jan 2017 13:16:25 -0800 Subject: [PATCH 01/73] [ADD] product_contract: Create module * Add contract functionality to `product.templates` * Add logic to create contracts from `sale.order` that contains contract products. --- product_contract/README.rst | 66 +++++++++++++++++++ product_contract/__init__.py | 5 ++ product_contract/__manifest__.py | 23 +++++++ product_contract/models/__init__.py | 7 ++ product_contract/models/product_template.py | 23 +++++++ product_contract/models/sale_order.py | 27 ++++++++ product_contract/models/sale_order_line.py | 14 ++++ product_contract/tests/__init__.py | 6 ++ .../tests/test_product_template.py | 31 +++++++++ product_contract/tests/test_sale_order.py | 34 ++++++++++ .../views/product_template_view.xml | 29 ++++++++ 11 files changed, 265 insertions(+) create mode 100644 product_contract/README.rst create mode 100644 product_contract/__init__.py create mode 100644 product_contract/__manifest__.py create mode 100644 product_contract/models/__init__.py create mode 100644 product_contract/models/product_template.py create mode 100644 product_contract/models/sale_order.py create mode 100644 product_contract/models/sale_order_line.py create mode 100644 product_contract/tests/__init__.py create mode 100644 product_contract/tests/test_product_template.py create mode 100644 product_contract/tests/test_sale_order.py create mode 100644 product_contract/views/product_template_view.xml diff --git a/product_contract/README.rst b/product_contract/README.rst new file mode 100644 index 00000000..6319dcf5 --- /dev/null +++ b/product_contract/README.rst @@ -0,0 +1,66 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +================ +Product Contract +================ + +This module adds support for products to be linked to contract templates. +It also adds functionality to automatically create a contract, from the template, +when a ``sale.order`` contains a product that implements a contract. + +Usage +===== + +To use this module, you need to: + +#. Go to Sales -> Products and select or create a product. +#. Check "Is a contract" and select the contract template related to the + product + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/110/10.0 + +Known issues / Roadmap +====================== + +* None + +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 smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Ted Salmon + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/product_contract/__init__.py b/product_contract/__init__.py new file mode 100644 index 00000000..44db863b --- /dev/null +++ b/product_contract/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py new file mode 100644 index 00000000..e1d4d8ac --- /dev/null +++ b/product_contract/__manifest__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'Product Contract', + 'version': '10.0.1.0.0', + 'category': 'Contract Management', + 'license': 'AGPL-3', + 'author': "LasLabs, " + "Odoo Community Association (OCA)", + 'website': 'https://laslabs.com', + 'depends': [ + 'contract', + 'product', + 'sale', + ], + 'data': [ + 'views/product_template_view.xml', + ], + 'installable': True, + 'application': False, +} diff --git a/product_contract/models/__init__.py b/product_contract/models/__init__.py new file mode 100644 index 00000000..388717d2 --- /dev/null +++ b/product_contract/models/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import product_template +from . import sale_order +from . import sale_order_line diff --git a/product_contract/models/product_template.py b/product_contract/models/product_template.py new file mode 100644 index 00000000..fd7e00d4 --- /dev/null +++ b/product_contract/models/product_template.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + is_contract = fields.Boolean('Is a contract') + contract_template_id = fields.Many2one( + comodel_name='account.analytic.contract', + string='Contract Template', + ) + + @api.onchange('is_contract') + def _change_is_contract(self): + """ Clear the relation to contract_template_id when downgrading + product from contract + """ + if not self.is_contract: + self.contract_template_id = False diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py new file mode 100644 index 00000000..45f2eec7 --- /dev/null +++ b/product_contract/models/sale_order.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class SaleOrder(models.Model): + _inherit = 'sale.order' + + @api.multi + def action_confirm(self): + """ If we have a contract in the order, set it up """ + for rec in self: + order_lines = self.mapped('order_line').filtered( + lambda r: r.product_id.is_contract + ) + for line in order_lines: + contract_tmpl = line.product_id.contract_template_id + contract = self.env['account.analytic.account'].create({ + 'name': '%s Contract' % rec.name, + 'partner_id': rec.partner_id.id, + 'contract_template_id': contract_tmpl.id, + }) + line.contract_id = contract.id + contract.recurring_create_invoice() + return super(SaleOrder, self).action_confirm() diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py new file mode 100644 index 00000000..c76c1059 --- /dev/null +++ b/product_contract/models/sale_order_line.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + contract_id = fields.Many2one( + comodel_name='account.analytic.account', + string='Contract' + ) diff --git a/product_contract/tests/__init__.py b/product_contract/tests/__init__.py new file mode 100644 index 00000000..e5fbe249 --- /dev/null +++ b/product_contract/tests/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_product_template +from . import test_sale_order diff --git a/product_contract/tests/test_product_template.py b/product_contract/tests/test_product_template.py new file mode 100644 index 00000000..2938cc7f --- /dev/null +++ b/product_contract/tests/test_product_template.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import TransactionCase + + +class TestProductTemplate(TransactionCase): + + def setUp(self): + super(TestProductTemplate, self).setUp() + self.product = self.env.ref( + 'product.product_product_4_product_template' + ) + self.contract = self.env['account.analytic.contract'].create({ + 'name': 'Test', + 'recurring_rule_type': 'yearly', + 'recurring_interval': 12345, + }) + + def test_change_is_contract(self): + """ It should verify that the contract_template_id is removed + when is_contract is False """ + self.product.is_contract = True + self.product.contract_template_id = self.contract.id + self.product.is_contract = False + self.product._change_is_contract() + self.assertEquals( + len(self.product.contract_template_id), + 0 + ) diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py new file mode 100644 index 00000000..7ca4c099 --- /dev/null +++ b/product_contract/tests/test_sale_order.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from mock import MagicMock +from odoo.tests.common import TransactionCase + + +class TestSaleOrder(TransactionCase): + + def setUp(self): + super(TestSaleOrder, self).setUp() + self.product = self.env.ref('product.product_product_1') + self.sale = self.env.ref('sale.sale_order_2') + self.contract = self.env['account.analytic.contract'].create({ + 'name': 'Test', + 'recurring_rule_type': 'yearly', + 'recurring_interval': 12345, + }) + self.product.product_tmpl_id.is_contract = True + self.product.product_tmpl_id.contract_template_id = self.contract.id + + def test_action_done(self): + """ It should create a contract when the sale for a contract is set + to done for the first time """ + self.env['account.analytic.account']._patch_method( + 'create', MagicMock() + ) + self.sale.action_confirm() + self.env['account.analytic.account'].create.assert_called_once_with({ + 'name': '%s Contract' % self.sale.name, + 'partner_id': self.sale.partner_id.id, + 'contract_template_id': self.contract.id, + }) diff --git a/product_contract/views/product_template_view.xml b/product_contract/views/product_template_view.xml new file mode 100644 index 00000000..46c2e05c --- /dev/null +++ b/product_contract/views/product_template_view.xml @@ -0,0 +1,29 @@ + + + + + + + + account.invoice.select.contract + product.template + + + +
+ +
+
+ + + +
+
+ +
From e6999f1c3965a07c59ba6327076bd72b1ad3377d Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Mon, 1 May 2017 17:48:45 +0200 Subject: [PATCH 02/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/de.po | 51 +++++++++++++++++++++++++++++++++ product_contract/i18n/es.po | 51 +++++++++++++++++++++++++++++++++ product_contract/i18n/fr.po | 51 +++++++++++++++++++++++++++++++++ product_contract/i18n/hr.po | 51 +++++++++++++++++++++++++++++++++ product_contract/i18n/hr_HR.po | 52 ++++++++++++++++++++++++++++++++++ product_contract/i18n/it.po | 51 +++++++++++++++++++++++++++++++++ product_contract/i18n/nl.po | 51 +++++++++++++++++++++++++++++++++ product_contract/i18n/pt_BR.po | 51 +++++++++++++++++++++++++++++++++ product_contract/i18n/tr_TR.po | 51 +++++++++++++++++++++++++++++++++ 9 files changed, 460 insertions(+) create mode 100644 product_contract/i18n/de.po create mode 100644 product_contract/i18n/es.po create mode 100644 product_contract/i18n/fr.po create mode 100644 product_contract/i18n/hr.po create mode 100644 product_contract/i18n/hr_HR.po create mode 100644 product_contract/i18n/it.po create mode 100644 product_contract/i18n/nl.po create mode 100644 product_contract/i18n/pt_BR.po create mode 100644 product_contract/i18n/tr_TR.po diff --git a/product_contract/i18n/de.po b/product_contract/i18n/de.po new file mode 100644 index 00000000..3b62b544 --- /dev/null +++ b/product_contract/i18n/de.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-27 02:40+0000\n" +"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Vertrag" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/product_contract/i18n/es.po b/product_contract/i18n/es.po new file mode 100644 index 00000000..a89a0a12 --- /dev/null +++ b/product_contract/i18n/es.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-27 02:40+0000\n" +"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Contrato" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/product_contract/i18n/fr.po b/product_contract/i18n/fr.po new file mode 100644 index 00000000..1efcaf7c --- /dev/null +++ b/product_contract/i18n/fr.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# leemannd , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-27 02:40+0000\n" +"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"Last-Translator: leemannd , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Contrat" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/product_contract/i18n/hr.po b/product_contract/i18n/hr.po new file mode 100644 index 00000000..7f2b4f8c --- /dev/null +++ b/product_contract/i18n/hr.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Bole , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-27 02:40+0000\n" +"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"Last-Translator: Bole , 2017\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: hr\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Ugovor" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/product_contract/i18n/hr_HR.po b/product_contract/i18n/hr_HR.po new file mode 100644 index 00000000..922d93fb --- /dev/null +++ b/product_contract/i18n/hr_HR.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Bole , 2017 +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-27 02:40+0000\n" +"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Croatian (Croatia) (https://www.transifex.com/oca/teams/23907/hr_HR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: hr_HR\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Ugovor" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "Predložak ugovora" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/product_contract/i18n/it.po b/product_contract/i18n/it.po new file mode 100644 index 00000000..982bdf76 --- /dev/null +++ b/product_contract/i18n/it.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Lorenzo Battistini , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-27 02:40+0000\n" +"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"Last-Translator: Lorenzo Battistini , 2017\n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Contratto" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "Template di contratto" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/product_contract/i18n/nl.po b/product_contract/i18n/nl.po new file mode 100644 index 00000000..4c309a25 --- /dev/null +++ b/product_contract/i18n/nl.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Erwin van der Ploeg , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-27 02:40+0000\n" +"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"Last-Translator: Erwin van der Ploeg , 2017\n" +"Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Contract" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/product_contract/i18n/pt_BR.po b/product_contract/i18n/pt_BR.po new file mode 100644 index 00000000..592c6aae --- /dev/null +++ b/product_contract/i18n/pt_BR.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Albert Vonpupp , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-27 02:40+0000\n" +"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"Last-Translator: Albert Vonpupp , 2017\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Contrato" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/product_contract/i18n/tr_TR.po b/product_contract/i18n/tr_TR.po new file mode 100644 index 00000000..5bcb2f7e --- /dev/null +++ b/product_contract/i18n/tr_TR.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Ediz Duman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-27 02:40+0000\n" +"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"Last-Translator: Ediz Duman , 2017\n" +"Language-Team: Turkish (Turkey) (https://www.transifex.com/oca/teams/23907/tr_TR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: tr_TR\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Sözleşme" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" From 7bb7eefd45f61fcfab5b6d0aecdacd5beac9cad5 Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Thu, 25 May 2017 17:51:46 -0700 Subject: [PATCH 03/73] [FIX] product_contract: Fix mock usage in tests --- product_contract/tests/test_sale_order.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index 7ca4c099..98b174ff 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -20,6 +20,11 @@ class TestSaleOrder(TransactionCase): self.product.product_tmpl_id.is_contract = True self.product.product_tmpl_id.contract_template_id = self.contract.id + def tearDown(self): + self.env['account.analytic.account']._revert_method( + 'create', + ) + def test_action_done(self): """ It should create a contract when the sale for a contract is set to done for the first time """ From 8ef810084108d96e77bc966de3f5aaced3309a0e Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 27 May 2017 02:29:11 +0200 Subject: [PATCH 04/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/tr.po | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 product_contract/i18n/tr.po diff --git a/product_contract/i18n/tr.po b/product_contract/i18n/tr.po new file mode 100644 index 00000000..9887463f --- /dev/null +++ b/product_contract/i18n/tr.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Ediz Duman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-13 09:15+0000\n" +"PO-Revision-Date: 2017-05-13 09:15+0000\n" +"Last-Translator: Ediz Duman , 2017\n" +"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: tr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Sözleşme" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "Sözleşme Şablonu" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" From cbf30ad603ac166af94fc95bb50fd276bdb79f39 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 10 Jun 2017 03:13:12 +0200 Subject: [PATCH 05/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/nl_NL.po | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 product_contract/i18n/nl_NL.po diff --git a/product_contract/i18n/nl_NL.po b/product_contract/i18n/nl_NL.po new file mode 100644 index 00000000..31a87e09 --- /dev/null +++ b/product_contract/i18n/nl_NL.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-09 01:10+0000\n" +"PO-Revision-Date: 2017-06-09 01:10+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nl_NL\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Contract" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "Contractsjabloon" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "Is een contract" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "Productsjabloon" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "Verkooporder" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "Verkooporderregel" From 3d315d1bbccd0f8be21ea9ccb31ed298e20d30e4 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 17 Jun 2017 03:12:34 +0200 Subject: [PATCH 06/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/pt_BR.po | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/product_contract/i18n/pt_BR.po b/product_contract/i18n/pt_BR.po index 592c6aae..cbe23885 100644 --- a/product_contract/i18n/pt_BR.po +++ b/product_contract/i18n/pt_BR.po @@ -3,14 +3,15 @@ # * product_contract # # Translators: -# Albert Vonpupp , 2017 +# OCA Transbot , 2017 +# falexandresilva , 2017 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-27 02:40+0000\n" -"PO-Revision-Date: 2017-04-27 02:40+0000\n" -"Last-Translator: Albert Vonpupp , 2017\n" +"POT-Creation-Date: 2017-06-13 02:40+0000\n" +"PO-Revision-Date: 2017-06-13 02:40+0000\n" +"Last-Translator: falexandresilva , 2017\n" "Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -43,7 +44,7 @@ msgstr "" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order msgid "Sales Order" -msgstr "" +msgstr "Pedido de compras" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order_line From 70313b4247c3e9f337bdbd640deed5a9d1112c13 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 8 Jul 2017 03:14:24 +0200 Subject: [PATCH 07/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/hr_HR.po | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/product_contract/i18n/hr_HR.po b/product_contract/i18n/hr_HR.po index 922d93fb..1248f3f2 100644 --- a/product_contract/i18n/hr_HR.po +++ b/product_contract/i18n/hr_HR.po @@ -3,15 +3,15 @@ # * product_contract # # Translators: -# Bole , 2017 # OCA Transbot , 2017 +# Bole , 2017 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-27 02:40+0000\n" -"PO-Revision-Date: 2017-04-27 02:40+0000\n" -"Last-Translator: OCA Transbot , 2017\n" +"POT-Creation-Date: 2017-06-17 01:39+0000\n" +"PO-Revision-Date: 2017-06-17 01:39+0000\n" +"Last-Translator: Bole , 2017\n" "Language-Team: Croatian (Croatia) (https://www.transifex.com/oca/teams/23907/hr_HR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -34,19 +34,19 @@ msgstr "Predložak ugovora" #: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract #: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract msgid "Is a contract" -msgstr "" +msgstr "Je ugovor" #. module: product_contract #: model:ir.model,name:product_contract.model_product_template msgid "Product Template" -msgstr "" +msgstr "Predložak proizvoda" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order msgid "Sales Order" -msgstr "" +msgstr "Prodajni nalog" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order_line msgid "Sales Order Line" -msgstr "" +msgstr "Stavka prodajnog naloga" From 5ed3039d31623c595074c74280808ed9f4fb8806 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 22 Jul 2017 03:13:58 +0200 Subject: [PATCH 08/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/pt.po | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 product_contract/i18n/pt.po diff --git a/product_contract/i18n/pt.po b/product_contract/i18n/pt.po new file mode 100644 index 00000000..edcf09df --- /dev/null +++ b/product_contract/i18n/pt.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Pedro Castro Silva , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-15 01:24+0000\n" +"PO-Revision-Date: 2017-07-15 01:24+0000\n" +"Last-Translator: Pedro Castro Silva , 2017\n" +"Language-Team: Portuguese (https://www.transifex.com/oca/teams/23907/pt/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Contrato" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "Modelo de Contrato" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "É um Contrato" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "Modelo de Produto" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "Encomenda de Venda" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "Linha de Encomenda de Venda" From d11badacef805b367ce122da6ef243546055d6f4 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 19 Aug 2017 03:16:47 +0200 Subject: [PATCH 09/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/hi_IN.po | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 product_contract/i18n/hi_IN.po diff --git a/product_contract/i18n/hi_IN.po b/product_contract/i18n/hi_IN.po new file mode 100644 index 00000000..fe5f0e87 --- /dev/null +++ b/product_contract/i18n/hi_IN.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Ashish Deshmukh , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-08-17 01:05+0000\n" +"PO-Revision-Date: 2017-08-17 01:05+0000\n" +"Last-Translator: Ashish Deshmukh , 2017\n" +"Language-Team: Hindi (India) (https://www.transifex.com/oca/teams/23907/hi_IN/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: hi_IN\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "अनुबंध" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "अनुबंध टेम्पलेट" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "एक अनुबंध है" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "प्रोडक्ट टेम्पलेट" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "बिक्री आदेश" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "बिक्री आदेश पंक्ति" From cb834606ccf29c2c1a225556f1777d9a6b0e6423 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 9 Dec 2017 03:33:26 +0100 Subject: [PATCH 10/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/es.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/product_contract/i18n/es.po b/product_contract/i18n/es.po index a89a0a12..d7dea7a1 100644 --- a/product_contract/i18n/es.po +++ b/product_contract/i18n/es.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-27 02:40+0000\n" -"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"POT-Creation-Date: 2017-12-08 01:46+0000\n" +"PO-Revision-Date: 2017-12-08 01:46+0000\n" "Last-Translator: OCA Transbot , 2017\n" "Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" "MIME-Version: 1.0\n" @@ -27,7 +27,7 @@ msgstr "Contrato" #: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id #: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id msgid "Contract Template" -msgstr "" +msgstr "Plantilla de contrato" #. module: product_contract #: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract From 523f8b017b785b886ce781fd7c09ca7ba163b1f5 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 3 Feb 2018 04:14:55 +0100 Subject: [PATCH 11/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/nl.po | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/product_contract/i18n/nl.po b/product_contract/i18n/nl.po index 4c309a25..bdc4ca24 100644 --- a/product_contract/i18n/nl.po +++ b/product_contract/i18n/nl.po @@ -4,13 +4,14 @@ # # Translators: # Erwin van der Ploeg , 2017 +# lfreeke , 2018 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-27 02:40+0000\n" -"PO-Revision-Date: 2017-04-27 02:40+0000\n" -"Last-Translator: Erwin van der Ploeg , 2017\n" +"POT-Creation-Date: 2018-01-06 03:17+0000\n" +"PO-Revision-Date: 2018-01-06 03:17+0000\n" +"Last-Translator: lfreeke , 2018\n" "Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -27,25 +28,25 @@ msgstr "Contract" #: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id #: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id msgid "Contract Template" -msgstr "" +msgstr "Contractsjabloon" #. module: product_contract #: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract #: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract msgid "Is a contract" -msgstr "" +msgstr "Is een contract" #. module: product_contract #: model:ir.model,name:product_contract.model_product_template msgid "Product Template" -msgstr "" +msgstr "Productsjabloon" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order msgid "Sales Order" -msgstr "" +msgstr "Verkooporder" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order_line msgid "Sales Order Line" -msgstr "" +msgstr "Verkooporderregel" From 6fc479e71ae865879559f7c4d7da876538fbd234 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 3 Mar 2018 04:13:30 +0100 Subject: [PATCH 12/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/es.po | 15 ++++++++------- product_contract/i18n/hr.po | 14 +++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/product_contract/i18n/es.po b/product_contract/i18n/es.po index d7dea7a1..d712dd0e 100644 --- a/product_contract/i18n/es.po +++ b/product_contract/i18n/es.po @@ -4,13 +4,14 @@ # # Translators: # OCA Transbot , 2017 +# enjolras , 2018 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-12-08 01:46+0000\n" -"PO-Revision-Date: 2017-12-08 01:46+0000\n" -"Last-Translator: OCA Transbot , 2017\n" +"POT-Creation-Date: 2018-02-10 03:15+0000\n" +"PO-Revision-Date: 2018-02-10 03:15+0000\n" +"Last-Translator: enjolras , 2018\n" "Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -33,19 +34,19 @@ msgstr "Plantilla de contrato" #: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract #: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract msgid "Is a contract" -msgstr "" +msgstr "Es un contrato" #. module: product_contract #: model:ir.model,name:product_contract.model_product_template msgid "Product Template" -msgstr "" +msgstr "Plantilla de producto" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order msgid "Sales Order" -msgstr "" +msgstr "Pedido de venta" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order_line msgid "Sales Order Line" -msgstr "" +msgstr "Línea de pedido de venta" diff --git a/product_contract/i18n/hr.po b/product_contract/i18n/hr.po index 7f2b4f8c..2cfaafae 100644 --- a/product_contract/i18n/hr.po +++ b/product_contract/i18n/hr.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-27 02:40+0000\n" -"PO-Revision-Date: 2017-04-27 02:40+0000\n" +"POT-Creation-Date: 2018-02-10 03:15+0000\n" +"PO-Revision-Date: 2018-02-10 03:15+0000\n" "Last-Translator: Bole , 2017\n" "Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" "MIME-Version: 1.0\n" @@ -27,25 +27,25 @@ msgstr "Ugovor" #: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id #: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id msgid "Contract Template" -msgstr "" +msgstr "Predložak ugovora" #. module: product_contract #: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract #: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract msgid "Is a contract" -msgstr "" +msgstr "Je ugovor" #. module: product_contract #: model:ir.model,name:product_contract.model_product_template msgid "Product Template" -msgstr "" +msgstr "Predložak proizvoda" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order msgid "Sales Order" -msgstr "" +msgstr "Ponuda" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order_line msgid "Sales Order Line" -msgstr "" +msgstr "Stavka ponude" From be7313b2a78a92457214b9dbfeabd36ee26a78ab Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 17 Mar 2018 04:14:31 +0100 Subject: [PATCH 13/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/fi.po | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 product_contract/i18n/fi.po diff --git a/product_contract/i18n/fi.po b/product_contract/i18n/fi.po new file mode 100644 index 00000000..9daef38d --- /dev/null +++ b/product_contract/i18n/fi.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# Jarmo Kortetjärvi , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-10 01:44+0000\n" +"PO-Revision-Date: 2018-03-10 01:44+0000\n" +"Last-Translator: Jarmo Kortetjärvi , 2018\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fi\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Contract" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "Sopimusmalli" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" From f2a9b93df884abfe8d07d518b3ab3494e6b63ca2 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 24 Mar 2018 04:16:05 +0100 Subject: [PATCH 14/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/ru.po | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 product_contract/i18n/ru.po diff --git a/product_contract/i18n/ru.po b/product_contract/i18n/ru.po new file mode 100644 index 00000000..f78f50ad --- /dev/null +++ b/product_contract/i18n/ru.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +# Translators: +# nek, 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-17 03:26+0000\n" +"PO-Revision-Date: 2018-03-17 03:26+0000\n" +"Last-Translator: nek, 2018\n" +"Language-Team: Russian (https://www.transifex.com/oca/teams/23907/ru/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: ru\n" +"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "Договор" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "Шаблон Договора" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "Это Договор" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "Шаблон Продукта" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" From 589e9b06847bc65f10a65ecefd7b723c6df0c359 Mon Sep 17 00:00:00 2001 From: Florent THOMAS Date: Sun, 1 Apr 2018 19:21:52 +0200 Subject: [PATCH 15/73] [FIX] contract_sale_generation: it doesn't create sales (#141) * Change the method called in the view * Complete the create_invoice method * Bump version + authoring * Correct bad call of method Small Documentation * Add super call in python test * FIX bad field names causing bad quantities in sale.order.line --- product_contract/tests/test_sale_order.py | 1 + 1 file changed, 1 insertion(+) diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index 98b174ff..61f33858 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -24,6 +24,7 @@ class TestSaleOrder(TransactionCase): self.env['account.analytic.account']._revert_method( 'create', ) + super(TestSaleOrder, self).tearDown() def test_action_done(self): """ It should create a contract when the sale for a contract is set From fc441bde9b2f170e95dfeeab36e9485471263cfe Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 14 Apr 2018 04:12:00 +0200 Subject: [PATCH 16/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/fr.po | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/product_contract/i18n/fr.po b/product_contract/i18n/fr.po index 1efcaf7c..ba5a5b9c 100644 --- a/product_contract/i18n/fr.po +++ b/product_contract/i18n/fr.po @@ -4,13 +4,14 @@ # # Translators: # leemannd , 2017 +# David BEAL, 2018 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-27 02:40+0000\n" -"PO-Revision-Date: 2017-04-27 02:40+0000\n" -"Last-Translator: leemannd , 2017\n" +"POT-Creation-Date: 2018-04-03 12:19+0000\n" +"PO-Revision-Date: 2018-04-03 12:19+0000\n" +"Last-Translator: David BEAL, 2018\n" "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -43,7 +44,7 @@ msgstr "" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order msgid "Sales Order" -msgstr "" +msgstr "Vente" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order_line From 37b3eaeb6838f1dfe7a96f328b5962d2ec4b6bcd Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 5 May 2018 04:13:46 +0200 Subject: [PATCH 17/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/tr.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/product_contract/i18n/tr.po b/product_contract/i18n/tr.po index 9887463f..f5e12fea 100644 --- a/product_contract/i18n/tr.po +++ b/product_contract/i18n/tr.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-05-13 09:15+0000\n" -"PO-Revision-Date: 2017-05-13 09:15+0000\n" +"POT-Creation-Date: 2018-04-21 01:48+0000\n" +"PO-Revision-Date: 2018-04-21 01:48+0000\n" "Last-Translator: Ediz Duman , 2017\n" "Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" "MIME-Version: 1.0\n" @@ -33,19 +33,19 @@ msgstr "Sözleşme Şablonu" #: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract #: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract msgid "Is a contract" -msgstr "" +msgstr "Sözleşmeli" #. module: product_contract #: model:ir.model,name:product_contract.model_product_template msgid "Product Template" -msgstr "" +msgstr "Ürün Şablonu" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order msgid "Sales Order" -msgstr "" +msgstr "Satış Siparişi" #. module: product_contract #: model:ir.model,name:product_contract.model_sale_order_line msgid "Sales Order Line" -msgstr "" +msgstr "Satış Sipariş Satırı" From 52b33785924f728d55cfef529617d1bf783ddf5a Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 26 May 2018 04:16:44 +0200 Subject: [PATCH 18/73] OCA Transbot updated translations from Transifex --- product_contract/i18n/fr.po | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/product_contract/i18n/fr.po b/product_contract/i18n/fr.po index ba5a5b9c..7df1f518 100644 --- a/product_contract/i18n/fr.po +++ b/product_contract/i18n/fr.po @@ -5,13 +5,14 @@ # Translators: # leemannd , 2017 # David BEAL, 2018 +# Fabien Bourgeois , 2018 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-04-03 12:19+0000\n" -"PO-Revision-Date: 2018-04-03 12:19+0000\n" -"Last-Translator: David BEAL, 2018\n" +"POT-Creation-Date: 2018-05-19 02:01+0000\n" +"PO-Revision-Date: 2018-05-19 02:01+0000\n" +"Last-Translator: Fabien Bourgeois , 2018\n" "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -28,7 +29,7 @@ msgstr "Contrat" #: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id #: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id msgid "Contract Template" -msgstr "" +msgstr "Modèle de contrat" #. module: product_contract #: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract From 37ce7e9b22c5422a0b5e115146a1fa80476af720 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Sat, 21 Jul 2018 21:55:25 +0000 Subject: [PATCH 19/73] [UPD] Update product_contract.pot --- product_contract/i18n/de.po | 4 +- product_contract/i18n/es.po | 4 +- product_contract/i18n/fi.po | 4 +- product_contract/i18n/fr.po | 4 +- product_contract/i18n/hi_IN.po | 7 ++-- product_contract/i18n/hr.po | 7 ++-- product_contract/i18n/hr_HR.po | 10 +++-- product_contract/i18n/it.po | 4 +- product_contract/i18n/nl.po | 4 +- product_contract/i18n/nl_NL.po | 7 ++-- product_contract/i18n/product_contract.pot | 47 ++++++++++++++++++++++ product_contract/i18n/pt.po | 4 +- product_contract/i18n/pt_BR.po | 7 ++-- product_contract/i18n/ru.po | 8 ++-- product_contract/i18n/tr.po | 4 +- product_contract/i18n/tr_TR.po | 7 ++-- 16 files changed, 94 insertions(+), 38 deletions(-) create mode 100644 product_contract/i18n/product_contract.pot diff --git a/product_contract/i18n/de.po b/product_contract/i18n/de.po index 3b62b544..00697a55 100644 --- a/product_contract/i18n/de.po +++ b/product_contract/i18n/de.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # OCA Transbot , 2017 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2017-04-27 02:40+0000\n" "Last-Translator: OCA Transbot , 2017\n" "Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: product_contract diff --git a/product_contract/i18n/es.po b/product_contract/i18n/es.po index d712dd0e..1fd8a1a1 100644 --- a/product_contract/i18n/es.po +++ b/product_contract/i18n/es.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # OCA Transbot , 2017 # enjolras , 2018 @@ -13,10 +13,10 @@ msgstr "" "PO-Revision-Date: 2018-02-10 03:15+0000\n" "Last-Translator: enjolras , 2018\n" "Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: es\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: product_contract diff --git a/product_contract/i18n/fi.po b/product_contract/i18n/fi.po index 9daef38d..3467c265 100644 --- a/product_contract/i18n/fi.po +++ b/product_contract/i18n/fi.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # Jarmo Kortetjärvi , 2018 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2018-03-10 01:44+0000\n" "Last-Translator: Jarmo Kortetjärvi , 2018\n" "Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"Language: fi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: fi\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: product_contract diff --git a/product_contract/i18n/fr.po b/product_contract/i18n/fr.po index 7df1f518..59f399b3 100644 --- a/product_contract/i18n/fr.po +++ b/product_contract/i18n/fr.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # leemannd , 2017 # David BEAL, 2018 @@ -14,10 +14,10 @@ msgstr "" "PO-Revision-Date: 2018-05-19 02:01+0000\n" "Last-Translator: Fabien Bourgeois , 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" -"Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: product_contract diff --git a/product_contract/i18n/hi_IN.po b/product_contract/i18n/hi_IN.po index fe5f0e87..e55f00ea 100644 --- a/product_contract/i18n/hi_IN.po +++ b/product_contract/i18n/hi_IN.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # Ashish Deshmukh , 2017 msgid "" @@ -11,11 +11,12 @@ msgstr "" "POT-Creation-Date: 2017-08-17 01:05+0000\n" "PO-Revision-Date: 2017-08-17 01:05+0000\n" "Last-Translator: Ashish Deshmukh , 2017\n" -"Language-Team: Hindi (India) (https://www.transifex.com/oca/teams/23907/hi_IN/)\n" +"Language-Team: Hindi (India) (https://www.transifex.com/oca/teams/23907/" +"hi_IN/)\n" +"Language: hi_IN\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: hi_IN\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: product_contract diff --git a/product_contract/i18n/hr.po b/product_contract/i18n/hr.po index 2cfaafae..5ac93789 100644 --- a/product_contract/i18n/hr.po +++ b/product_contract/i18n/hr.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # Bole , 2017 msgid "" @@ -12,11 +12,12 @@ msgstr "" "PO-Revision-Date: 2018-02-10 03:15+0000\n" "Last-Translator: Bole , 2017\n" "Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: hr\n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" #. module: product_contract #: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id diff --git a/product_contract/i18n/hr_HR.po b/product_contract/i18n/hr_HR.po index 1248f3f2..2766a631 100644 --- a/product_contract/i18n/hr_HR.po +++ b/product_contract/i18n/hr_HR.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # OCA Transbot , 2017 # Bole , 2017 @@ -12,12 +12,14 @@ msgstr "" "POT-Creation-Date: 2017-06-17 01:39+0000\n" "PO-Revision-Date: 2017-06-17 01:39+0000\n" "Last-Translator: Bole , 2017\n" -"Language-Team: Croatian (Croatia) (https://www.transifex.com/oca/teams/23907/hr_HR/)\n" +"Language-Team: Croatian (Croatia) (https://www.transifex.com/oca/teams/23907/" +"hr_HR/)\n" +"Language: hr_HR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: hr_HR\n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" #. module: product_contract #: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id diff --git a/product_contract/i18n/it.po b/product_contract/i18n/it.po index 982bdf76..010897f6 100644 --- a/product_contract/i18n/it.po +++ b/product_contract/i18n/it.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # Lorenzo Battistini , 2017 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2017-04-27 02:40+0000\n" "Last-Translator: Lorenzo Battistini , 2017\n" "Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: it\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: product_contract diff --git a/product_contract/i18n/nl.po b/product_contract/i18n/nl.po index bdc4ca24..4c8db3eb 100644 --- a/product_contract/i18n/nl.po +++ b/product_contract/i18n/nl.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # Erwin van der Ploeg , 2017 # lfreeke , 2018 @@ -13,10 +13,10 @@ msgstr "" "PO-Revision-Date: 2018-01-06 03:17+0000\n" "Last-Translator: lfreeke , 2018\n" "Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" +"Language: nl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: nl\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: product_contract diff --git a/product_contract/i18n/nl_NL.po b/product_contract/i18n/nl_NL.po index 31a87e09..517781e3 100644 --- a/product_contract/i18n/nl_NL.po +++ b/product_contract/i18n/nl_NL.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # Peter Hageman , 2017 msgid "" @@ -11,11 +11,12 @@ msgstr "" "POT-Creation-Date: 2017-06-09 01:10+0000\n" "PO-Revision-Date: 2017-06-09 01:10+0000\n" "Last-Translator: Peter Hageman , 2017\n" -"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: nl_NL\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: product_contract diff --git a/product_contract/i18n/product_contract.pot b/product_contract/i18n/product_contract.pot new file mode 100644 index 00000000..154aed4d --- /dev/null +++ b/product_contract/i18n/product_contract.pot @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_contract +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.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: product_contract +#: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id +msgid "Contract" +msgstr "" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_contract_template_id +#: model:ir.model.fields,field_description:product_contract.field_product_template_contract_template_id +msgid "Contract Template" +msgstr "" + +#. module: product_contract +#: model:ir.model.fields,field_description:product_contract.field_product_product_is_contract +#: model:ir.model.fields,field_description:product_contract.field_product_template_is_contract +msgid "Is a contract" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: product_contract +#: model:ir.model,name:product_contract.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + diff --git a/product_contract/i18n/pt.po b/product_contract/i18n/pt.po index edcf09df..0ca84dea 100644 --- a/product_contract/i18n/pt.po +++ b/product_contract/i18n/pt.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # Pedro Castro Silva , 2017 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2017-07-15 01:24+0000\n" "Last-Translator: Pedro Castro Silva , 2017\n" "Language-Team: Portuguese (https://www.transifex.com/oca/teams/23907/pt/)\n" +"Language: pt\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: pt\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: product_contract diff --git a/product_contract/i18n/pt_BR.po b/product_contract/i18n/pt_BR.po index cbe23885..75fd5d80 100644 --- a/product_contract/i18n/pt_BR.po +++ b/product_contract/i18n/pt_BR.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # OCA Transbot , 2017 # falexandresilva , 2017 @@ -12,11 +12,12 @@ msgstr "" "POT-Creation-Date: 2017-06-13 02:40+0000\n" "PO-Revision-Date: 2017-06-13 02:40+0000\n" "Last-Translator: falexandresilva , 2017\n" -"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: product_contract diff --git a/product_contract/i18n/ru.po b/product_contract/i18n/ru.po index f78f50ad..bc7bdcbb 100644 --- a/product_contract/i18n/ru.po +++ b/product_contract/i18n/ru.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # nek, 2018 msgid "" @@ -12,11 +12,13 @@ msgstr "" "PO-Revision-Date: 2018-03-17 03:26+0000\n" "Last-Translator: nek, 2018\n" "Language-Team: Russian (https://www.transifex.com/oca/teams/23907/ru/)\n" +"Language: ru\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: ru\n" -"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" +"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n" +"%100>=11 && n%100<=14)? 2 : 3);\n" #. module: product_contract #: model:ir.model.fields,field_description:product_contract.field_sale_order_line_contract_id diff --git a/product_contract/i18n/tr.po b/product_contract/i18n/tr.po index f5e12fea..03f07329 100644 --- a/product_contract/i18n/tr.po +++ b/product_contract/i18n/tr.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # Ediz Duman , 2017 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2018-04-21 01:48+0000\n" "Last-Translator: Ediz Duman , 2017\n" "Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"Language: tr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: tr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: product_contract diff --git a/product_contract/i18n/tr_TR.po b/product_contract/i18n/tr_TR.po index 5bcb2f7e..7c93e6e4 100644 --- a/product_contract/i18n/tr_TR.po +++ b/product_contract/i18n/tr_TR.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * product_contract -# +# # Translators: # Ediz Duman , 2017 msgid "" @@ -11,11 +11,12 @@ msgstr "" "POT-Creation-Date: 2017-04-27 02:40+0000\n" "PO-Revision-Date: 2017-04-27 02:40+0000\n" "Last-Translator: Ediz Duman , 2017\n" -"Language-Team: Turkish (Turkey) (https://www.transifex.com/oca/teams/23907/tr_TR/)\n" +"Language-Team: Turkish (Turkey) (https://www.transifex.com/oca/teams/23907/" +"tr_TR/)\n" +"Language: tr_TR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: tr_TR\n" "Plural-Forms: nplurals=1; plural=0;\n" #. module: product_contract From ad375f4fa56f7cb4cf1a2e14320bb81535a89e70 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Wed, 31 Oct 2018 15:38:10 +0100 Subject: [PATCH 20/73] [HACK] Get PR 207, 203 beofre tavis build this commit must be reverted --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 184d6954..124c52df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,9 +21,6 @@ env: - TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1" install: -# FIXME: - - git clone --branch 12.0-recurrence-mechanism-on-contract-line https://github.com/sbejaoui/contract.git PR207 - - rm -rf contract && cp -ar PR207/contract . - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} - travis_install_nightly From 034c832f37e5866e1d77947625ac79ee16650482 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Wed, 31 Oct 2018 16:21:51 +0100 Subject: [PATCH 21/73] [MIG] - Product Contract Migration to 12.0 --- product_contract/__manifest__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py index e1d4d8ac..b5b5cac5 100644 --- a/product_contract/__manifest__.py +++ b/product_contract/__manifest__.py @@ -1,13 +1,15 @@ # -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. +# Copyright 2018 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Product Contract', - 'version': '10.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "LasLabs, " + "ACSONE SA/NV, " "Odoo Community Association (OCA)", 'website': 'https://laslabs.com', 'depends': [ From 93440ccbce4004b5c7458be62772bd9aae2c9594 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Wed, 31 Oct 2018 16:23:34 +0100 Subject: [PATCH 22/73] [IMP] - Product with is_contract can be only of type service --- product_contract/models/product_template.py | 15 ++++++-- product_contract/tests/__init__.py | 2 +- product_contract/tests/test_product.py | 34 +++++++++++++++++++ .../tests/test_product_template.py | 31 ----------------- product_contract/tests/test_sale_order.py | 2 -- 5 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 product_contract/tests/test_product.py delete mode 100644 product_contract/tests/test_product_template.py diff --git a/product_contract/models/product_template.py b/product_contract/models/product_template.py index fd7e00d4..1016c60c 100644 --- a/product_contract/models/product_template.py +++ b/product_contract/models/product_template.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. +# Copyright 2018 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, fields, models +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError class ProductTemplate(models.Model): @@ -10,8 +12,7 @@ class ProductTemplate(models.Model): is_contract = fields.Boolean('Is a contract') contract_template_id = fields.Many2one( - comodel_name='account.analytic.contract', - string='Contract Template', + comodel_name='account.analytic.contract', string='Contract Template' ) @api.onchange('is_contract') @@ -21,3 +22,11 @@ class ProductTemplate(models.Model): """ if not self.is_contract: self.contract_template_id = False + + @api.constrains('is_contract', 'type') + def _check_contract_product_type(self): + """ + Contract product should be service type + """ + if self.is_contract and self.type != 'service': + raise ValidationError(_("Contract product should be service type")) diff --git a/product_contract/tests/__init__.py b/product_contract/tests/__init__.py index e5fbe249..b4af49c0 100644 --- a/product_contract/tests/__init__.py +++ b/product_contract/tests/__init__.py @@ -2,5 +2,5 @@ # Copyright 2017 LasLabs Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import test_product_template +from . import test_product from . import test_sale_order diff --git a/product_contract/tests/test_product.py b/product_contract/tests/test_product.py new file mode 100644 index 00000000..3676dc05 --- /dev/null +++ b/product_contract/tests/test_product.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# Copyright 2018 ACSONE SA/NV. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import TransactionCase +from odoo.exceptions import ValidationError + + +class TestProductTemplate(TransactionCase): + def setUp(self): + super(TestProductTemplate, self).setUp() + self.service_product = self.env.ref('product.product_product_1') + self.consu_product = self.env.ref('product.product_product_5') + self.contract = self.env['account.analytic.contract'].create( + {'name': 'Test'} + ) + + def test_change_is_contract(self): + """ It should verify that the contract_template_id is removed + when is_contract is False """ + self.service_product.is_contract = True + self.service_product.contract_template_id = self.contract.id + self.service_product.is_contract = False + self.service_product.product_tmpl_id._change_is_contract() + self.assertEquals(len(self.service_product.contract_template_id), 0) + + def test_check_contract_product_type(self): + """ + It should raise ValidationError on change of is_contract to True + for consu product + """ + with self.assertRaises(ValidationError): + self.consu_product.is_contract = True diff --git a/product_contract/tests/test_product_template.py b/product_contract/tests/test_product_template.py deleted file mode 100644 index 2938cc7f..00000000 --- a/product_contract/tests/test_product_template.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 LasLabs Inc. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo.tests.common import TransactionCase - - -class TestProductTemplate(TransactionCase): - - def setUp(self): - super(TestProductTemplate, self).setUp() - self.product = self.env.ref( - 'product.product_product_4_product_template' - ) - self.contract = self.env['account.analytic.contract'].create({ - 'name': 'Test', - 'recurring_rule_type': 'yearly', - 'recurring_interval': 12345, - }) - - def test_change_is_contract(self): - """ It should verify that the contract_template_id is removed - when is_contract is False """ - self.product.is_contract = True - self.product.contract_template_id = self.contract.id - self.product.is_contract = False - self.product._change_is_contract() - self.assertEquals( - len(self.product.contract_template_id), - 0 - ) diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index 61f33858..f8a90e34 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -14,8 +14,6 @@ class TestSaleOrder(TransactionCase): self.sale = self.env.ref('sale.sale_order_2') self.contract = self.env['account.analytic.contract'].create({ 'name': 'Test', - 'recurring_rule_type': 'yearly', - 'recurring_interval': 12345, }) self.product.product_tmpl_id.is_contract = True self.product.product_tmpl_id.contract_template_id = self.contract.id From 32b2e176609c46efa94a9a86f72968e68c0d6e08 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Wed, 31 Oct 2018 17:07:47 +0100 Subject: [PATCH 23/73] [IMP] - Change dependencies to contract_sale --- product_contract/__manifest__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py index b5b5cac5..970265ff 100644 --- a/product_contract/__manifest__.py +++ b/product_contract/__manifest__.py @@ -13,9 +13,8 @@ "Odoo Community Association (OCA)", 'website': 'https://laslabs.com', 'depends': [ - 'contract', 'product', - 'sale', + 'contract_sale', ], 'data': [ 'views/product_template_view.xml', From 280eca9819915562a2105f0cf56d83205b3e1981 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Wed, 31 Oct 2018 18:10:08 +0100 Subject: [PATCH 24/73] [IMP] - Add recurrence fields to product template and sale order line --- product_contract/__manifest__.py | 3 +- product_contract/models/product_template.py | 24 +++++++ product_contract/models/sale_order.py | 12 +++- product_contract/models/sale_order_line.py | 49 ++++++++++++++- product_contract/tests/__init__.py | 2 + product_contract/tests/test_sale_order.py | 2 + .../tests/test_sale_order_line.py | 37 +++++++++++ product_contract/views/product_template.xml | 44 +++++++++++++ .../views/product_template_view.xml | 29 --------- product_contract/views/sale_order.xml | 63 +++++++++++++++++++ 10 files changed, 231 insertions(+), 34 deletions(-) create mode 100644 product_contract/tests/test_sale_order_line.py create mode 100644 product_contract/views/product_template.xml delete mode 100644 product_contract/views/product_template_view.xml create mode 100644 product_contract/views/sale_order.xml diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py index 970265ff..f369b825 100644 --- a/product_contract/__manifest__.py +++ b/product_contract/__manifest__.py @@ -17,7 +17,8 @@ 'contract_sale', ], 'data': [ - 'views/product_template_view.xml', + 'views/product_template.xml', + 'views/sale_order.xml', ], 'installable': True, 'application': False, diff --git a/product_contract/models/product_template.py b/product_contract/models/product_template.py index 1016c60c..1d256201 100644 --- a/product_contract/models/product_template.py +++ b/product_contract/models/product_template.py @@ -15,6 +15,30 @@ class ProductTemplate(models.Model): comodel_name='account.analytic.contract', string='Contract Template' ) + recurring_rule_type = fields.Selection( + [ + ('daily', 'Day(s)'), + ('weekly', 'Week(s)'), + ('monthly', 'Month(s)'), + ('monthlylastday', 'Month(s) last day'), + ('yearly', 'Year(s)'), + ], + default='monthly', + string='Recurrence', + help="Specify Interval for automatic invoice generation.", + ) + recurring_invoicing_type = fields.Selection( + [('pre-paid', 'Pre-paid'), ('post-paid', 'Post-paid')], + default='pre-paid', + string='Invoicing type', + help="Specify if process date is 'from' or 'to' invoicing date", + ) + recurring_interval = fields.Integer( + default=1, + string='Repeat Every', + help="Repeat every (Days/Week/Month/Year)", + ) + @api.onchange('is_contract') def _change_is_contract(self): """ Clear the relation to contract_template_id when downgrading diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py index 45f2eec7..443eaaff 100644 --- a/product_contract/models/sale_order.py +++ b/product_contract/models/sale_order.py @@ -2,12 +2,22 @@ # Copyright 2017 LasLabs Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, models +from odoo import fields, api, models class SaleOrder(models.Model): _inherit = 'sale.order' + is_contract = fields.Boolean( + string='Is a contract', compute="_compute_is_contract" + ) + + @api.depends('order_line') + def _compute_is_contract(self): + self.is_contract = any( + self.order_line.mapped('is_contract') + ) + @api.multi def action_confirm(self): """ If we have a contract in the order, set it up """ diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index c76c1059..23da9c1c 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -1,14 +1,57 @@ # -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. +# Copyright 2017 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models +from odoo import api, fields, models class SaleOrderLine(models.Model): _inherit = 'sale.order.line' + is_contract = fields.Boolean( + string='Is a contract', related="product_id.is_contract" + ) contract_id = fields.Many2one( - comodel_name='account.analytic.account', - string='Contract' + comodel_name='account.analytic.account', string='Contract' + ) + recurring_rule_type = fields.Selection( + [ + ('daily', 'Day(s)'), + ('weekly', 'Week(s)'), + ('monthly', 'Month(s)'), + ('monthlylastday', 'Month(s) last day'), + ('yearly', 'Year(s)'), + ], + default='monthly', + string='Recurrence', + help="Specify Interval for automatic invoice generation.", + copy=False, + ) + recurring_invoicing_type = fields.Selection( + [('pre-paid', 'Pre-paid'), ('post-paid', 'Post-paid')], + default='pre-paid', + string='Invoicing type', + help="Specify if process date is 'from' or 'to' invoicing date", + copy=False, ) + recurring_interval = fields.Integer( + default=1, + string='Repeat Every', + help="Repeat every (Days/Week/Month/Year)", + copy=False, + ) + date_start = fields.Date(string='Date Start', default=fields.Date.today()) + date_end = fields.Date(string='Date End', index=True) + recurring_next_date = fields.Date( + default=fields.Date.today(), copy=False, string='Date of Next Invoice' + ) + + @api.onchange('product_id') + def onchange_product(self): + if self.product_id.is_contract: + self.recurring_rule_type = self.product_id.recurring_rule_type + self.recurring_invoicing_type = ( + self.product_id.recurring_invoicing_type + ) + self.recurring_interval = self.product_id.recurring_interval diff --git a/product_contract/tests/__init__.py b/product_contract/tests/__init__.py index b4af49c0..4766d5ea 100644 --- a/product_contract/tests/__init__.py +++ b/product_contract/tests/__init__.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. +# Copyright 2018 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import test_product from . import test_sale_order +from . import test_sale_order_line diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index f8a90e34..e8f66602 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -27,6 +27,8 @@ class TestSaleOrder(TransactionCase): def test_action_done(self): """ It should create a contract when the sale for a contract is set to done for the first time """ + + self.assertTrue(self.sale.is_contract) self.env['account.analytic.account']._patch_method( 'create', MagicMock() ) diff --git a/product_contract/tests/test_sale_order_line.py b/product_contract/tests/test_sale_order_line.py new file mode 100644 index 00000000..1f109059 --- /dev/null +++ b/product_contract/tests/test_sale_order_line.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 ACSONE SA/NV. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from mock import MagicMock +from odoo.tests.common import TransactionCase + + +class TestSaleOrder(TransactionCase): + + def setUp(self): + super(TestSaleOrder, self).setUp() + self.product = self.env.ref('product.product_product_1') + self.sale = self.env.ref('sale.sale_order_2') + self.contract = self.env['account.analytic.contract'].create({ + 'name': 'Test', + }) + self.product.product_tmpl_id.is_contract = True + self.sale_order_line = self.sale.order_line.filtered( + lambda l: l.product_id == self.product + ) + + def test_onchange_product(self): + """ It should get recurrence invoicing info to the sale line from + its product """ + self.assertEqual( + self.sale_order_line.recurring_rule_type, + self.product.recurring_rule_type + ) + self.assertEqual( + self.sale_order_line.recurring_interval, + self.product.recurring_interval + ) + self.assertEqual( + self.sale_order_line.recurring_invoicing_type, + self.product.recurring_invoicing_type + ) diff --git a/product_contract/views/product_template.xml b/product_contract/views/product_template.xml new file mode 100644 index 00000000..9eb3b38f --- /dev/null +++ b/product_contract/views/product_template.xml @@ -0,0 +1,44 @@ + + + + + + + + account.invoice.select.contract + product.template + + + +
+ +
+
+ + + + + +
+
+ +
diff --git a/product_contract/views/product_template_view.xml b/product_contract/views/product_template_view.xml deleted file mode 100644 index 46c2e05c..00000000 --- a/product_contract/views/product_template_view.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - account.invoice.select.contract - product.template - - - -
- -
-
- - - -
-
- -
diff --git a/product_contract/views/sale_order.xml b/product_contract/views/sale_order.xml new file mode 100644 index 00000000..f27c4025 --- /dev/null +++ b/product_contract/views/sale_order.xml @@ -0,0 +1,63 @@ + + + + + + + + sale.order.form (in product_contract) + sale.order + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 16f480c04c5092c51759a9d14ed1937a28a7a8ff Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Fri, 2 Nov 2018 14:34:05 +0100 Subject: [PATCH 25/73] [IMP] - Create contract on sale order confirmation - On Sale Order confirmation, a contract is created for each contract template used on sale order lines - A not finished contract can be mentioned on sale order line - A sale order line linked to a contract will update it and don't create a new one if it had the same template --- product_contract/models/sale_order.py | 65 ++++++++--- product_contract/models/sale_order_line.py | 62 ++++++++++- product_contract/tests/__init__.py | 1 - product_contract/tests/test_sale_order.py | 102 +++++++++++++----- .../tests/test_sale_order_line.py | 37 ------- product_contract/views/sale_order.xml | 18 ++++ 6 files changed, 205 insertions(+), 80 deletions(-) delete mode 100644 product_contract/tests/test_sale_order_line.py diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py index 443eaaff..4b356f32 100644 --- a/product_contract/models/sale_order.py +++ b/product_contract/models/sale_order.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. +# Copyright 2018 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import fields, api, models @@ -9,29 +10,61 @@ class SaleOrder(models.Model): _inherit = 'sale.order' is_contract = fields.Boolean( - string='Is a contract', compute="_compute_is_contract" + string='Is a contract', compute='_compute_is_contract' ) + contract_count = fields.Integer(compute='_compute_contract_count') @api.depends('order_line') def _compute_is_contract(self): - self.is_contract = any( - self.order_line.mapped('is_contract') - ) + self.is_contract = any(self.order_line.mapped('is_contract')) @api.multi def action_confirm(self): """ If we have a contract in the order, set it up """ - for rec in self: - order_lines = self.mapped('order_line').filtered( - lambda r: r.product_id.is_contract + contract_env = self.env['account.analytic.account'] + for rec in self.filtered('is_contract'): + line_to_create_contract = rec.order_line.filtered( + lambda r: not r.contract_id ) - for line in order_lines: - contract_tmpl = line.product_id.contract_template_id - contract = self.env['account.analytic.account'].create({ - 'name': '%s Contract' % rec.name, - 'partner_id': rec.partner_id.id, - 'contract_template_id': contract_tmpl.id, - }) - line.contract_id = contract.id - contract.recurring_create_invoice() + for contract_template in line_to_create_contract.mapped( + 'product_id.contract_template_id' + ): + order_lines = line_to_create_contract.filtered( + lambda r: r.product_id.contract_template_id + == contract_template + ) + contract = contract_env.create( + { + 'name': '{template_name}: {sale_name}'.format( + template_name=contract_template.name, + sale_name=rec.name, + ), + 'partner_id': rec.partner_id.id, + 'recurring_invoices': True, + 'contract_template_id': contract_template.id, + } + ) + contract._onchange_contract_template_id() + order_lines.create_contract_line(contract) + order_lines.write({'contract_id': contract.id}) + line_to_update_contract = rec.order_line.filtered('contract_id') + for line in line_to_update_contract: + line.create_contract_line(line.contract_id) return super(SaleOrder, self).action_confirm() + + @api.multi + @api.depends("order_line") + def _compute_contract_count(self): + for rec in self: + rec.contract_count = len(rec.order_line.mapped('contract_id')) + + @api.multi + def action_show_contracts(self): + self.ensure_one() + action = self.env.ref( + "contract.action_account_analytic_sale_overdue_all" + ).read()[0] + action["domain"] = [ + ("id", "in", self.order_line.mapped('contract_id').ids) + ] + return action diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 23da9c1c..b275e67e 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -3,7 +3,8 @@ # Copyright 2017 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, fields, models +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError class SaleOrderLine(models.Model): @@ -13,7 +14,13 @@ class SaleOrderLine(models.Model): string='Is a contract', related="product_id.is_contract" ) contract_id = fields.Many2one( - comodel_name='account.analytic.account', string='Contract' + comodel_name='account.analytic.account', string='Contract', copy=False + ) + contract_template_id = fields.Many2one( + comodel_name='account.analytic.contract', + string='Contract Template', + related='product_id.product_tmpl_id.contract_template_id', + readonly=True ) recurring_rule_type = fields.Selection( [ @@ -55,3 +62,54 @@ class SaleOrderLine(models.Model): self.product_id.recurring_invoicing_type ) self.recurring_interval = self.product_id.recurring_interval + + @api.multi + def _prepare_contract_line_values(self, contract): + self.ensure_one() + return { + 'sequence': self.sequence, + 'product_id': self.product_id.id, + 'name': self.name, + 'quantity': self.product_uom_qty, + 'uom_id': self.product_uom.id, + 'price_unit': self.price_unit, + 'discount': self.discount, + 'recurring_next_date': self.recurring_next_date + or fields.Date.today(), + 'date_end': self.date_end, + 'date_start': self.date_start or fields.Date.today(), + 'recurring_interval': self.recurring_interval, + 'recurring_invoicing_type': self.recurring_invoicing_type, + 'recurring_rule_type': self.recurring_rule_type, + 'contract_id': contract.id, + } + + @api.multi + def create_contract_line(self, contract): + contract_line = self.env['account.analytic.invoice.line'] + for rec in self: + contract_line.create(rec._prepare_contract_line_values(contract)) + + @api.constrains('contract_id') + def _check_contract_sale_partner(self): + for rec in self: + if rec.contract_id: + if rec.order_id.partner_id != rec.contract_id.partner_id: + raise ValidationError( + _( + "Sale Order and contract should be " + "linked to the same partner" + ) + ) + + @api.constrains('product_id', 'contract_id') + def _check_contract_sale_contract_template(self): + for rec in self: + if rec.contract_id: + if ( + rec.contract_template_id + != rec.contract_id.contract_template_id + ): + raise ValidationError( + _("Contract product has different contract template") + ) diff --git a/product_contract/tests/__init__.py b/product_contract/tests/__init__.py index 4766d5ea..9d85581f 100644 --- a/product_contract/tests/__init__.py +++ b/product_contract/tests/__init__.py @@ -5,4 +5,3 @@ from . import test_product from . import test_sale_order -from . import test_sale_order_line diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index e8f66602..36e690b1 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -2,39 +2,93 @@ # Copyright 2017 LasLabs Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from mock import MagicMock from odoo.tests.common import TransactionCase +from odoo.exceptions import ValidationError class TestSaleOrder(TransactionCase): - def setUp(self): super(TestSaleOrder, self).setUp() - self.product = self.env.ref('product.product_product_1') + self.product1 = self.env.ref('product.product_product_1') + self.product2 = self.env.ref('product.product_product_2') self.sale = self.env.ref('sale.sale_order_2') - self.contract = self.env['account.analytic.contract'].create({ - 'name': 'Test', - }) - self.product.product_tmpl_id.is_contract = True - self.product.product_tmpl_id.contract_template_id = self.contract.id - - def tearDown(self): - self.env['account.analytic.account']._revert_method( - 'create', + self.contract_template1 = self.env['account.analytic.contract'].create( + {'name': 'Template 1'} + ) + self.contract_template2 = self.env['account.analytic.contract'].create( + {'name': 'Template 2'} + ) + self.product1.write( + { + 'is_contract': True, + 'contract_template_id': self.contract_template1.id, + } + ) + self.product2.write( + { + 'is_contract': True, + 'contract_template_id': self.contract_template2.id, + } + ) + self.order_line1 = self.sale.order_line.filtered( + lambda l: l.product_id == self.product1 ) - super(TestSaleOrder, self).tearDown() - - def test_action_done(self): - """ It should create a contract when the sale for a contract is set - to done for the first time """ + def test_compute_is_contract(self): + """Sale Order should have is_contract true if one of its lines is + contract""" self.assertTrue(self.sale.is_contract) - self.env['account.analytic.account']._patch_method( - 'create', MagicMock() + + def test_action_confirm(self): + """ It should create a contract for each contract template used in + order_line """ + self.sale.action_confirm() + contracts = self.sale.order_line.mapped('contract_id') + self.assertEqual(len(contracts), 2) + self.assertEqual( + self.order_line1.contract_id.contract_template_id, + self.contract_template1, ) + + def test_sale_contract_count(self): + """It should count contracts as many different contract template used + in order_line""" self.sale.action_confirm() - self.env['account.analytic.account'].create.assert_called_once_with({ - 'name': '%s Contract' % self.sale.name, - 'partner_id': self.sale.partner_id.id, - 'contract_template_id': self.contract.id, - }) + self.assertEqual(self.sale.contract_count, 2) + + def test_onchange_product(self): + """ It should get recurrence invoicing info to the sale line from + its product """ + self.assertEqual( + self.order_line1.recurring_rule_type, + self.product1.recurring_rule_type, + ) + self.assertEqual( + self.order_line1.recurring_interval, + self.product1.recurring_interval, + ) + self.assertEqual( + self.order_line1.recurring_invoicing_type, + self.product1.recurring_invoicing_type, + ) + + def test_check_contract_sale_partner(self): + contract2 = self.env['account.analytic.account'].create( + { + 'name': 'Contract', + 'contract_template_id': self.contract_template2.id, + 'partner_id': self.sale.partner_id.id, + } + ) + with self.assertRaises(ValidationError): + self.order_line1.contract_id = contract2 + + def test_check_contract_sale_contract_template(self): + contract1 = self.env['account.analytic.account'].create( + { + 'name': 'Contract', + 'contract_template_id': self.contract_template1.id, + } + ) + with self.assertRaises(ValidationError): + self.order_line1.contract_id = contract1 diff --git a/product_contract/tests/test_sale_order_line.py b/product_contract/tests/test_sale_order_line.py deleted file mode 100644 index 1f109059..00000000 --- a/product_contract/tests/test_sale_order_line.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 ACSONE SA/NV. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from mock import MagicMock -from odoo.tests.common import TransactionCase - - -class TestSaleOrder(TransactionCase): - - def setUp(self): - super(TestSaleOrder, self).setUp() - self.product = self.env.ref('product.product_product_1') - self.sale = self.env.ref('sale.sale_order_2') - self.contract = self.env['account.analytic.contract'].create({ - 'name': 'Test', - }) - self.product.product_tmpl_id.is_contract = True - self.sale_order_line = self.sale.order_line.filtered( - lambda l: l.product_id == self.product - ) - - def test_onchange_product(self): - """ It should get recurrence invoicing info to the sale line from - its product """ - self.assertEqual( - self.sale_order_line.recurring_rule_type, - self.product.recurring_rule_type - ) - self.assertEqual( - self.sale_order_line.recurring_interval, - self.product.recurring_interval - ) - self.assertEqual( - self.sale_order_line.recurring_invoicing_type, - self.product.recurring_invoicing_type - ) diff --git a/product_contract/views/sale_order.xml b/product_contract/views/sale_order.xml index f27c4025..70397c32 100644 --- a/product_contract/views/sale_order.xml +++ b/product_contract/views/sale_order.xml @@ -12,9 +12,27 @@ sale.order + + + + + + + Date: Fri, 2 Nov 2018 16:26:51 +0100 Subject: [PATCH 26/73] [IMP] - Link contract line to sale order line --- product_contract/models/__init__.py | 1 + product_contract/models/contract_line.py | 16 ++++++++++++++++ product_contract/models/sale_order.py | 5 ++++- product_contract/models/sale_order_line.py | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 product_contract/models/contract_line.py diff --git a/product_contract/models/__init__.py b/product_contract/models/__init__.py index 388717d2..a275fa21 100644 --- a/product_contract/models/__init__.py +++ b/product_contract/models/__init__.py @@ -2,6 +2,7 @@ # Copyright 2017 LasLabs Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import contract_line from . import product_template from . import sale_order from . import sale_order_line diff --git a/product_contract/models/contract_line.py b/product_contract/models/contract_line.py new file mode 100644 index 00000000..998da169 --- /dev/null +++ b/product_contract/models/contract_line.py @@ -0,0 +1,16 @@ +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import api, fields, models, _ + + +class AccountAnalyticInvoiceLine(models.Model): + _inherit = 'account.analytic.invoice.line' + + sale_order_line_id = fields.Many2one( + comodel_name="sale.order.line", + string="Sale Order Line", + required=False, + copy=False, + ) diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py index 4b356f32..a2e8487d 100644 --- a/product_contract/models/sale_order.py +++ b/product_contract/models/sale_order.py @@ -64,7 +64,10 @@ class SaleOrder(models.Model): action = self.env.ref( "contract.action_account_analytic_sale_overdue_all" ).read()[0] + contracts = self.env['account.analytic.invoice.line'].search([ + ('sale_order_line', 'in', self.order_line.ids) + ]).mapped('contract_id') action["domain"] = [ - ("id", "in", self.order_line.mapped('contract_id').ids) + ("id", "in", contracts.ids) ] return action diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index b275e67e..1c13fdad 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -82,6 +82,7 @@ class SaleOrderLine(models.Model): 'recurring_invoicing_type': self.recurring_invoicing_type, 'recurring_rule_type': self.recurring_rule_type, 'contract_id': contract.id, + 'sale_order_line_id': self.id, } @api.multi From 3c882b676477634a02da60ca8cb573ad6730a3c8 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Fri, 2 Nov 2018 17:13:36 +0100 Subject: [PATCH 27/73] [FIX] - Remove recurring_next_date from sale order line recurring_next_date should be computed by contract line to get default value --- product_contract/models/contract_line.py | 2 +- product_contract/models/sale_order.py | 14 +++++++------- product_contract/models/sale_order_line.py | 13 ++++++------- product_contract/views/sale_order.xml | 3 --- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/product_contract/models/contract_line.py b/product_contract/models/contract_line.py index 998da169..101e544c 100644 --- a/product_contract/models/contract_line.py +++ b/product_contract/models/contract_line.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models, _ +from odoo import fields, models class AccountAnalyticInvoiceLine(models.Model): diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py index a2e8487d..e53fbb91 100644 --- a/product_contract/models/sale_order.py +++ b/product_contract/models/sale_order.py @@ -26,6 +26,7 @@ class SaleOrder(models.Model): line_to_create_contract = rec.order_line.filtered( lambda r: not r.contract_id ) + line_to_update_contract = rec.order_line.filtered('contract_id') for contract_template in line_to_create_contract.mapped( 'product_id.contract_template_id' ): @@ -47,7 +48,6 @@ class SaleOrder(models.Model): contract._onchange_contract_template_id() order_lines.create_contract_line(contract) order_lines.write({'contract_id': contract.id}) - line_to_update_contract = rec.order_line.filtered('contract_id') for line in line_to_update_contract: line.create_contract_line(line.contract_id) return super(SaleOrder, self).action_confirm() @@ -64,10 +64,10 @@ class SaleOrder(models.Model): action = self.env.ref( "contract.action_account_analytic_sale_overdue_all" ).read()[0] - contracts = self.env['account.analytic.invoice.line'].search([ - ('sale_order_line', 'in', self.order_line.ids) - ]).mapped('contract_id') - action["domain"] = [ - ("id", "in", contracts.ids) - ] + contracts = ( + self.env['account.analytic.invoice.line'] + .search([('sale_order_line_id', 'in', self.order_line.ids)]) + .mapped('contract_id') + ) + action["domain"] = [("id", "in", contracts.ids)] return action diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 1c13fdad..70e868c4 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -20,7 +20,7 @@ class SaleOrderLine(models.Model): comodel_name='account.analytic.contract', string='Contract Template', related='product_id.product_tmpl_id.contract_template_id', - readonly=True + readonly=True, ) recurring_rule_type = fields.Selection( [ @@ -50,9 +50,6 @@ class SaleOrderLine(models.Model): ) date_start = fields.Date(string='Date Start', default=fields.Date.today()) date_end = fields.Date(string='Date End', index=True) - recurring_next_date = fields.Date( - default=fields.Date.today(), copy=False, string='Date of Next Invoice' - ) @api.onchange('product_id') def onchange_product(self): @@ -74,8 +71,6 @@ class SaleOrderLine(models.Model): 'uom_id': self.product_uom.id, 'price_unit': self.price_unit, 'discount': self.discount, - 'recurring_next_date': self.recurring_next_date - or fields.Date.today(), 'date_end': self.date_end, 'date_start': self.date_start or fields.Date.today(), 'recurring_interval': self.recurring_interval, @@ -87,9 +82,13 @@ class SaleOrderLine(models.Model): @api.multi def create_contract_line(self, contract): + contract_line_env = self.env['account.analytic.invoice.line'] contract_line = self.env['account.analytic.invoice.line'] for rec in self: - contract_line.create(rec._prepare_contract_line_values(contract)) + contract_line |= contract_line_env.create( + rec._prepare_contract_line_values(contract) + ) + contract_line._onchange_date_start() @api.constrains('contract_id') def _check_contract_sale_partner(self): diff --git a/product_contract/views/sale_order.xml b/product_contract/views/sale_order.xml index 70397c32..4443c39d 100644 --- a/product_contract/views/sale_order.xml +++ b/product_contract/views/sale_order.xml @@ -56,7 +56,6 @@ - @@ -68,8 +67,6 @@ attrs="{'column_invisible': [('parent.is_contract', '=', False)]}"/> - From 147c40acaa37600d6e58998607fca89f3d716162 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 5 Nov 2018 11:40:58 +0100 Subject: [PATCH 28/73] [IMP] - Contract product are ignored on invoicing process - Sale order line for contract product pass to nothing to invoice on order confirmation - Contract Invoices are linked to sale order line --- product_contract/models/contract_line.py | 11 +++++- product_contract/models/sale_order.py | 6 ++- product_contract/models/sale_order_line.py | 11 ++++++ product_contract/tests/test_sale_order.py | 43 ++++++++++++++++++++++ 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/product_contract/models/contract_line.py b/product_contract/models/contract_line.py index 101e544c..23fcb306 100644 --- a/product_contract/models/contract_line.py +++ b/product_contract/models/contract_line.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import fields, models +from odoo import api, fields, models class AccountAnalyticInvoiceLine(models.Model): @@ -14,3 +14,12 @@ class AccountAnalyticInvoiceLine(models.Model): required=False, copy=False, ) + + @api.multi + def _prepare_invoice_line(self, invoice_id): + res = super(AccountAnalyticInvoiceLine, self)._prepare_invoice_line( + invoice_id + ) + if self.sale_order_line_id: + res['sale_line_ids'] = [(6, 0, [self.sale_order_line_id.id])] + return res diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py index e53fbb91..3a38c116 100644 --- a/product_contract/models/sale_order.py +++ b/product_contract/models/sale_order.py @@ -24,9 +24,11 @@ class SaleOrder(models.Model): contract_env = self.env['account.analytic.account'] for rec in self.filtered('is_contract'): line_to_create_contract = rec.order_line.filtered( - lambda r: not r.contract_id + lambda r: not r.contract_id and r.product_id.is_contract + ) + line_to_update_contract = rec.order_line.filtered( + lambda r: r.contract_id and r.product_id.is_contract ) - line_to_update_contract = rec.order_line.filtered('contract_id') for contract_template in line_to_create_contract.mapped( 'product_id.contract_template_id' ): diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 70e868c4..6b0dc1f8 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -113,3 +113,14 @@ class SaleOrderLine(models.Model): raise ValidationError( _("Contract product has different contract template") ) + + def _compute_invoice_status(self): + super(SaleOrderLine, self)._compute_invoice_status() + for line in self.filtered('contract_id'): + line.invoice_status = 'no' + + @api.multi + def invoice_line_create(self, invoice_id, qty): + return super( + SaleOrderLine, self.filtered(lambda l: not l.contract_id) + ).invoice_line_create(invoice_id, qty) diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index 36e690b1..b3b505e8 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -73,6 +73,8 @@ class TestSaleOrder(TransactionCase): ) def test_check_contract_sale_partner(self): + """Can't link order line to a partner contract different then the + order one""" contract2 = self.env['account.analytic.account'].create( { 'name': 'Contract', @@ -84,6 +86,8 @@ class TestSaleOrder(TransactionCase): self.order_line1.contract_id = contract2 def test_check_contract_sale_contract_template(self): + """Can't link order line to a contract with different contract + template then the product one""" contract1 = self.env['account.analytic.account'].create( { 'name': 'Contract', @@ -92,3 +96,42 @@ class TestSaleOrder(TransactionCase): ) with self.assertRaises(ValidationError): self.order_line1.contract_id = contract1 + + def test_no_contract_proudct(self): + """it should create contract for only product contract""" + self.product1.is_contract = False + self.sale.action_confirm() + self.assertFalse(self.order_line1.contract_id) + + def test_sale_order_line_invoice_status(self): + """Sale order line for contract product should have nothing to + invoice as status""" + self.sale.action_confirm() + self.assertEqual(self.order_line1.invoice_status, 'no') + + def test_sale_order_invoice_status(self): + """Sale order with only contract product should have nothing to + invoice status directtly""" + self.sale.order_line.filtered( + lambda line: not line.product_id.is_contract + ).unlink() + self.sale.action_confirm() + self.assertEqual(self.sale.invoice_status, 'no') + + def test_sale_order_create_invoice(self): + """Should not invoice contract product on sale order create invoice""" + self.product2.is_contract = False + self.product2.invoice_policy = 'order' + self.sale.action_confirm() + self.sale.action_invoice_create() + self.assertEqual(len(self.sale.invoice_ids), 1) + invoice_line = self.sale.invoice_ids.invoice_line_ids.filtered( + lambda line: line.product_id.is_contract + ) + self.assertEqual(len(invoice_line), 0) + + def test_link_contract_invoice_to_sale_order(self): + """It should link contract invoice to sale order""" + self.sale.action_confirm() + invoice = self.order_line1.contract_id.recurring_create_invoice() + self.assertTrue(invoice in self.sale.invoice_ids) From f3a261d5147ef1ae24cd84cdfb1bcc5c97ffef9b Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 5 Nov 2018 11:44:46 +0100 Subject: [PATCH 29/73] [FIX] - Default value for date_start applied on product change --- product_contract/models/sale_order_line.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 6b0dc1f8..b0d14ee2 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -48,7 +48,7 @@ class SaleOrderLine(models.Model): help="Repeat every (Days/Week/Month/Year)", copy=False, ) - date_start = fields.Date(string='Date Start', default=fields.Date.today()) + date_start = fields.Date(string='Date Start') date_end = fields.Date(string='Date End', index=True) @api.onchange('product_id') @@ -59,6 +59,7 @@ class SaleOrderLine(models.Model): self.product_id.recurring_invoicing_type ) self.recurring_interval = self.product_id.recurring_interval + self.date_start = fields.Date.today() @api.multi def _prepare_contract_line_values(self, contract): From 73c4b167c6cd8932de37e64f35846acdf3758b2d Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 5 Nov 2018 14:35:38 +0100 Subject: [PATCH 30/73] [ADD] - Add readme directory --- product_contract/readme/CONTRIBUTORS.rst | 2 ++ product_contract/readme/DESCRIPTION.rst | 5 +++++ product_contract/readme/USAGE.rst | 6 ++++++ 3 files changed, 13 insertions(+) create mode 100644 product_contract/readme/CONTRIBUTORS.rst create mode 100644 product_contract/readme/DESCRIPTION.rst create mode 100644 product_contract/readme/USAGE.rst diff --git a/product_contract/readme/CONTRIBUTORS.rst b/product_contract/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..2db29075 --- /dev/null +++ b/product_contract/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Ted Salmon +* Souheil Bejaoui diff --git a/product_contract/readme/DESCRIPTION.rst b/product_contract/readme/DESCRIPTION.rst new file mode 100644 index 00000000..e620eb27 --- /dev/null +++ b/product_contract/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module adds support for products to be linked to contract templates. + +A contract is created on ``sale.order`` confirmation for each different template used in sale order line where recurrence details are set too. + +Contract product are ignored on invoicing process and pass to nothing to invoice directly. diff --git a/product_contract/readme/USAGE.rst b/product_contract/readme/USAGE.rst new file mode 100644 index 00000000..e1380d0f --- /dev/null +++ b/product_contract/readme/USAGE.rst @@ -0,0 +1,6 @@ +To use this module, you need to: + +#. Go to Sales -> Products and select or create a product. +#. Check "Is a contract" and select the contract template related to the + product +#. Define default recurrence rules \ No newline at end of file From c4f189a1d20452b99ea167442c3f7f5040f39d88 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 5 Nov 2018 15:44:02 +0100 Subject: [PATCH 31/73] [ADD] setup.py --- setup/product_contract/odoo/addons/product_contract | 1 + setup/product_contract/setup.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 120000 setup/product_contract/odoo/addons/product_contract create mode 100644 setup/product_contract/setup.py diff --git a/setup/product_contract/odoo/addons/product_contract b/setup/product_contract/odoo/addons/product_contract new file mode 120000 index 00000000..8a36744f --- /dev/null +++ b/setup/product_contract/odoo/addons/product_contract @@ -0,0 +1 @@ +../../../../product_contract \ No newline at end of file diff --git a/setup/product_contract/setup.py b/setup/product_contract/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/product_contract/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From ffef4c1c25dc51929a331d22cba4db977fc1d86b Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 5 Nov 2018 16:04:53 +0100 Subject: [PATCH 32/73] [IMP] - Onchange contract product on contract contract and contract template --- product_contract/models/__init__.py | 1 + .../models/abstract_contract_line.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 product_contract/models/abstract_contract_line.py diff --git a/product_contract/models/__init__.py b/product_contract/models/__init__.py index a275fa21..4d43b3ea 100644 --- a/product_contract/models/__init__.py +++ b/product_contract/models/__init__.py @@ -2,6 +2,7 @@ # Copyright 2017 LasLabs Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import abstract_contract_line from . import contract_line from . import product_template from . import sale_order diff --git a/product_contract/models/abstract_contract_line.py b/product_contract/models/abstract_contract_line.py new file mode 100644 index 00000000..1bfe4c8c --- /dev/null +++ b/product_contract/models/abstract_contract_line.py @@ -0,0 +1,18 @@ +# Copyright 2018 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models, fields + + +class AccountAbstractAnalyticContractLine(models.AbstractModel): + _inherit = 'account.abstract.analytic.contract.line' + + @api.onchange('product_id') + def onchange_product(self): + if self.product_id.is_contract: + self.recurring_rule_type = self.product_id.recurring_rule_type + self.recurring_invoicing_type = ( + self.product_id.recurring_invoicing_type + ) + self.recurring_interval = self.product_id.recurring_interval + self.date_start = fields.Date.today() From 6ee1b9c242156c0ecd9be1b4a06087e437a74f9d Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 5 Nov 2018 16:19:03 +0100 Subject: [PATCH 33/73] [FIX] - Change website to OCA repository url and prefix module name with Recurring --- product_contract/__manifest__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py index f369b825..09769091 100644 --- a/product_contract/__manifest__.py +++ b/product_contract/__manifest__.py @@ -4,14 +4,14 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - 'name': 'Product Contract', + 'name': 'Recurring - Product Contract', 'version': '12.0.1.0.0', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "LasLabs, " "ACSONE SA/NV, " "Odoo Community Association (OCA)", - 'website': 'https://laslabs.com', + 'website': 'https://github.com/oca/contract', 'depends': [ 'product', 'contract_sale', From c8ec4f34040fe7d6fa59a4dd14f0197f391d2266 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 5 Nov 2018 18:05:53 +0100 Subject: [PATCH 34/73] [FIX] - Compute recurring_next_date before create contract line --- product_contract/models/sale_order_line.py | 10 +++++++++- product_contract/tests/test_sale_order.py | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index b0d14ee2..2284a33a 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -64,6 +64,7 @@ class SaleOrderLine(models.Model): @api.multi def _prepare_contract_line_values(self, contract): self.ensure_one() + contract_line_env = self.env['account.analytic.invoice.line'] return { 'sequence': self.sequence, 'product_id': self.product_id.id, @@ -74,6 +75,13 @@ class SaleOrderLine(models.Model): 'discount': self.discount, 'date_end': self.date_end, 'date_start': self.date_start or fields.Date.today(), + 'recurring_next_date': + contract_line_env._compute_first_recurring_next_date( + self.date_start or fields.Date.today(), + self.recurring_invoicing_type, + self.recurring_rule_type, + self.recurring_interval, + ), 'recurring_interval': self.recurring_interval, 'recurring_invoicing_type': self.recurring_invoicing_type, 'recurring_rule_type': self.recurring_rule_type, @@ -89,7 +97,7 @@ class SaleOrderLine(models.Model): contract_line |= contract_line_env.create( rec._prepare_contract_line_values(contract) ) - contract_line._onchange_date_start() + return contract_line @api.constrains('contract_id') def _check_contract_sale_partner(self): diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index b3b505e8..e60cffff 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -16,7 +16,25 @@ class TestSaleOrder(TransactionCase): {'name': 'Template 1'} ) self.contract_template2 = self.env['account.analytic.contract'].create( - {'name': 'Template 2'} + { + 'name': 'Template 2', + 'recurring_invoice_line_ids': [ + ( + 0, + 0, + { + 'product_id': self.product2.id, + 'name': 'Services from #START# to #END#', + 'quantity': 1, + 'uom_id': self.product2.uom_id.id, + 'price_unit': 100, + 'discount': 50, + 'recurring_rule_type': 'yearly', + 'recurring_interval': 1, + }, + ) + ], + } ) self.product1.write( { From 29a83d77694e3085ef984bb4edeb7223386068fb Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Thu, 15 Nov 2018 11:53:01 +0100 Subject: [PATCH 35/73] [IMP] - Upsell/Downsell contract from sale order --- product_contract/__manifest__.py | 6 +-- product_contract/models/product_template.py | 1 - product_contract/models/sale_order.py | 1 - product_contract/models/sale_order_line.py | 9 ++++- product_contract/tests/test_product.py | 1 - product_contract/tests/test_sale_order.py | 43 ++++++++++++++++++++- product_contract/views/sale_order.xml | 17 ++++---- 7 files changed, 61 insertions(+), 17 deletions(-) diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py index 09769091..fc857821 100644 --- a/product_contract/__manifest__.py +++ b/product_contract/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. # Copyright 2018 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -12,10 +11,7 @@ "ACSONE SA/NV, " "Odoo Community Association (OCA)", 'website': 'https://github.com/oca/contract', - 'depends': [ - 'product', - 'contract_sale', - ], + 'depends': ['product', 'contract_sale'], 'data': [ 'views/product_template.xml', 'views/sale_order.xml', diff --git a/product_contract/models/product_template.py b/product_contract/models/product_template.py index 1d256201..b10ef3de 100644 --- a/product_contract/models/product_template.py +++ b/product_contract/models/product_template.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. # Copyright 2018 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py index 3a38c116..ad6f9690 100644 --- a/product_contract/models/sale_order.py +++ b/product_contract/models/sale_order.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. # Copyright 2018 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 2284a33a..b0434540 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. # Copyright 2017 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -51,6 +50,13 @@ class SaleOrderLine(models.Model): date_start = fields.Date(string='Date Start') date_end = fields.Date(string='Date End', index=True) + contract_line_id = fields.Many2one( + comodel_name="account.analytic.invoice.line", + string="Contract Line to replace", + required=False, + copy=False, + ) + @api.onchange('product_id') def onchange_product(self): if self.product_id.is_contract: @@ -97,6 +103,7 @@ class SaleOrderLine(models.Model): contract_line |= contract_line_env.create( rec._prepare_contract_line_values(contract) ) + rec.contract_line_id.stop(rec.date_start) return contract_line @api.constrains('contract_id') diff --git a/product_contract/tests/test_product.py b/product_contract/tests/test_product.py index 3676dc05..76d1aef8 100644 --- a/product_contract/tests/test_product.py +++ b/product_contract/tests/test_product.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. # Copyright 2018 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index e60cffff..37feb78b 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -1,9 +1,10 @@ -# -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. +# Copyright 2018 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo.tests.common import TransactionCase from odoo.exceptions import ValidationError +from odoo.fields import Date class TestSaleOrder(TransactionCase): @@ -51,6 +52,36 @@ class TestSaleOrder(TransactionCase): self.order_line1 = self.sale.order_line.filtered( lambda l: l.product_id == self.product1 ) + self.contract = self.env["account.analytic.account"].create( + { + "name": "Test Contract 2", + "partner_id": self.sale.partner_id.id, + "pricelist_id": + self.sale.partner_id.property_product_pricelist.id, + "recurring_invoices": True, + "contract_type": "purchase", + "contract_template_id": self.contract_template1.id, + "recurring_invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": self.product1.id, + "name": "Services from #START# to #END#", + "quantity": 1, + "uom_id": self.product1.uom_id.id, + "price_unit": 100, + "discount": 50, + "recurring_rule_type": "monthly", + "recurring_interval": 1, + "date_start": "2016-02-15", + "recurring_next_date": "2016-02-29", + }, + ) + ], + } + ) + self.contract_line = self.contract.recurring_invoice_line_ids[0] def test_compute_is_contract(self): """Sale Order should have is_contract true if one of its lines is @@ -153,3 +184,13 @@ class TestSaleOrder(TransactionCase): self.sale.action_confirm() invoice = self.order_line1.contract_id.recurring_create_invoice() self.assertTrue(invoice in self.sale.invoice_ids) + + def test_contract_upsell(self): + """Should stop contract line at sale order line start date""" + self.order_line1.contract_id = self.contract + self.order_line1.contract_line_id = self.contract_line + self.order_line1.date_start = "2018-01-01" + self.sale.action_confirm() + self.assertEqual( + self.contract_line.date_end, Date.to_date("2018-01-01") + ) diff --git a/product_contract/views/sale_order.xml b/product_contract/views/sale_order.xml index 4443c39d..b24f7fe6 100644 --- a/product_contract/views/sale_order.xml +++ b/product_contract/views/sale_order.xml @@ -25,14 +25,17 @@ - - - - + + + + + Date: Mon, 19 Nov 2018 16:00:48 +0100 Subject: [PATCH 36/73] [ADD] - Add renewal process with termination notice --- .../models/abstract_contract_line.py | 9 ++++ product_contract/models/product_template.py | 20 +++++++ product_contract/models/sale_order_line.py | 25 +++++++-- product_contract/tests/test_sale_order.py | 27 +++++++++- product_contract/views/product_template.xml | 53 +++++++++++++------ product_contract/views/sale_order.xml | 6 ++- 6 files changed, 117 insertions(+), 23 deletions(-) diff --git a/product_contract/models/abstract_contract_line.py b/product_contract/models/abstract_contract_line.py index 1bfe4c8c..2013cc15 100644 --- a/product_contract/models/abstract_contract_line.py +++ b/product_contract/models/abstract_contract_line.py @@ -16,3 +16,12 @@ class AccountAbstractAnalyticContractLine(models.AbstractModel): ) self.recurring_interval = self.product_id.recurring_interval self.date_start = fields.Date.today() + self.is_auto_renew = self.product_id.is_auto_renew + self.auto_renew_interval = self.product_id.auto_renew_interval + self.auto_renew_rule_type = self.product_id.auto_renew_rule_type + self.termination_notice_interval = ( + self.product_id.termination_notice_interval + ) + self.termination_notice_rule_type = ( + self.product_id.termination_notice_rule_type + ) diff --git a/product_contract/models/product_template.py b/product_contract/models/product_template.py index b10ef3de..d3fd0b55 100644 --- a/product_contract/models/product_template.py +++ b/product_contract/models/product_template.py @@ -37,6 +37,26 @@ class ProductTemplate(models.Model): string='Repeat Every', help="Repeat every (Days/Week/Month/Year)", ) + is_auto_renew = fields.Boolean(string="Auto Renew", default=False) + auto_renew_interval = fields.Integer( + default=1, + string='Renew Every', + help="Renew every (Days/Week/Month/Year)", + ) + auto_renew_rule_type = fields.Selection( + [('monthly', 'Month(s)'), ('yearly', 'Year(s)')], + default='yearly', + string='Renewal type', + help="Specify Interval for automatic renewal.", + ) + termination_notice_interval = fields.Integer( + default=1, string='Termination Notice Before' + ) + termination_notice_rule_type = fields.Selection( + [('daily', 'Day(s)'), ('weekly', 'Week(s)'), ('monthly', 'Month(s)')], + default='monthly', + string='Termination Notice type', + ) @api.onchange('is_contract') def _change_is_contract(self): diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index b0434540..7caaf7a3 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -47,8 +47,8 @@ class SaleOrderLine(models.Model): help="Repeat every (Days/Week/Month/Year)", copy=False, ) - date_start = fields.Date(string='Date Start') - date_end = fields.Date(string='Date End', index=True) + date_start = fields.Date(string='Date Start',) + date_end = fields.Date(string='Date End',) contract_line_id = fields.Many2one( comodel_name="account.analytic.invoice.line", @@ -56,6 +56,11 @@ class SaleOrderLine(models.Model): required=False, copy=False, ) + is_auto_renew = fields.Boolean( + string="Auto Renew", + related="product_id.is_auto_renew", + readonly=True, + ) @api.onchange('product_id') def onchange_product(self): @@ -65,7 +70,14 @@ class SaleOrderLine(models.Model): self.product_id.recurring_invoicing_type ) self.recurring_interval = self.product_id.recurring_interval - self.date_start = fields.Date.today() + self.date_start = self.date_start or fields.Date.today() + if self.product_id.is_auto_renew: + self.date_end = self.date_start + self.env[ + 'account.analytic.invoice.line' + ].get_relative_delta( + self.product_id.auto_renew_rule_type, + self.product_id.auto_renew_interval, + ) @api.multi def _prepare_contract_line_values(self, contract): @@ -91,6 +103,13 @@ class SaleOrderLine(models.Model): 'recurring_interval': self.recurring_interval, 'recurring_invoicing_type': self.recurring_invoicing_type, 'recurring_rule_type': self.recurring_rule_type, + 'is_auto_renew': self.product_id.is_auto_renew, + 'auto_renew_interval': self.product_id.auto_renew_interval, + 'auto_renew_rule_type': self.product_id.auto_renew_rule_type, + 'termination_notice_interval': + self.product_id.termination_notice_interval, + 'termination_notice_rule_type': + self.product_id.termination_notice_rule_type, 'contract_id': contract.id, 'sale_order_line_id': self.id, } diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index 37feb78b..09f9d9a9 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -40,6 +40,7 @@ class TestSaleOrder(TransactionCase): self.product1.write( { 'is_contract': True, + 'is_auto_renew': True, 'contract_template_id': self.contract_template1.id, } ) @@ -52,6 +53,7 @@ class TestSaleOrder(TransactionCase): self.order_line1 = self.sale.order_line.filtered( lambda l: l.product_id == self.product1 ) + self.order_line1.date_start = '2018-01-01' self.contract = self.env["account.analytic.account"].create( { "name": "Test Contract 2", @@ -88,9 +90,14 @@ class TestSaleOrder(TransactionCase): contract""" self.assertTrue(self.sale.is_contract) + def test_action_confirm_auto_renew_without_date_end(self): + with self.assertRaises(ValidationError): + self.sale.action_confirm() + def test_action_confirm(self): """ It should create a contract for each contract template used in order_line """ + self.order_line1.onchange_product() self.sale.action_confirm() contracts = self.sale.order_line.mapped('contract_id') self.assertEqual(len(contracts), 2) @@ -102,12 +109,14 @@ class TestSaleOrder(TransactionCase): def test_sale_contract_count(self): """It should count contracts as many different contract template used in order_line""" + self.order_line1.onchange_product() self.sale.action_confirm() self.assertEqual(self.sale.contract_count, 2) def test_onchange_product(self): """ It should get recurrence invoicing info to the sale line from its product """ + self.order_line1.onchange_product() self.assertEqual( self.order_line1.recurring_rule_type, self.product1.recurring_rule_type, @@ -120,6 +129,10 @@ class TestSaleOrder(TransactionCase): self.order_line1.recurring_invoicing_type, self.product1.recurring_invoicing_type, ) + self.assertEqual( + self.order_line1.date_end, + Date.to_date('2019-01-01'), + ) def test_check_contract_sale_partner(self): """Can't link order line to a partner contract different then the @@ -155,6 +168,7 @@ class TestSaleOrder(TransactionCase): def test_sale_order_line_invoice_status(self): """Sale order line for contract product should have nothing to invoice as status""" + self.order_line1.onchange_product() self.sale.action_confirm() self.assertEqual(self.order_line1.invoice_status, 'no') @@ -164,6 +178,7 @@ class TestSaleOrder(TransactionCase): self.sale.order_line.filtered( lambda line: not line.product_id.is_contract ).unlink() + self.order_line1.onchange_product() self.sale.action_confirm() self.assertEqual(self.sale.invoice_status, 'no') @@ -171,6 +186,7 @@ class TestSaleOrder(TransactionCase): """Should not invoice contract product on sale order create invoice""" self.product2.is_contract = False self.product2.invoice_policy = 'order' + self.order_line1.onchange_product() self.sale.action_confirm() self.sale.action_invoice_create() self.assertEqual(len(self.sale.invoice_ids), 1) @@ -181,6 +197,7 @@ class TestSaleOrder(TransactionCase): def test_link_contract_invoice_to_sale_order(self): """It should link contract invoice to sale order""" + self.order_line1.onchange_product() self.sale.action_confirm() invoice = self.order_line1.contract_id.recurring_create_invoice() self.assertTrue(invoice in self.sale.invoice_ids) @@ -189,8 +206,14 @@ class TestSaleOrder(TransactionCase): """Should stop contract line at sale order line start date""" self.order_line1.contract_id = self.contract self.order_line1.contract_line_id = self.contract_line - self.order_line1.date_start = "2018-01-01" + self.contract_line.date_end = "2019-01-01" + self.contract_line.is_auto_renew = "2019-01-01" + self.order_line1.date_start = "2018-06-01" + self.order_line1.onchange_product() self.sale.action_confirm() self.assertEqual( - self.contract_line.date_end, Date.to_date("2018-01-01") + self.contract_line.date_end, Date.to_date("2018-06-01") + ) + self.assertFalse( + self.contract_line.is_auto_renew ) diff --git a/product_contract/views/product_template.xml b/product_contract/views/product_template.xml index 9eb3b38f..0ff9f33f 100644 --- a/product_contract/views/product_template.xml +++ b/product_contract/views/product_template.xml @@ -19,24 +19,45 @@ - - - + + + + + - + + + + diff --git a/product_contract/views/sale_order.xml b/product_contract/views/sale_order.xml index b24f7fe6..8493716d 100644 --- a/product_contract/views/sale_order.xml +++ b/product_contract/views/sale_order.xml @@ -34,6 +34,8 @@ + - + - + Date: Mon, 19 Nov 2018 16:53:35 +0100 Subject: [PATCH 37/73] [IMP] - compute date end onchange date start for auto-renew sale order lines --- product_contract/models/sale_order_line.py | 16 +++++++++++++++- product_contract/views/product_template.xml | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 7caaf7a3..3bef2d85 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -71,7 +71,7 @@ class SaleOrderLine(models.Model): ) self.recurring_interval = self.product_id.recurring_interval self.date_start = self.date_start or fields.Date.today() - if self.product_id.is_auto_renew: + if self.is_auto_renew: self.date_end = self.date_start + self.env[ 'account.analytic.invoice.line' ].get_relative_delta( @@ -79,6 +79,20 @@ class SaleOrderLine(models.Model): self.product_id.auto_renew_interval, ) + @api.onchange('date_start') + def onchange_date_start(self): + for rec in self: + if rec.is_auto_renew: + if not self.date_start: + rec.date_end = False + else: + self.date_end = self.date_start + self.env[ + 'account.analytic.invoice.line' + ].get_relative_delta( + self.product_id.auto_renew_rule_type, + self.product_id.auto_renew_interval, + ) + @api.multi def _prepare_contract_line_values(self, contract): self.ensure_one() diff --git a/product_contract/views/product_template.xml b/product_contract/views/product_template.xml index 0ff9f33f..92bac211 100644 --- a/product_contract/views/product_template.xml +++ b/product_contract/views/product_template.xml @@ -21,6 +21,7 @@ Date: Mon, 26 Nov 2018 15:17:24 +0100 Subject: [PATCH 38/73] [IMP] - link contract line and its successor in upsel case --- product_contract/models/sale_order_line.py | 39 ++++++++++++---------- product_contract/tests/test_sale_order.py | 19 ++++++----- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 3bef2d85..4a41c2a6 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -47,8 +47,8 @@ class SaleOrderLine(models.Model): help="Repeat every (Days/Week/Month/Year)", copy=False, ) - date_start = fields.Date(string='Date Start',) - date_end = fields.Date(string='Date End',) + date_start = fields.Date(string='Date Start') + date_end = fields.Date(string='Date End') contract_line_id = fields.Many2one( comodel_name="account.analytic.invoice.line", @@ -57,9 +57,7 @@ class SaleOrderLine(models.Model): copy=False, ) is_auto_renew = fields.Boolean( - string="Auto Renew", - related="product_id.is_auto_renew", - readonly=True, + string="Auto Renew", related="product_id.is_auto_renew", readonly=True ) @api.onchange('product_id') @@ -107,23 +105,20 @@ class SaleOrderLine(models.Model): 'discount': self.discount, 'date_end': self.date_end, 'date_start': self.date_start or fields.Date.today(), - 'recurring_next_date': - contract_line_env._compute_first_recurring_next_date( - self.date_start or fields.Date.today(), - self.recurring_invoicing_type, - self.recurring_rule_type, - self.recurring_interval, - ), + 'recurring_next_date': contract_line_env._compute_first_recurring_next_date( + self.date_start or fields.Date.today(), + self.recurring_invoicing_type, + self.recurring_rule_type, + self.recurring_interval, + ), 'recurring_interval': self.recurring_interval, 'recurring_invoicing_type': self.recurring_invoicing_type, 'recurring_rule_type': self.recurring_rule_type, 'is_auto_renew': self.product_id.is_auto_renew, 'auto_renew_interval': self.product_id.auto_renew_interval, 'auto_renew_rule_type': self.product_id.auto_renew_rule_type, - 'termination_notice_interval': - self.product_id.termination_notice_interval, - 'termination_notice_rule_type': - self.product_id.termination_notice_rule_type, + 'termination_notice_interval': self.product_id.termination_notice_interval, + 'termination_notice_rule_type': self.product_id.termination_notice_rule_type, 'contract_id': contract.id, 'sale_order_line_id': self.id, } @@ -133,10 +128,18 @@ class SaleOrderLine(models.Model): contract_line_env = self.env['account.analytic.invoice.line'] contract_line = self.env['account.analytic.invoice.line'] for rec in self: - contract_line |= contract_line_env.create( + new_contract_line = contract_line_env.create( rec._prepare_contract_line_values(contract) ) - rec.contract_line_id.stop(rec.date_start) + contract_line |= new_contract_line + if rec.contract_line_id: + rec.contract_line_id.stop(rec.date_start) + rec.contract_line_id.successor_contract_line_id = ( + new_contract_line + ) + new_contract_line.predecessor_contract_line_id = ( + self.contract_line_id.id + ) return contract_line @api.constrains('contract_id') diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index 09f9d9a9..de46f93c 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -58,8 +58,7 @@ class TestSaleOrder(TransactionCase): { "name": "Test Contract 2", "partner_id": self.sale.partner_id.id, - "pricelist_id": - self.sale.partner_id.property_product_pricelist.id, + "pricelist_id": self.sale.partner_id.property_product_pricelist.id, "recurring_invoices": True, "contract_type": "purchase", "contract_template_id": self.contract_template1.id, @@ -129,10 +128,7 @@ class TestSaleOrder(TransactionCase): self.order_line1.recurring_invoicing_type, self.product1.recurring_invoicing_type, ) - self.assertEqual( - self.order_line1.date_end, - Date.to_date('2019-01-01'), - ) + self.assertEqual(self.order_line1.date_end, Date.to_date('2019-01-01')) def test_check_contract_sale_partner(self): """Can't link order line to a partner contract different then the @@ -214,6 +210,13 @@ class TestSaleOrder(TransactionCase): self.assertEqual( self.contract_line.date_end, Date.to_date("2018-06-01") ) - self.assertFalse( - self.contract_line.is_auto_renew + self.assertFalse(self.contract_line.is_auto_renew) + new_contract_line = self.env['account.analytic.invoice.line'].search( + [('sale_order_line_id', '=', self.order_line1.id)] + ) + self.assertEqual( + self.contract_line.successor_contract_line_id, new_contract_line + ) + self.assertEqual( + new_contract_line.predecessor_contract_line_id, self.contract_line ) From 478c9b01ca5e5a887406d178c7f878bd828f4bbb Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Wed, 28 Nov 2018 18:37:31 +0100 Subject: [PATCH 39/73] [FIX] - on upsel, contract line should stop day - 1 --- product_contract/__manifest__.py | 9 ++------ product_contract/models/sale_order_line.py | 24 ++++++++++++++-------- product_contract/tests/test_sale_order.py | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py index fc857821..d1dc37ee 100644 --- a/product_contract/__manifest__.py +++ b/product_contract/__manifest__.py @@ -7,15 +7,10 @@ 'version': '12.0.1.0.0', 'category': 'Contract Management', 'license': 'AGPL-3', - 'author': "LasLabs, " - "ACSONE SA/NV, " - "Odoo Community Association (OCA)", + 'author': "LasLabs, " "ACSONE SA/NV, " "Odoo Community Association (OCA)", 'website': 'https://github.com/oca/contract', 'depends': ['product', 'contract_sale'], - 'data': [ - 'views/product_template.xml', - 'views/sale_order.xml', - ], + 'data': ['views/product_template.xml', 'views/sale_order.xml'], 'installable': True, 'application': False, } diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 4a41c2a6..07195dcc 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -2,6 +2,7 @@ # Copyright 2017 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from dateutil.relativedelta import relativedelta from odoo import api, fields, models, _ from odoo.exceptions import ValidationError @@ -105,20 +106,23 @@ class SaleOrderLine(models.Model): 'discount': self.discount, 'date_end': self.date_end, 'date_start': self.date_start or fields.Date.today(), - 'recurring_next_date': contract_line_env._compute_first_recurring_next_date( - self.date_start or fields.Date.today(), - self.recurring_invoicing_type, - self.recurring_rule_type, - self.recurring_interval, - ), + 'recurring_next_date': + contract_line_env._compute_first_recurring_next_date( + self.date_start or fields.Date.today(), + self.recurring_invoicing_type, + self.recurring_rule_type, + self.recurring_interval, + ), 'recurring_interval': self.recurring_interval, 'recurring_invoicing_type': self.recurring_invoicing_type, 'recurring_rule_type': self.recurring_rule_type, 'is_auto_renew': self.product_id.is_auto_renew, 'auto_renew_interval': self.product_id.auto_renew_interval, 'auto_renew_rule_type': self.product_id.auto_renew_rule_type, - 'termination_notice_interval': self.product_id.termination_notice_interval, - 'termination_notice_rule_type': self.product_id.termination_notice_rule_type, + 'termination_notice_interval': + self.product_id.termination_notice_interval, + 'termination_notice_rule_type': + self.product_id.termination_notice_rule_type, 'contract_id': contract.id, 'sale_order_line_id': self.id, } @@ -133,7 +137,9 @@ class SaleOrderLine(models.Model): ) contract_line |= new_contract_line if rec.contract_line_id: - rec.contract_line_id.stop(rec.date_start) + rec.contract_line_id.stop( + rec.date_start - relativedelta(days=1) + ) rec.contract_line_id.successor_contract_line_id = ( new_contract_line ) diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index de46f93c..5409ebc3 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -208,7 +208,7 @@ class TestSaleOrder(TransactionCase): self.order_line1.onchange_product() self.sale.action_confirm() self.assertEqual( - self.contract_line.date_end, Date.to_date("2018-06-01") + self.contract_line.date_end, Date.to_date("2018-05-31") ) self.assertFalse(self.contract_line.is_auto_renew) new_contract_line = self.env['account.analytic.invoice.line'].search( From a17695e4aeff755f1515b980207991e2a8eb54dc Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Thu, 29 Nov 2018 12:09:04 +0100 Subject: [PATCH 40/73] [FIX] - fix onchange --- product_contract/models/sale_order_line.py | 66 ++++++++++++---------- product_contract/tests/test_sale_order.py | 3 +- 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 07195dcc..836f9937 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -63,39 +63,55 @@ class SaleOrderLine(models.Model): @api.onchange('product_id') def onchange_product(self): - if self.product_id.is_contract: - self.recurring_rule_type = self.product_id.recurring_rule_type - self.recurring_invoicing_type = ( - self.product_id.recurring_invoicing_type - ) - self.recurring_interval = self.product_id.recurring_interval - self.date_start = self.date_start or fields.Date.today() - if self.is_auto_renew: - self.date_end = self.date_start + self.env[ - 'account.analytic.invoice.line' - ].get_relative_delta( - self.product_id.auto_renew_rule_type, - self.product_id.auto_renew_interval, + contract_line_env = self.env['account.analytic.invoice.line'] + for rec in self: + if rec.product_id.is_contract: + rec.recurring_rule_type = rec.product_id.recurring_rule_type + rec.recurring_invoicing_type = ( + rec.product_id.recurring_invoicing_type ) + rec.recurring_interval = rec.product_id.recurring_interval + rec.date_start = rec.date_start or fields.Date.today() + if rec.is_auto_renew: + rec.date_end = ( + rec.date_start + + contract_line_env.get_relative_delta( + rec.product_id.auto_renew_rule_type, + rec.product_id.auto_renew_interval, + ) + ) @api.onchange('date_start') def onchange_date_start(self): for rec in self: if rec.is_auto_renew: - if not self.date_start: + if not rec.date_start: rec.date_end = False else: - self.date_end = self.date_start + self.env[ + rec.date_end = rec.date_start + self.env[ 'account.analytic.invoice.line' ].get_relative_delta( - self.product_id.auto_renew_rule_type, - self.product_id.auto_renew_interval, + rec.product_id.auto_renew_rule_type, + rec.product_id.auto_renew_interval, ) @api.multi def _prepare_contract_line_values(self, contract): self.ensure_one() - contract_line_env = self.env['account.analytic.invoice.line'] + recurring_next_date = self.env[ + 'account.analytic.invoice.line' + ]._compute_first_recurring_next_date( + self.date_start or fields.Date.today(), + self.recurring_invoicing_type, + self.recurring_rule_type, + self.recurring_interval, + ) + termination_notice_interval = ( + self.product_id.termination_notice_interval + ) + termination_notice_rule_type = ( + self.product_id.termination_notice_rule_type + ) return { 'sequence': self.sequence, 'product_id': self.product_id.id, @@ -106,23 +122,15 @@ class SaleOrderLine(models.Model): 'discount': self.discount, 'date_end': self.date_end, 'date_start': self.date_start or fields.Date.today(), - 'recurring_next_date': - contract_line_env._compute_first_recurring_next_date( - self.date_start or fields.Date.today(), - self.recurring_invoicing_type, - self.recurring_rule_type, - self.recurring_interval, - ), + 'recurring_next_date': recurring_next_date, 'recurring_interval': self.recurring_interval, 'recurring_invoicing_type': self.recurring_invoicing_type, 'recurring_rule_type': self.recurring_rule_type, 'is_auto_renew': self.product_id.is_auto_renew, 'auto_renew_interval': self.product_id.auto_renew_interval, 'auto_renew_rule_type': self.product_id.auto_renew_rule_type, - 'termination_notice_interval': - self.product_id.termination_notice_interval, - 'termination_notice_rule_type': - self.product_id.termination_notice_rule_type, + 'termination_notice_interval': termination_notice_interval, + 'termination_notice_rule_type': termination_notice_rule_type, 'contract_id': contract.id, 'sale_order_line_id': self.id, } diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index 5409ebc3..73715d12 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -54,11 +54,12 @@ class TestSaleOrder(TransactionCase): lambda l: l.product_id == self.product1 ) self.order_line1.date_start = '2018-01-01' + pricelist = self.sale.partner_id.property_product_pricelist.id self.contract = self.env["account.analytic.account"].create( { "name": "Test Contract 2", "partner_id": self.sale.partner_id.id, - "pricelist_id": self.sale.partner_id.property_product_pricelist.id, + "pricelist_id": pricelist, "recurring_invoices": True, "contract_type": "purchase", "contract_template_id": self.contract_template1.id, From 639d2ee524e34f8ecdc4b06dbd6890125a27bc84 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Thu, 29 Nov 2018 12:32:22 +0100 Subject: [PATCH 41/73] [IMP] - hide recurring_invoicing_type if recurring_rule_type is monthlylastday for the monthlylastday case, pre-paid is logicly impossible, if monthlylastday is set, we consider only post-paid case --- product_contract/views/product_template.xml | 25 ++++++++++++--------- product_contract/views/sale_order.xml | 24 ++++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/product_contract/views/product_template.xml b/product_contract/views/product_template.xml index 92bac211..dcc54cae 100644 --- a/product_contract/views/product_template.xml +++ b/product_contract/views/product_template.xml @@ -26,16 +26,21 @@ - - - + + + + + + diff --git a/product_contract/views/sale_order.xml b/product_contract/views/sale_order.xml index 8493716d..d5a75d02 100644 --- a/product_contract/views/sale_order.xml +++ b/product_contract/views/sale_order.xml @@ -40,30 +40,30 @@ + - - - - + - + + + + - + Date: Fri, 30 Nov 2018 17:16:55 +0100 Subject: [PATCH 42/73] [FIX] - include date_end in the period if the product is_autorenew --- product_contract/models/sale_order_line.py | 15 ++++++++++----- product_contract/tests/test_sale_order.py | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 836f9937..af93f9bf 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -79,6 +79,7 @@ class SaleOrderLine(models.Model): rec.product_id.auto_renew_rule_type, rec.product_id.auto_renew_interval, ) + - relativedelta(days=1) ) @api.onchange('date_start') @@ -88,11 +89,15 @@ class SaleOrderLine(models.Model): if not rec.date_start: rec.date_end = False else: - rec.date_end = rec.date_start + self.env[ - 'account.analytic.invoice.line' - ].get_relative_delta( - rec.product_id.auto_renew_rule_type, - rec.product_id.auto_renew_interval, + rec.date_end = ( + rec.date_start + + self.env[ + 'account.analytic.invoice.line' + ].get_relative_delta( + rec.product_id.auto_renew_rule_type, + rec.product_id.auto_renew_interval, + ) + - relativedelta(days=1) ) @api.multi diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index 73715d12..72105999 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -129,7 +129,7 @@ class TestSaleOrder(TransactionCase): self.order_line1.recurring_invoicing_type, self.product1.recurring_invoicing_type, ) - self.assertEqual(self.order_line1.date_end, Date.to_date('2019-01-01')) + self.assertEqual(self.order_line1.date_end, Date.to_date('2018-12-31')) def test_check_contract_sale_partner(self): """Can't link order line to a partner contract different then the From fc47a1edefb5662c0baac551458603760da9c09d Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 3 Dec 2018 13:13:10 +0100 Subject: [PATCH 43/73] [IMP] - _prepare_contract_value for sale order confirm --- product_contract/models/sale_order.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py index ad6f9690..2ae9b4e4 100644 --- a/product_contract/models/sale_order.py +++ b/product_contract/models/sale_order.py @@ -17,6 +17,18 @@ class SaleOrder(models.Model): def _compute_is_contract(self): self.is_contract = any(self.order_line.mapped('is_contract')) + @api.multi + def _prepare_contract_value(self, contract_template): + self.ensure_one() + return { + 'name': '{template_name}: {sale_name}'.format( + template_name=contract_template.name, sale_name=self.name + ), + 'partner_id': self.partner_id.id, + 'recurring_invoices': True, + 'contract_template_id': contract_template.id, + } + @api.multi def action_confirm(self): """ If we have a contract in the order, set it up """ @@ -36,15 +48,7 @@ class SaleOrder(models.Model): == contract_template ) contract = contract_env.create( - { - 'name': '{template_name}: {sale_name}'.format( - template_name=contract_template.name, - sale_name=rec.name, - ), - 'partner_id': rec.partner_id.id, - 'recurring_invoices': True, - 'contract_template_id': contract_template.id, - } + rec._prepare_contract_value(contract_template) ) contract._onchange_contract_template_id() order_lines.create_contract_line(contract) From d4f6c9b97cc61a3b61422b9e920abaefe9174e9d Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Tue, 4 Dec 2018 12:57:13 +0100 Subject: [PATCH 44/73] [REM] - Remove unused method --- product_contract/models/__init__.py | 1 - .../models/abstract_contract_line.py | 27 ------------------- product_contract/models/sale_order_line.py | 4 +-- 3 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 product_contract/models/abstract_contract_line.py diff --git a/product_contract/models/__init__.py b/product_contract/models/__init__.py index 4d43b3ea..a275fa21 100644 --- a/product_contract/models/__init__.py +++ b/product_contract/models/__init__.py @@ -2,7 +2,6 @@ # Copyright 2017 LasLabs Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import abstract_contract_line from . import contract_line from . import product_template from . import sale_order diff --git a/product_contract/models/abstract_contract_line.py b/product_contract/models/abstract_contract_line.py deleted file mode 100644 index 2013cc15..00000000 --- a/product_contract/models/abstract_contract_line.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2018 ACSONE SA/NV -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import api, models, fields - - -class AccountAbstractAnalyticContractLine(models.AbstractModel): - _inherit = 'account.abstract.analytic.contract.line' - - @api.onchange('product_id') - def onchange_product(self): - if self.product_id.is_contract: - self.recurring_rule_type = self.product_id.recurring_rule_type - self.recurring_invoicing_type = ( - self.product_id.recurring_invoicing_type - ) - self.recurring_interval = self.product_id.recurring_interval - self.date_start = fields.Date.today() - self.is_auto_renew = self.product_id.is_auto_renew - self.auto_renew_interval = self.product_id.auto_renew_interval - self.auto_renew_rule_type = self.product_id.auto_renew_rule_type - self.termination_notice_interval = ( - self.product_id.termination_notice_interval - ) - self.termination_notice_rule_type = ( - self.product_id.termination_notice_rule_type - ) diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index af93f9bf..61094b2b 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -72,7 +72,7 @@ class SaleOrderLine(models.Model): ) rec.recurring_interval = rec.product_id.recurring_interval rec.date_start = rec.date_start or fields.Date.today() - if rec.is_auto_renew: + if rec.product_id.is_auto_renew: rec.date_end = ( rec.date_start + contract_line_env.get_relative_delta( @@ -85,7 +85,7 @@ class SaleOrderLine(models.Model): @api.onchange('date_start') def onchange_date_start(self): for rec in self: - if rec.is_auto_renew: + if rec.product_id.is_auto_renew: if not rec.date_start: rec.date_end = False else: From b9ffcd5054d806d2384774824787dd19f5d36f9e Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Thu, 13 Dec 2018 21:46:11 +0100 Subject: [PATCH 45/73] [IMP] - get contract user from sale order user --- product_contract/models/sale_order.py | 1 + 1 file changed, 1 insertion(+) diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py index 2ae9b4e4..5a7bfd18 100644 --- a/product_contract/models/sale_order.py +++ b/product_contract/models/sale_order.py @@ -27,6 +27,7 @@ class SaleOrder(models.Model): 'partner_id': self.partner_id.id, 'recurring_invoices': True, 'contract_template_id': contract_template.id, + 'user_id': self.user_id.id, } @api.multi From c5929d3005e71f5b676a655cebe401dd0446021e Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Fri, 14 Dec 2018 15:55:12 +0100 Subject: [PATCH 46/73] [IMP] - show related sale orders in contract form --- product_contract/__manifest__.py | 6 ++++- product_contract/models/__init__.py | 1 + product_contract/models/contract.py | 35 +++++++++++++++++++++++++++++ product_contract/views/contract.xml | 29 ++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 product_contract/models/contract.py create mode 100644 product_contract/views/contract.xml diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py index d1dc37ee..aa0f3b74 100644 --- a/product_contract/__manifest__.py +++ b/product_contract/__manifest__.py @@ -10,7 +10,11 @@ 'author': "LasLabs, " "ACSONE SA/NV, " "Odoo Community Association (OCA)", 'website': 'https://github.com/oca/contract', 'depends': ['product', 'contract_sale'], - 'data': ['views/product_template.xml', 'views/sale_order.xml'], + 'data': [ + 'views/contract.xml', + 'views/product_template.xml', + 'views/sale_order.xml' + ], 'installable': True, 'application': False, } diff --git a/product_contract/models/__init__.py b/product_contract/models/__init__.py index a275fa21..6ec5fa03 100644 --- a/product_contract/models/__init__.py +++ b/product_contract/models/__init__.py @@ -2,6 +2,7 @@ # Copyright 2017 LasLabs Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import contract from . import contract_line from . import product_template from . import sale_order diff --git a/product_contract/models/contract.py b/product_contract/models/contract.py new file mode 100644 index 00000000..56279cef --- /dev/null +++ b/product_contract/models/contract.py @@ -0,0 +1,35 @@ +# Copyright 2018 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models +from odoo.tools.translate import _ + + +class AccountAnalyticAccount(models.Model): + _name = 'account.analytic.account' + _inherit = 'account.analytic.account' + + sale_order_count = fields.Integer(compute="_compute_sale_order_count") + + @api.depends('recurring_invoice_line_ids') + def _compute_sale_order_count(self): + for rec in self: + rec.sale_order_count = len( + rec.recurring_invoice_line_ids.mapped( + 'sale_order_line_id.order_id' + ) + ) + + @api.multi + def action_view_sales_orders(self): + self.ensure_one() + orders = self.recurring_invoice_line_ids.mapped( + 'sale_order_line_id.order_id' + ) + return { + "name": _("Sales Orders"), + "view_mode": "tree,form", + "res_model": "sale.order", + "type": "ir.actions.act_window", + "domain": [("id", "in", orders.ids)], + } diff --git a/product_contract/views/contract.xml b/product_contract/views/contract.xml new file mode 100644 index 00000000..abf53e6e --- /dev/null +++ b/product_contract/views/contract.xml @@ -0,0 +1,29 @@ + + + + + + account.analytic.account + + + + + + + + + From 2ad68f94a8e485016d7aac840f8cee21dad49acf Mon Sep 17 00:00:00 2001 From: Thomas Binsfeld Date: Tue, 18 Dec 2018 14:08:31 +0100 Subject: [PATCH 47/73] [REF] Contract Product: invoice in prepare_invoice_line is optional --- product_contract/models/contract_line.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/product_contract/models/contract_line.py b/product_contract/models/contract_line.py index 23fcb306..e067929d 100644 --- a/product_contract/models/contract_line.py +++ b/product_contract/models/contract_line.py @@ -16,9 +16,9 @@ class AccountAnalyticInvoiceLine(models.Model): ) @api.multi - def _prepare_invoice_line(self, invoice_id): + def _prepare_invoice_line(self, invoice_id=False): res = super(AccountAnalyticInvoiceLine, self)._prepare_invoice_line( - invoice_id + invoice_id=invoice_id ) if self.sale_order_line_id: res['sale_line_ids'] = [(6, 0, [self.sale_order_line_id.id])] From 2aca05b59ef5ab0f2934274be350e49815345b8a Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Thu, 20 Dec 2018 22:57:15 +0100 Subject: [PATCH 48/73] [FIX] - fix flake8 --- product_contract/__init__.py | 1 - product_contract/readme/USAGE.rst | 2 +- product_contract/tests/__init__.py | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/product_contract/__init__.py b/product_contract/__init__.py index 44db863b..c6339a00 100644 --- a/product_contract/__init__.py +++ b/product_contract/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/product_contract/readme/USAGE.rst b/product_contract/readme/USAGE.rst index e1380d0f..1ed5d471 100644 --- a/product_contract/readme/USAGE.rst +++ b/product_contract/readme/USAGE.rst @@ -3,4 +3,4 @@ To use this module, you need to: #. Go to Sales -> Products and select or create a product. #. Check "Is a contract" and select the contract template related to the product -#. Define default recurrence rules \ No newline at end of file +#. Define default recurrence rules diff --git a/product_contract/tests/__init__.py b/product_contract/tests/__init__.py index 9d85581f..9dad07bd 100644 --- a/product_contract/tests/__init__.py +++ b/product_contract/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. # Copyright 2018 ACSONE SA/NV. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). From 1c69339970936676a1cfbe6a2aa3b4909a6edf6b Mon Sep 17 00:00:00 2001 From: Thomas Binsfeld Date: Fri, 21 Dec 2018 16:07:40 +0100 Subject: [PATCH 49/73] [ADD] Product Contract: payment term --- product_contract/models/sale_order.py | 1 + 1 file changed, 1 insertion(+) diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py index 5a7bfd18..6c92feef 100644 --- a/product_contract/models/sale_order.py +++ b/product_contract/models/sale_order.py @@ -28,6 +28,7 @@ class SaleOrder(models.Model): 'recurring_invoices': True, 'contract_template_id': contract_template.id, 'user_id': self.user_id.id, + 'payment_term_id': self.payment_term_id.id, } @api.multi From ba6e7840b67aeaea09bc890f6bec4e9f1efa36d3 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Fri, 28 Dec 2018 12:36:19 +0100 Subject: [PATCH 50/73] [IMP] - update invoice_line vals only if it is not null --- product_contract/models/contract_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product_contract/models/contract_line.py b/product_contract/models/contract_line.py index e067929d..0a7a4015 100644 --- a/product_contract/models/contract_line.py +++ b/product_contract/models/contract_line.py @@ -20,6 +20,6 @@ class AccountAnalyticInvoiceLine(models.Model): res = super(AccountAnalyticInvoiceLine, self)._prepare_invoice_line( invoice_id=invoice_id ) - if self.sale_order_line_id: + if self.sale_order_line_id and res: res['sale_line_ids'] = [(6, 0, [self.sale_order_line_id.id])] return res From d24f99a407c66097fb58a67e11260e1b185e8ece Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Thu, 3 Jan 2019 11:51:44 +0100 Subject: [PATCH 51/73] [FIX] - fix unit tests --- product_contract/tests/test_sale_order.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index 72105999..d3c29572 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -2,6 +2,7 @@ # Copyright 2018 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from dateutil.relativedelta import relativedelta from odoo.tests.common import TransactionCase from odoo.exceptions import ValidationError from odoo.fields import Date @@ -61,7 +62,7 @@ class TestSaleOrder(TransactionCase): "partner_id": self.sale.partner_id.id, "pricelist_id": pricelist, "recurring_invoices": True, - "contract_type": "purchase", + "contract_type": "sale", "contract_template_id": self.contract_template1.id, "recurring_invoice_line_ids": [ ( @@ -203,8 +204,8 @@ class TestSaleOrder(TransactionCase): """Should stop contract line at sale order line start date""" self.order_line1.contract_id = self.contract self.order_line1.contract_line_id = self.contract_line - self.contract_line.date_end = "2019-01-01" - self.contract_line.is_auto_renew = "2019-01-01" + self.contract_line.date_end = Date.today() + relativedelta(months=4) + self.contract_line.is_auto_renew = True self.order_line1.date_start = "2018-06-01" self.order_line1.onchange_product() self.sale.action_confirm() From ead260ce54121b988a4e22084f662a62183d7a43 Mon Sep 17 00:00:00 2001 From: Thomas Binsfeld Date: Mon, 7 Jan 2019 14:28:10 +0100 Subject: [PATCH 52/73] [ADD] Contract Sale Payment Mode --- contract_sale_payment_mode/README.rst | 73 +++ contract_sale_payment_mode/__init__.py | 1 + contract_sale_payment_mode/__manifest__.py | 22 + contract_sale_payment_mode/models/__init__.py | 1 + .../models/sale_order.py | 16 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 1 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 419 ++++++++++++++++++ .../odoo/addons/contract_sale_payment_mode | 1 + setup/contract_sale_payment_mode/setup.py | 6 + 11 files changed, 541 insertions(+) create mode 100644 contract_sale_payment_mode/README.rst create mode 100644 contract_sale_payment_mode/__init__.py create mode 100644 contract_sale_payment_mode/__manifest__.py create mode 100644 contract_sale_payment_mode/models/__init__.py create mode 100644 contract_sale_payment_mode/models/sale_order.py create mode 100644 contract_sale_payment_mode/readme/CONTRIBUTORS.rst create mode 100644 contract_sale_payment_mode/readme/DESCRIPTION.rst create mode 100644 contract_sale_payment_mode/static/description/icon.png create mode 100644 contract_sale_payment_mode/static/description/index.html create mode 120000 setup/contract_sale_payment_mode/odoo/addons/contract_sale_payment_mode create mode 100644 setup/contract_sale_payment_mode/setup.py diff --git a/contract_sale_payment_mode/README.rst b/contract_sale_payment_mode/README.rst new file mode 100644 index 00000000..b1a70bc1 --- /dev/null +++ b/contract_sale_payment_mode/README.rst @@ -0,0 +1,73 @@ +========================== +Contract Sale Payment Mode +========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/12.0/contract_sale_payment_mode + :alt: OCA/contract +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract_sale_payment_mode + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/110/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module manages the payment mode from sale order to contract. + +**Table of contents** + +.. contents:: + :local: + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Thomas Binsfeld + +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/contract `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/contract_sale_payment_mode/__init__.py b/contract_sale_payment_mode/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/contract_sale_payment_mode/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/contract_sale_payment_mode/__manifest__.py b/contract_sale_payment_mode/__manifest__.py new file mode 100644 index 00000000..1aa7187c --- /dev/null +++ b/contract_sale_payment_mode/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Contract Sale Payment Mode', + 'summary': """ + This addon manages payment mode from sale order to contract.""", + 'version': '12.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', + 'website': 'https://acsone.eu/', + 'depends': [ + # OCA/bank-payment + 'account_payment_sale', + # OCA/contract + 'product_contract', + ], + 'data': [ + ], + 'demo': [ + ], +} diff --git a/contract_sale_payment_mode/models/__init__.py b/contract_sale_payment_mode/models/__init__.py new file mode 100644 index 00000000..6aacb753 --- /dev/null +++ b/contract_sale_payment_mode/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order diff --git a/contract_sale_payment_mode/models/sale_order.py b/contract_sale_payment_mode/models/sale_order.py new file mode 100644 index 00000000..95a4a79b --- /dev/null +++ b/contract_sale_payment_mode/models/sale_order.py @@ -0,0 +1,16 @@ +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class SaleOrder(models.Model): + _inherit = 'sale.order' + + @api.multi + def _prepare_contract_value(self, contract_template): + self.ensure_one() + vals = super(SaleOrder, self)._prepare_contract_value( + contract_template) + vals['payment_mode_id'] = self.payment_mode_id.id + return vals diff --git a/contract_sale_payment_mode/readme/CONTRIBUTORS.rst b/contract_sale_payment_mode/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..e90fe382 --- /dev/null +++ b/contract_sale_payment_mode/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Thomas Binsfeld diff --git a/contract_sale_payment_mode/readme/DESCRIPTION.rst b/contract_sale_payment_mode/readme/DESCRIPTION.rst new file mode 100644 index 00000000..3dd53cdb --- /dev/null +++ b/contract_sale_payment_mode/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module manages the payment mode from sale order to contract. diff --git a/contract_sale_payment_mode/static/description/icon.png b/contract_sale_payment_mode/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h zFfekr30S!-LHmV_Su-W+rEwYXJ^;6&3|L$mMC8*bQptyOo9;>Qb9Q9`ySe3%V$A*9 zeKEe+b0{#KWGp$F+tga)0RtI)nhMa-K@JS}2krK~n8vJ=Ngm?R!9G<~RyuU0d?nz# z-5EK$o(!F?hmX*2Yt6+coY`6jGbb7tF#6nHA zuKk=GGJ;ZwON1iAfG$E#Y7MnZVmrY|j0eVI(DN_MNFJmyZ|;w4tf@=CCDZ#5N_0K= z$;R~bbk?}TpfDjfB&aiQ$VA}s?P}xPERJG{kxk5~R`iRS(SK5d+Xs9swCozZISbnS zk!)I0>t=A<-^z(cmSFz3=jZ23u13X><0b)P)^1T_))Kr`e!-pb#q&J*Q`p+B6la%C zuVl&0duN<;uOsB3%T9Fp8t{ED108<+W(nOZd?gDnfNBC3>M8WE61$So|P zVvqH0SNtDTcsUdzaMDpT=Ty0pDHHNL@Z0w$Y`XO z2M-_r1S+GaH%pz#Uy0*w$Vdl=X=rQXEzO}d6J^R6zjM1u&c9vYLvLp?W7w(?np9x1 zE_0JSAJCPB%i7p*Wvg)pn5T`8k3-uR?*NT|J`eS#_#54p>!p(mLDvmc-3o0mX*mp_ zN*AeS<>#^-{S%W<*mz^!X$w_2dHWpcJ6^j64qFBft-o}o_Vx80o0>}Du;>kLts;$8 zC`7q$QI(dKYG`Wa8#wl@V4jVWBRGQ@1dr-hstpQL)Tl+aqVpGpbSfN>5i&QMXfiZ> zaA?T1VGe?rpQ@;+pkrVdd{klI&jVS@I5_iz!=UMpTsa~mBga?1r}aRBm1WS;TT*s0f0lY=JBl66Upy)-k4J}lh=P^8(SXk~0xW=T9v*B|gzIhN z>qsO7dFd~mgxAy4V?&)=5ieYq?zi?ZEoj)&2o)RLy=@hbCRcfT5jigwtQGE{L*8<@Yd{zg;CsL5mvzfDY}P-wos_6PfprFVaeqNE%h zKZhLtcQld;ZD+>=nqN~>GvROfueSzJD&BE*}XfU|H&(FssBqY=hPCt`d zH?@s2>I(|;fcW&YM6#V#!kUIP8$Nkdh0A(bEVj``-AAyYgwY~jB zT|I7Bf@%;7aL7Wf4dZ%VqF$eiaC38OV6oy3Z#TER2G+fOCd9Iaoy6aLYbPTN{XRPz z;U!V|vBf%H!}52L2gH_+j;`bTcQRXB+y9onc^wLm5wi3-Be}U>k_u>2Eg$=k!(l@I zcCg+flakT2Nej3i0yn+g+}%NYb?ta;R?(g5SnwsQ49U8Wng8d|{B+lyRcEDvR3+`O{zfmrmvFrL6acVP%yG98X zo&+VBg@px@i)%o?dG(`T;n*$S5*rnyiR#=wW}}GsAcfyQpE|>a{=$Hjg=-*_K;UtD z#z-)AXwSRY?OPefw^iI+ z)AXz#PfEjlwTes|_{sB?4(O@fg0AJ^g8gP}ex9Ucf*@_^J(s_5jJV}c)s$`Myn|Kd z$6>}#q^n{4vN@+Os$m7KV+`}c%4)4pv@06af4-x5#wj!KKb%caK{A&Y#Rfs z-po?Dcb1({W=6FKIUirH&(yg=*6aLCekcKwyfK^JN5{wcA3nhO(o}SK#!CINhI`-I z1)6&n7O&ZmyFMuNwvEic#IiOAwNkR=u5it{B9n2sAJV5pNhar=j5`*N!Na;c7g!l$ z3aYBqUkqqTJ=Re-;)s!EOeij=7SQZ3Hq}ZRds%IM*PtM$wV z@;rlc*NRK7i3y5BETSKuumEN`Xu_8GP1Ri=OKQ$@I^ko8>H6)4rjiG5{VBM>B|%`&&s^)jS|-_95&yc=GqjNo{zFkw%%HHhS~e=s zD#sfS+-?*t|J!+ozP6KvtOl!R)@@-z24}`9{QaVLD^9VCSR2b`b!KC#o;Ki<+wXB6 zx3&O0LOWcg4&rv4QG0)4yb}7BFSEg~=IR5#ZRj8kg}dS7_V&^%#Do==#`u zpy6{ox?jWuR(;pg+f@mT>#HGWHAJRRDDDv~@(IDw&R>9643kK#HN`!1vBJHnC+RM&yIh8{gG2q zA%e*U3|N0XSRa~oX-3EAneep)@{h2vvd3Xvy$7og(sayr@95+e6~Xvi1tUqnIxoIH zVWo*OwYElb#uyW{Imam6f2rGbjR!Y3`#gPqkv57dB6K^wRGxc9B(t|aYDGS=m$&S!NmCtrMMaUg(c zc2qC=2Z`EEFMW-me5B)24AqF*bV5Dr-M5ig(l-WPS%CgaPzs6p_gnCIvTJ=Y<6!gT zVt@AfYCzjjsMEGi=rDQHo0yc;HqoRNnNFeWZgcm?f;cp(6CNylj36DoL(?TS7eU#+ z7&mfr#y))+CJOXQKUMZ7QIdS9@#-}7y2K1{8)cCt0~-X0O!O?Qx#E4Og+;A2SjalQ zs7r?qn0H044=sDN$SRG$arw~n=+T_DNdSrarmu)V6@|?1-ZB#hRn`uilTGPJ@fqEy zGt(f0B+^JDP&f=r{#Y_wi#AVDf-y!RIXU^0jXsFpf>=Ji*TeqSY!H~AMbJdCGLhC) zn7Rx+sXw6uYj;WRYrLd^5IZq@6JI1C^YkgnedZEYy<&4(z%Q$5yv#Boo{AH8n$a zhb4Y3PWdr269&?V%uI$xMcUrMzl=;w<_nm*qr=c3Rl@i5wWB;e-`t7D&c-mcQl7x! zZWB`UGcw=Y2=}~wzrfLx=uet<;m3~=8I~ZRuzvMQUQdr+yTV|ATf1Uuomr__nDf=X zZ3WYJtHp_ri(}SQAPjv+Y+0=fH4krOP@S&=zZ-t1jW1o@}z;xk8 z(Nz1co&El^HK^NrhVHa-_;&88vTU>_J33=%{if;BEY*J#1n59=07jrGQ#IP>@u#3A z;!q+E1Rj3ZJ+!4bq9F8PXJ@yMgZL;>&gYA0%_Kbi8?S=XGM~dnQZQ!yBSgcZhY96H zrWnU;k)qy`rX&&xlDyA%(a1Hhi5CWkmg(`Gb%m(HKi-7Z!LKGRP_B8@`7&hdDy5n= z`OIxqxiVfX@OX1p(mQu>0Ai*v_cTMiw4qRt3~NBvr9oBy0)r>w3p~V0SCm=An6@3n)>@z!|o-$HvDK z|3D2ZMJkLE5loMKl6R^ez@Zz%S$&mbeoqH5`Bb){Ei21q&VP)hWS2tjShfFtGE+$z zzCR$P#uktu+#!w)cX!lWN1XU%K-r=s{|j?)Akf@q#3b#{6cZCuJ~gCxuMXRmI$nGtnH+-h z+GEi!*X=AP<|fG`1>MBdTb?28JYc=fGvAi2I<$B(rs$;eoJCyR6_bc~p!XR@O-+sD z=eH`-ye})I5ic1eL~TDmtfJ|8`0VJ*Yr=hNCd)G1p2MMz4C3^Mj?7;!w|Ly%JqmuW zlIEW^Ft%z?*|fpXda>Jr^1noFZEwFgVV%|*XhH@acv8rdGxeEX{M$(vG{Zw+x(ei@ zmfXb22}8-?Fi`vo-YVrTH*C?a8%M=Hv9MqVH7H^J$KsD?>!SFZ;ZsvnHr_gn=7acz z#W?0eCdVhVMWN12VV^$>WlQ?f;P^{(&pYTops|btm6aj>_Uz+hqpGwB)vWp0Cf5y< zft8-je~nn?W11plq}N)4A{l8I7$!ks_x$PXW-2XaRFswX_BnF{R#6YIwMhAgd5F9X zGmwdadS6(a^fjHtXg8=l?Rc0Sm%hk6E9!5cLVloEy4eh(=FwgP`)~I^5~pBEWo+F6 zSf2ncyMurJN91#cJTy_u8Y}@%!bq1RkGC~-bV@SXRd4F{R-*V`bS+6;W5vZ(&+I<9$;-V|eNfLa5n-6% z2(}&uGRF;p92eS*sE*oR$@pexaqr*meB)VhmIg@h{uzkk$9~qh#cHhw#>O%)b@+(| z^IQgqzuj~Sk(J;swEM-3TrJAPCq9k^^^`q{IItKBRXYe}e0Tdr=Huf7da3$l4PdpwWDop%^}n;dD#K4s#DYA8SHZ z&1!riV4W4R7R#C))JH1~axJ)RYnM$$lIR%6fIVA@zV{XVyx}C+a-Dt8Y9M)^KU0+H zR4IUb2CJ{Hg>CuaXtD50jB(_Tcx=Z$^WYu2u5kubqmwp%drJ6 z?Fo40g!Qd<-l=TQxqHEOuPX0;^z7iX?Ke^a%XT<13TA^5`4Xcw6D@Ur&VT&CUe0d} z1GjOVF1^L@>O)l@?bD~$wzgf(nxX1OGD8fEV?TdJcZc2KoUe|oP1#=$$7ee|xbY)A zDZq+cuTpc(fFdj^=!;{k03C69lMQ(|>uhRfRu%+!k&YOi-3|1QKB z z?n?eq1XP>p-IM$Z^C;2L3itnbJZAip*Zo0aw2bs8@(s^~*8T9go!%dHcAz2lM;`yp zD=7&xjFV$S&5uDaiScyD?B-i1ze`+CoRtz`Wn+Zl&#s4&}MO{@N!ufrzjG$B79)Y2d3tBk&)TxUTw@QS0TEL_?njX|@vq?Uz(nBFK5Pq7*xj#u*R&i|?7+6# z+|r_n#SW&LXhtheZdah{ZVoqwyT{D>MC3nkFF#N)xLi{p7J1jXlmVeb;cP5?e(=f# zuT7fvjSbjS781v?7{)-X3*?>tq?)Yd)~|1{BDS(pqC zC}~H#WXlkUW*H5CDOo<)#x7%RY)A;ShGhI5s*#cRDA8YgqG(HeKDx+#(ZQ?386dv! zlXCO)w91~Vw4AmOcATuV653fa9R$fyK8ul%rG z-wfS zihugoZyr38Im?Zuh6@RcF~t1anQu7>#lPpb#}4cOA!EM11`%f*07RqOVkmX{p~KJ9 z^zP;K#|)$`^Rb{rnHGH{~>1(fawV0*Z#)}M`m8-?ZJV<+e}s9wE# z)l&az?w^5{)`S(%MRzxdNqrs1n*-=jS^_jqE*5XDrA0+VE`5^*p3CuM<&dZEeCjoz zR;uu_H9ZPZV|fQq`Cyw4nscrVwi!fE6ciMmX$!_hN7uF;jjKG)d2@aC4ropY)8etW=xJvni)8eHi`H$%#zn^WJ5NLc-rqk|u&&4Z6fD_m&JfSI1Bvb?b<*n&sfl0^t z=HnmRl`XrFvMKB%9}>PaA`m-fK6a0(8=qPkWS5bb4=v?XcWi&hRY?O5HdulRi4?fN zlsJ*N-0Qw+Yic@s0(2uy%F@ib;GjXt01Fmx5XbRo6+n|pP(&nodMoap^z{~q ziEeaUT@Mxe3vJSfI6?uLND(CNr=#^W<1b}jzW58bIfyWTDle$mmS(|x-0|2UlX+9k zQ^EX7Nw}?EzVoBfT(-LT|=9N@^hcn-_p&sqG z&*oVs2JSU+N4ZD`FhCAWaS;>|wH2G*Id|?pa#@>tyxX`+4HyIArWDvVrX)2WAOQff z0qyHu&-S@i^MS-+j--!pr4fPBj~_8({~e1bfcl0wI1kaoN>mJL6KUPQm5N7lB(ui1 zE-o%kq)&djzWJ}ob<-GfDlkB;F31j-VHKvQUGQ3sp`CwyGJk_i!y^sD0fqC@$9|jO zOqN!r!8-p==F@ZVP=U$qSpY(gQ0)59P1&t@y?5rvg<}E+GB}26NYPp4f2YFQrQtot5mn3wu_qprZ=>Ig-$ zbW26Ws~IgY>}^5w`vTB(G`PTZaDiGBo5o(tp)qli|NeV( z@H_=R8V39rt5J5YB2Ky?4eJJ#b`_iBe2ot~6%7mLt5t8Vwi^Jy7|jWXqa3amOIoRb zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4 z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/contract_sale_payment_mode/static/description/index.html b/contract_sale_payment_mode/static/description/index.html new file mode 100644 index 00000000..058c25aa --- /dev/null +++ b/contract_sale_payment_mode/static/description/index.html @@ -0,0 +1,419 @@ + + + + + + +Contract Sale Payment Mode + + + +
+

Contract Sale Payment Mode

+ + +

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

+

This module manages the payment mode from sale order to contract.

+

Table of contents

+ +
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

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.

+

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/setup/contract_sale_payment_mode/odoo/addons/contract_sale_payment_mode b/setup/contract_sale_payment_mode/odoo/addons/contract_sale_payment_mode new file mode 120000 index 00000000..68f9e65c --- /dev/null +++ b/setup/contract_sale_payment_mode/odoo/addons/contract_sale_payment_mode @@ -0,0 +1 @@ +../../../../contract_sale_payment_mode \ No newline at end of file diff --git a/setup/contract_sale_payment_mode/setup.py b/setup/contract_sale_payment_mode/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/contract_sale_payment_mode/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From 6e9eeed1790b64650c953517e8ac41675463273d Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Thu, 10 Jan 2019 17:03:30 +0100 Subject: [PATCH 53/73] [IMP] - Add unit test --- product_contract/models/contract_line.py | 20 +++++++++++++ product_contract/tests/test_sale_order.py | 35 +++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/product_contract/models/contract_line.py b/product_contract/models/contract_line.py index 0a7a4015..ca5cd9a5 100644 --- a/product_contract/models/contract_line.py +++ b/product_contract/models/contract_line.py @@ -23,3 +23,23 @@ class AccountAnalyticInvoiceLine(models.Model): if self.sale_order_line_id and res: res['sale_line_ids'] = [(6, 0, [self.sale_order_line_id.id])] return res + + @api.onchange('product_id') + def _onchange_product_id_recurring_info(self): + for rec in self: + rec.date_start = fields.Date.today() + if rec.product_id.is_contract: + rec.recurring_rule_type = rec.product_id.recurring_rule_type + rec.recurring_invoicing_type = ( + rec.product_id.recurring_invoicing_type + ) + rec.recurring_interval = rec.product_id.recurring_interval + rec.is_auto_renew = rec.product_id.is_auto_renew + rec.auto_renew_interval = rec.product_id.auto_renew_interval + rec.auto_renew_rule_type = rec.product_id.auto_renew_rule_type + rec.termination_notice_interval = ( + rec.product_id.termination_notice_interval + ) + rec.termination_notice_rule_type = ( + rec.product_id.termination_notice_rule_type + ) diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index d3c29572..a13aa121 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -222,3 +222,38 @@ class TestSaleOrder(TransactionCase): self.assertEqual( new_contract_line.predecessor_contract_line_id, self.contract_line ) + + def test_onchange_product_id_recurring_info(self): + self.product2.write( + { + 'recurring_rule_type': 'monthly', + 'recurring_invoicing_type': 'pre-paid', + 'recurring_interval': '2', + 'is_auto_renew': True, + 'auto_renew_interval': '6', + 'auto_renew_rule_type': 'monthly', + 'termination_notice_interval': '6', + 'termination_notice_rule_type': 'weekly', + } + ) + self.contract_line.write( + { + 'date_start': Date.today(), + 'date_end': Date.today() + relativedelta(years=1), + 'recurring_next_date': Date.today(), + 'product_id': self.product2.id, + } + ) + self.contract_line._onchange_product_id_recurring_info() + self.assertEqual(self.contract_line.recurring_rule_type, 'monthly') + self.assertEqual( + self.contract_line.recurring_invoicing_type, 'pre-paid' + ) + self.assertEqual(self.contract_line.recurring_interval, 2) + self.assertEqual(self.contract_line.is_auto_renew, True) + self.assertEqual(self.contract_line.auto_renew_interval, 6) + self.assertEqual(self.contract_line.auto_renew_rule_type, 'monthly') + self.assertEqual(self.contract_line.termination_notice_interval, 6) + self.assertEqual( + self.contract_line.termination_notice_rule_type, 'weekly' + ) From b3db76f2de2ccbe57e84623f1b321c51a2669a4d Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Tue, 15 Jan 2019 13:37:17 +0100 Subject: [PATCH 54/73] [REF] - predecessor_contract_line set in create process --- product_contract/models/sale_order_line.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 61094b2b..a99f96d3 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -101,7 +101,9 @@ class SaleOrderLine(models.Model): ) @api.multi - def _prepare_contract_line_values(self, contract): + def _prepare_contract_line_values( + self, contract, predecessor_contract_line + ): self.ensure_one() recurring_next_date = self.env[ 'account.analytic.invoice.line' @@ -138,6 +140,7 @@ class SaleOrderLine(models.Model): 'termination_notice_rule_type': termination_notice_rule_type, 'contract_id': contract.id, 'sale_order_line_id': self.id, + 'predecessor_contract_line_id': predecessor_contract_line.id, } @api.multi @@ -145,20 +148,19 @@ class SaleOrderLine(models.Model): contract_line_env = self.env['account.analytic.invoice.line'] contract_line = self.env['account.analytic.invoice.line'] for rec in self: - new_contract_line = contract_line_env.create( - rec._prepare_contract_line_values(contract) - ) - contract_line |= new_contract_line if rec.contract_line_id: rec.contract_line_id.stop( rec.date_start - relativedelta(days=1) ) + new_contract_line = contract_line_env.create( + rec._prepare_contract_line_values(contract, + rec.contract_line_id) + ) + if rec.contract_line_id: rec.contract_line_id.successor_contract_line_id = ( new_contract_line ) - new_contract_line.predecessor_contract_line_id = ( - self.contract_line_id.id - ) + contract_line |= new_contract_line return contract_line @api.constrains('contract_id') From df451582fc638b7eb574d32d589469d700d83258 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 21 Jan 2019 19:02:48 +0100 Subject: [PATCH 55/73] [IMP] - Simplify sale order line creation for contract product --- product_contract/__manifest__.py | 4 +- product_contract/models/contract_line.py | 6 +- product_contract/models/product_template.py | 20 +---- product_contract/models/sale_order_line.py | 82 ++++++++++----------- product_contract/tests/test_sale_order.py | 19 ++--- product_contract/views/product_template.xml | 18 +---- product_contract/views/sale_order.xml | 14 +--- 7 files changed, 59 insertions(+), 104 deletions(-) diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py index aa0f3b74..5f112894 100644 --- a/product_contract/__manifest__.py +++ b/product_contract/__manifest__.py @@ -7,7 +7,9 @@ 'version': '12.0.1.0.0', 'category': 'Contract Management', 'license': 'AGPL-3', - 'author': "LasLabs, " "ACSONE SA/NV, " "Odoo Community Association (OCA)", + 'author': "LasLabs, " + "ACSONE SA/NV, " + "Odoo Community Association (OCA)", 'website': 'https://github.com/oca/contract', 'depends': ['product', 'contract_sale'], 'data': [ diff --git a/product_contract/models/contract_line.py b/product_contract/models/contract_line.py index ca5cd9a5..1e0cd4fe 100644 --- a/product_contract/models/contract_line.py +++ b/product_contract/models/contract_line.py @@ -33,10 +33,10 @@ class AccountAnalyticInvoiceLine(models.Model): rec.recurring_invoicing_type = ( rec.product_id.recurring_invoicing_type ) - rec.recurring_interval = rec.product_id.recurring_interval + rec.recurring_interval = 1 rec.is_auto_renew = rec.product_id.is_auto_renew - rec.auto_renew_interval = rec.product_id.auto_renew_interval - rec.auto_renew_rule_type = rec.product_id.auto_renew_rule_type + rec.auto_renew_interval = rec.product_id.default_qty + rec.auto_renew_rule_type = rec.product_id.recurring_rule_type rec.termination_notice_interval = ( rec.product_id.termination_notice_interval ) diff --git a/product_contract/models/product_template.py b/product_contract/models/product_template.py index d3fd0b55..f73cc3af 100644 --- a/product_contract/models/product_template.py +++ b/product_contract/models/product_template.py @@ -13,7 +13,7 @@ class ProductTemplate(models.Model): contract_template_id = fields.Many2one( comodel_name='account.analytic.contract', string='Contract Template' ) - + default_qty = fields.Integer(string="Default Quantity") recurring_rule_type = fields.Selection( [ ('daily', 'Day(s)'), @@ -23,7 +23,7 @@ class ProductTemplate(models.Model): ('yearly', 'Year(s)'), ], default='monthly', - string='Recurrence', + string='Invoice Every', help="Specify Interval for automatic invoice generation.", ) recurring_invoicing_type = fields.Selection( @@ -32,23 +32,7 @@ class ProductTemplate(models.Model): string='Invoicing type', help="Specify if process date is 'from' or 'to' invoicing date", ) - recurring_interval = fields.Integer( - default=1, - string='Repeat Every', - help="Repeat every (Days/Week/Month/Year)", - ) is_auto_renew = fields.Boolean(string="Auto Renew", default=False) - auto_renew_interval = fields.Integer( - default=1, - string='Renew Every', - help="Renew every (Days/Week/Month/Year)", - ) - auto_renew_rule_type = fields.Selection( - [('monthly', 'Month(s)'), ('yearly', 'Year(s)')], - default='yearly', - string='Renewal type', - help="Specify Interval for automatic renewal.", - ) termination_notice_interval = fields.Integer( default=1, string='Termination Notice Before' ) diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index a99f96d3..049f778c 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -31,8 +31,7 @@ class SaleOrderLine(models.Model): ('yearly', 'Year(s)'), ], default='monthly', - string='Recurrence', - help="Specify Interval for automatic invoice generation.", + string='Invoice Every', copy=False, ) recurring_invoicing_type = fields.Selection( @@ -42,12 +41,6 @@ class SaleOrderLine(models.Model): help="Specify if process date is 'from' or 'to' invoicing date", copy=False, ) - recurring_interval = fields.Integer( - default=1, - string='Repeat Every', - help="Repeat every (Days/Week/Month/Year)", - copy=False, - ) date_start = fields.Date(string='Date Start') date_end = fields.Date(string='Date End') @@ -57,48 +50,42 @@ class SaleOrderLine(models.Model): required=False, copy=False, ) - is_auto_renew = fields.Boolean( - string="Auto Renew", related="product_id.is_auto_renew", readonly=True - ) @api.onchange('product_id') def onchange_product(self): contract_line_env = self.env['account.analytic.invoice.line'] for rec in self: if rec.product_id.is_contract: + rec.product_uom_qty = rec.product_id.default_qty rec.recurring_rule_type = rec.product_id.recurring_rule_type rec.recurring_invoicing_type = ( rec.product_id.recurring_invoicing_type ) - rec.recurring_interval = rec.product_id.recurring_interval rec.date_start = rec.date_start or fields.Date.today() - if rec.product_id.is_auto_renew: - rec.date_end = ( - rec.date_start - + contract_line_env.get_relative_delta( - rec.product_id.auto_renew_rule_type, - rec.product_id.auto_renew_interval, - ) - - relativedelta(days=1) + rec.date_end = ( + rec.date_start + + contract_line_env.get_relative_delta( + rec.product_id.recurring_rule_type, + int(rec.product_uom_qty), ) + - relativedelta(days=1) + ) - @api.onchange('date_start') + @api.onchange('date_start', 'product_uom_qty', 'recurring_rule_type') def onchange_date_start(self): for rec in self: - if rec.product_id.is_auto_renew: - if not rec.date_start: - rec.date_end = False - else: - rec.date_end = ( - rec.date_start - + self.env[ - 'account.analytic.invoice.line' - ].get_relative_delta( - rec.product_id.auto_renew_rule_type, - rec.product_id.auto_renew_interval, - ) - - relativedelta(days=1) + if not rec.date_start: + rec.date_end = False + else: + rec.date_end = ( + rec.date_start + + self.env[ + 'account.analytic.invoice.line' + ].get_relative_delta( + rec.recurring_rule_type, int(rec.product_uom_qty) ) + - relativedelta(days=1) + ) @api.multi def _prepare_contract_line_values( @@ -111,7 +98,7 @@ class SaleOrderLine(models.Model): self.date_start or fields.Date.today(), self.recurring_invoicing_type, self.recurring_rule_type, - self.recurring_interval, + int(self.product_uom_qty), ) termination_notice_interval = ( self.product_id.termination_notice_interval @@ -123,19 +110,31 @@ class SaleOrderLine(models.Model): 'sequence': self.sequence, 'product_id': self.product_id.id, 'name': self.name, - 'quantity': self.product_uom_qty, + # The quantity on the generated contract line is 1, as it + # correspond to the most common use cases: + # - quantity on the SO line = number of periods sold and unit + # price the price of one period, so the + # total amount of the SO corresponds to the planned value + # of the contract; in this case the quantity on the contract + # line must be 1 + # - quantity on the SO line = number of hours sold, + # automatic invoicing of the actual hours through a variable + # quantity formula, in which case the quantity on the contract + # line is not used + # Other use cases are easy to implement by overriding this method. + 'quantity': 1.0, 'uom_id': self.product_uom.id, 'price_unit': self.price_unit, 'discount': self.discount, 'date_end': self.date_end, 'date_start': self.date_start or fields.Date.today(), 'recurring_next_date': recurring_next_date, - 'recurring_interval': self.recurring_interval, + 'recurring_interval': 1, 'recurring_invoicing_type': self.recurring_invoicing_type, 'recurring_rule_type': self.recurring_rule_type, 'is_auto_renew': self.product_id.is_auto_renew, - 'auto_renew_interval': self.product_id.auto_renew_interval, - 'auto_renew_rule_type': self.product_id.auto_renew_rule_type, + 'auto_renew_interval': self.product_uom_qty, + 'auto_renew_rule_type': self.product_id.recurring_rule_type, 'termination_notice_interval': termination_notice_interval, 'termination_notice_rule_type': termination_notice_rule_type, 'contract_id': contract.id, @@ -153,8 +152,9 @@ class SaleOrderLine(models.Model): rec.date_start - relativedelta(days=1) ) new_contract_line = contract_line_env.create( - rec._prepare_contract_line_values(contract, - rec.contract_line_id) + rec._prepare_contract_line_values( + contract, rec.contract_line_id + ) ) if rec.contract_line_id: rec.contract_line_id.successor_contract_line_id = ( diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index a13aa121..33180659 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -41,7 +41,7 @@ class TestSaleOrder(TransactionCase): self.product1.write( { 'is_contract': True, - 'is_auto_renew': True, + 'default_qty': 12, 'contract_template_id': self.contract_template1.id, } ) @@ -55,6 +55,7 @@ class TestSaleOrder(TransactionCase): lambda l: l.product_id == self.product1 ) self.order_line1.date_start = '2018-01-01' + self.order_line1.product_uom_qty = 12 pricelist = self.sale.partner_id.property_product_pricelist.id self.contract = self.env["account.analytic.account"].create( { @@ -91,10 +92,6 @@ class TestSaleOrder(TransactionCase): contract""" self.assertTrue(self.sale.is_contract) - def test_action_confirm_auto_renew_without_date_end(self): - with self.assertRaises(ValidationError): - self.sale.action_confirm() - def test_action_confirm(self): """ It should create a contract for each contract template used in order_line """ @@ -122,10 +119,6 @@ class TestSaleOrder(TransactionCase): self.order_line1.recurring_rule_type, self.product1.recurring_rule_type, ) - self.assertEqual( - self.order_line1.recurring_interval, - self.product1.recurring_interval, - ) self.assertEqual( self.order_line1.recurring_invoicing_type, self.product1.recurring_invoicing_type, @@ -228,10 +221,8 @@ class TestSaleOrder(TransactionCase): { 'recurring_rule_type': 'monthly', 'recurring_invoicing_type': 'pre-paid', - 'recurring_interval': '2', 'is_auto_renew': True, - 'auto_renew_interval': '6', - 'auto_renew_rule_type': 'monthly', + 'default_qty': 12, 'termination_notice_interval': '6', 'termination_notice_rule_type': 'weekly', } @@ -249,9 +240,9 @@ class TestSaleOrder(TransactionCase): self.assertEqual( self.contract_line.recurring_invoicing_type, 'pre-paid' ) - self.assertEqual(self.contract_line.recurring_interval, 2) + self.assertEqual(self.contract_line.recurring_interval, 1) self.assertEqual(self.contract_line.is_auto_renew, True) - self.assertEqual(self.contract_line.auto_renew_interval, 6) + self.assertEqual(self.contract_line.auto_renew_interval, 12) self.assertEqual(self.contract_line.auto_renew_rule_type, 'monthly') self.assertEqual(self.contract_line.termination_notice_interval, 6) self.assertEqual( diff --git a/product_contract/views/product_template.xml b/product_contract/views/product_template.xml index dcc54cae..fd26d555 100644 --- a/product_contract/views/product_template.xml +++ b/product_contract/views/product_template.xml @@ -29,30 +29,16 @@ - + -