diff --git a/contract_sale_generation/README.rst b/contract_sale_generation/README.rst
index 1ad37d085..b28440f5e 100644
--- a/contract_sale_generation/README.rst
+++ b/contract_sale_generation/README.rst
@@ -14,13 +14,13 @@ Contracts Management - Recurring Sales
: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/14.0/contract_sale_generation
+ :target: https://github.com/OCA/contract/tree/15.0/contract_sale_generation
:alt: OCA/contract
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract_sale_generation
+ :target: https://translation.odoo-community.org/projects/contract-15-0/contract-15-0-contract_sale_generation
: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/14.0
+ :target: https://runbot.odoo-community.org/runbot/110/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -50,7 +50,7 @@ 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -84,6 +84,6 @@ 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.
+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_generation/__manifest__.py b/contract_sale_generation/__manifest__.py
index 74af8013d..cc3680541 100644
--- a/contract_sale_generation/__manifest__.py
+++ b/contract_sale_generation/__manifest__.py
@@ -5,7 +5,7 @@
{
"name": "Contracts Management - Recurring Sales",
- "version": "14.0.1.0.1",
+ "version": "15.0.1.0.2",
"category": "Contract Management",
"license": "AGPL-3",
"author": "ACSONE SA/NV, PESOL, Odoo Community Association (OCA)",
diff --git a/contract_sale_generation/i18n/contract_sale_generation.pot b/contract_sale_generation/i18n/contract_sale_generation.pot
index 534e61d7c..d268f17e3 100644
--- a/contract_sale_generation/i18n/contract_sale_generation.pot
+++ b/contract_sale_generation/i18n/contract_sale_generation.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 14.0\n"
+"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -43,17 +43,8 @@ msgstr ""
#: code:addons/contract_sale_generation/models/contract.py:0
#, python-format
msgid ""
-"Contract manually sale order: Sale Order"
-msgstr ""
-
-#. module: contract_sale_generation
-#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_abstract_contract__display_name
-#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_contract__display_name
-#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_line__display_name
-#: model:ir.model.fields,field_description:contract_sale_generation.field_sale_order__display_name
-#: model:ir.model.fields,field_description:contract_sale_generation.field_sale_order_line__display_name
-msgid "Display Name"
+"Contract manually sale order: Sale Order"
msgstr ""
#. module: contract_sale_generation
@@ -63,24 +54,6 @@ msgstr ""
msgid "Generate Recurring sales from Contracts"
msgstr ""
-#. module: contract_sale_generation
-#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_abstract_contract__id
-#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_contract__id
-#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_line__id
-#: model:ir.model.fields,field_description:contract_sale_generation.field_sale_order__id
-#: model:ir.model.fields,field_description:contract_sale_generation.field_sale_order_line__id
-msgid "ID"
-msgstr ""
-
-#. module: contract_sale_generation
-#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_abstract_contract____last_update
-#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_contract____last_update
-#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_line____last_update
-#: model:ir.model.fields,field_description:contract_sale_generation.field_sale_order____last_update
-#: model:ir.model.fields,field_description:contract_sale_generation.field_sale_order_line____last_update
-msgid "Last Modified on"
-msgstr ""
-
#. module: contract_sale_generation
#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_abstract_contract__sale_autoconfirm
#: model:ir.model.fields,field_description:contract_sale_generation.field_contract_contract__sale_autoconfirm
diff --git a/contract_sale_generation/models/abstract_contract.py b/contract_sale_generation/models/abstract_contract.py
index 84f8228b4..b5d7dcd62 100644
--- a/contract_sale_generation/models/abstract_contract.py
+++ b/contract_sale_generation/models/abstract_contract.py
@@ -8,7 +8,7 @@ from odoo import api, fields, models
class ContractAbstractContract(models.AbstractModel):
_inherit = "contract.abstract.contract"
- sale_autoconfirm = fields.Boolean(string="Sale Autoconfirm")
+ sale_autoconfirm = fields.Boolean()
@api.model
def _selection_generation_type(self):
diff --git a/contract_sale_generation/models/contract.py b/contract_sale_generation/models/contract.py
index f15d2a694..80ba905b7 100644
--- a/contract_sale_generation/models/contract.py
+++ b/contract_sale_generation/models/contract.py
@@ -75,11 +75,11 @@ class ContractContract(models.Model):
self.message_post(
body=_(
"Contract manually sale order: "
- ''
+ ''
"Sale Order"
""
)
- % (sale_rec._name, sale_rec.id)
+ % {"model": sale_rec._name, "id": sale_rec.id}
)
return sales
diff --git a/contract_sale_generation/models/contract_line.py b/contract_sale_generation/models/contract_line.py
index a3005b8b8..ebbb32749 100644
--- a/contract_sale_generation/models/contract_line.py
+++ b/contract_sale_generation/models/contract_line.py
@@ -25,7 +25,7 @@ class ContractLine(models.Model):
dates = self._get_period_to_invoice(
self.last_date_invoiced, self.recurring_next_date
)
- sale_line_vals = self._prepare_sale_line_vals(dates, order_id)
+ sale_line_vals = self._prepare_sale_line_vals(dates, order_id=order_id)
order_line = (
self.env["sale.order.line"]
diff --git a/contract_sale_generation/static/description/index.html b/contract_sale_generation/static/description/index.html
index 6ecc3866d..68d7d9328 100644
--- a/contract_sale_generation/static/description/index.html
+++ b/contract_sale_generation/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module extends functionality of contracts to be able to generate sales
orders instead of invoices.
Table of contents
@@ -400,7 +400,7 @@ orders instead of invoices.
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -428,7 +428,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
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.
+
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_generation/tests/common.py b/contract_sale_generation/tests/common.py
index cea97f152..fe100b02f 100644
--- a/contract_sale_generation/tests/common.py
+++ b/contract_sale_generation/tests/common.py
@@ -24,6 +24,12 @@ class ContractSaleCommon:
"name": "Contracts",
}
)
+ cls.payment_term_id = cls.env.ref(
+ "account.account_payment_term_end_following_month"
+ )
+ cls.fiscal_position_id = cls.env["account.fiscal.position"].create(
+ {"name": "Contracts"}
+ )
contract_date = "2020-01-15"
cls.pricelist = cls.env["product.pricelist"].create(
{
@@ -34,6 +40,8 @@ class ContractSaleCommon:
{
"name": "partner test contract",
"property_product_pricelist": cls.pricelist.id,
+ "property_payment_term_id": cls.payment_term_id.id,
+ "property_account_position_id": cls.fiscal_position_id.id,
}
)
cls.product_1 = cls.env.ref("product.product_product_1")
diff --git a/contract_sale_generation/tests/test_contract_sale.py b/contract_sale_generation/tests/test_contract_sale.py
index 51ae1ee90..7f07fad3d 100644
--- a/contract_sale_generation/tests/test_contract_sale.py
+++ b/contract_sale_generation/tests/test_contract_sale.py
@@ -3,15 +3,10 @@
# Copyright 2017 Angel Moya
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import fields
from odoo.exceptions import ValidationError
from odoo.tests.common import SavepointCase
-from .common import ContractSaleCommon
-
-
-def to_date(date):
- return fields.Date.to_date(date)
+from .common import ContractSaleCommon, to_date
class TestContractSale(ContractSaleCommon, SavepointCase):
@@ -96,6 +91,11 @@ class TestContractSale(ContractSaleCommon, SavepointCase):
self.contract_line.recurring_invoicing_type = "post-paid"
self.contract_line.date_end = "2020-03-15"
self.contract_line._onchange_is_auto_renew()
+ # If we do not recompute recurring_next_date
+ # then it maintains it's 'old' value.
+ # TODO: Research that
+ recurring_next_date = self.contract_line.recurring_next_date
+ self.assertGreaterEqual(recurring_next_date, self.contract_line.date_start)
contracts = self.contract2
for _i in range(10):
contracts |= self.contract.copy({"generation_type": "sale"})
@@ -108,7 +108,43 @@ class TestContractSale(ContractSaleCommon, SavepointCase):
len(order_lines),
)
- def test_contract_sale_analytic(self):
+ def test_contract_sale_analytic_payment_term_fiscal_position(self):
+ # Call onchange in order to retrieve
+ # payment term and fiscal position
+ self.contract._onchange_partner_id()
orders = self.env["sale.order"].browse()
orders |= self.contract.recurring_create_sale()
self.assertEqual(self.analytic_account, orders.mapped("analytic_account_id"))
+ self.assertEqual(self.payment_term_id, orders.mapped("payment_term_id"))
+ self.assertEqual(self.fiscal_position_id, orders.mapped("fiscal_position_id"))
+
+ def test_recurring_method_retrieval(self):
+ self.assertNotEqual(
+ self.contract._get_recurring_create_func(create_type="sale"),
+ self.contract._get_recurring_create_func(create_type="invoice"),
+ )
+
+ def test__prepare_recurring_sales_values_no_date_ref(self):
+ self.contract.recurring_next_date = False
+ self.assertEqual(self.contract._prepare_recurring_sales_values(), [])
+
+ def test__prepare_recurring_sales_values_no_contract_lines(self):
+ a_contract_with_no_lines = self.env["contract.contract"].create(
+ {
+ "name": "No lines Contract",
+ "partner_id": self.partner.id,
+ "generation_type": "sale",
+ "date_start": "2020-01-15",
+ }
+ )
+ self.assertEqual(a_contract_with_no_lines._prepare_recurring_sales_values(), [])
+
+ def test__prepare_sale_line_vals_with_order_id(self):
+ order = self.contract.recurring_create_sale()[0]
+ recurring_next_date = self.contract.recurring_next_date
+ date_start = self.contract.date_start
+ date_end = self.contract.date_end
+ dates = [date_start, date_end, recurring_next_date]
+ for line in self.contract._get_lines_to_invoice(recurring_next_date):
+ line_vals = line._prepare_sale_line_vals(dates, order)
+ self.assertEqual(line_vals["order_id"], order.id)
diff --git a/contract_sale_generation/tests/test_contract_sale_recurrency.py b/contract_sale_generation/tests/test_contract_sale_recurrency.py
index 63ffd539b..16572a55c 100644
--- a/contract_sale_generation/tests/test_contract_sale_recurrency.py
+++ b/contract_sale_generation/tests/test_contract_sale_recurrency.py
@@ -9,11 +9,6 @@ from odoo.tests.common import SavepointCase
from .common import ContractSaleCommon
-
-def to_date(date):
- return fields.Date.to_date(date)
-
-
today = "2020-01-15"