mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG] contract_sale_generation: Migration to 15.0
This commit is contained in:
committed by
Jesús Feliciano Valdez Cruz [Vauxoo]
parent
42b907c7d2
commit
0730d45f09
@@ -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 <https://github.com/OCA/contract/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 <https://github.com/OCA/contract/issues/new?body=module:%20contract_sale_generation%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20contract_sale_generation%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
@@ -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 <https://github.com/OCA/contract/tree/14.0/contract_sale_generation>`_ project on GitHub.
|
||||
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/15.0/contract_sale_generation>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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: <a href=\"#\" data-oe-model=\"%s\" data-oe-"
|
||||
"id=\"%s\">Sale Order</a>"
|
||||
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: <a href=\"#\" data-oe-model=\"%(model)s\" "
|
||||
"data-oe-id=\"%(id)s\">Sale Order</a>"
|
||||
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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -75,11 +75,11 @@ class ContractContract(models.Model):
|
||||
self.message_post(
|
||||
body=_(
|
||||
"Contract manually sale order: "
|
||||
'<a href="#" data-oe-model="%s" data-oe-id="%s">'
|
||||
'<a href="#" data-oe-model="%(model)s" data-oe-id="%(id)s">'
|
||||
"Sale Order"
|
||||
"</a>"
|
||||
)
|
||||
% (sale_rec._name, sale_rec.id)
|
||||
% {"model": sale_rec._name, "id": sale_rec.id}
|
||||
)
|
||||
return sales
|
||||
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -367,7 +367,7 @@ ul.auto-toc {
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/contract/tree/14.0/contract_sale_generation"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract_sale_generation"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/110/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/contract/tree/15.0/contract_sale_generation"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/contract-15-0/contract-15-0-contract_sale_generation"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/110/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module extends functionality of contracts to be able to generate sales
|
||||
orders instead of invoices.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
@@ -400,7 +400,7 @@ orders instead of invoices.</p>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/contract/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/contract/issues/new?body=module:%20contract_sale_generation%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/contract/issues/new?body=module:%20contract_sale_generation%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
@@ -428,7 +428,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/14.0/contract_sale_generation">OCA/contract</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/15.0/contract_sale_generation">OCA/contract</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -3,15 +3,10 @@
|
||||
# Copyright 2017 Angel Moya <angel.moya@pesol.es>
|
||||
# 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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user