|
@ -1,10 +1,10 @@ |
|
|
# Copyright 2019 ACSONE SA/NV |
|
|
# Copyright 2019 ACSONE SA/NV |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|
|
|
|
|
|
|
|
|
|
|
from datetime import date |
|
|
from dateutil.relativedelta import relativedelta |
|
|
from dateutil.relativedelta import relativedelta |
|
|
|
|
|
|
|
|
from odoo.addons.contract.tests.test_contract import TestContractBase |
|
|
from odoo.addons.contract.tests.test_contract import TestContractBase |
|
|
from odoo.fields import Date |
|
|
|
|
|
from odoo.tools import mute_logger |
|
|
from odoo.tools import mute_logger |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -15,21 +15,21 @@ class TestContractLineForecastPeriod(TestContractBase): |
|
|
context=dict(self.env.context, test_queue_job_no_delay=True) |
|
|
context=dict(self.env.context, test_queue_job_no_delay=True) |
|
|
) |
|
|
) |
|
|
super(TestContractLineForecastPeriod, self).setUp() |
|
|
super(TestContractLineForecastPeriod, self).setUp() |
|
|
self.line_vals["date_start"] = Date.context_today(self.acct_line) |
|
|
|
|
|
self.line_vals["recurring_next_date"] = Date.context_today( |
|
|
|
|
|
self.acct_line |
|
|
|
|
|
) |
|
|
|
|
|
self.acct_line = self.env["account.analytic.invoice.line"].create( |
|
|
|
|
|
self.line_vals |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
self.this_year = date.today().year |
|
|
|
|
|
self.line_vals["date_start"] = date.today() |
|
|
|
|
|
self.line_vals["recurring_next_date"] = date.today() |
|
|
|
|
|
self.acct_line = self.env["contract.line"].create(self.line_vals) |
|
|
|
|
|
|
|
|
@mute_logger("odoo.addons.queue_job.models.base") |
|
|
@mute_logger("odoo.addons.queue_job.models.base") |
|
|
def test_forecast_period_creation(self): |
|
|
def test_forecast_period_creation(self): |
|
|
self.acct_line.write( |
|
|
self.acct_line.write( |
|
|
{ |
|
|
{ |
|
|
'date_start': "2019-01-01", |
|
|
|
|
|
'recurring_next_date': "2019-01-01", |
|
|
|
|
|
'date_end': "2019-12-31", |
|
|
|
|
|
|
|
|
'date_start': "{this_year}-01-01".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'recurring_next_date': "{this_year}-01-01".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'date_end': "{this_year}-12-31".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
'recurring_rule_type': "monthly", |
|
|
'recurring_rule_type': "monthly", |
|
|
'recurring_invoicing_type': 'pre-paid', |
|
|
'recurring_invoicing_type': 'pre-paid', |
|
|
} |
|
|
} |
|
@ -41,9 +41,12 @@ class TestContractLineForecastPeriod(TestContractBase): |
|
|
def test_forecast_period_on_contract_line_update_1(self): |
|
|
def test_forecast_period_on_contract_line_update_1(self): |
|
|
self.acct_line.write( |
|
|
self.acct_line.write( |
|
|
{ |
|
|
{ |
|
|
'date_start': "2019-01-01", |
|
|
|
|
|
'recurring_next_date': "2019-01-01", |
|
|
|
|
|
'date_end': "2019-12-31", |
|
|
|
|
|
|
|
|
'date_start': "{this_year}-01-01".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'recurring_next_date': "{this_year}-01-01".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'date_end': "{this_year}-12-31".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
'recurring_rule_type': "yearly", |
|
|
'recurring_rule_type': "yearly", |
|
|
'recurring_invoicing_type': 'pre-paid', |
|
|
'recurring_invoicing_type': 'pre-paid', |
|
|
} |
|
|
} |
|
@ -55,9 +58,12 @@ class TestContractLineForecastPeriod(TestContractBase): |
|
|
def test_forecast_period_on_contract_line_update_2(self): |
|
|
def test_forecast_period_on_contract_line_update_2(self): |
|
|
self.acct_line.write( |
|
|
self.acct_line.write( |
|
|
{ |
|
|
{ |
|
|
'date_start': "2019-01-01", |
|
|
|
|
|
'recurring_next_date': "2019-01-31", |
|
|
|
|
|
'date_end': "2019-6-05", |
|
|
|
|
|
|
|
|
'date_start': "{this_year}-01-01".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'recurring_next_date': "{this_year}-01-31".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'date_end': "{this_year}-06-05".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
'recurring_rule_type': "monthlylastday", |
|
|
'recurring_rule_type': "monthlylastday", |
|
|
'recurring_invoicing_type': 'pre-paid', |
|
|
'recurring_invoicing_type': 'pre-paid', |
|
|
} |
|
|
} |
|
@ -92,9 +98,12 @@ class TestContractLineForecastPeriod(TestContractBase): |
|
|
def test_forecast_period_on_contract_line_update_6(self): |
|
|
def test_forecast_period_on_contract_line_update_6(self): |
|
|
self.acct_line.write( |
|
|
self.acct_line.write( |
|
|
{ |
|
|
{ |
|
|
'date_start': "2019-01-01", |
|
|
|
|
|
'recurring_next_date': "2019-01-01", |
|
|
|
|
|
'date_end': "2019-01-28", |
|
|
|
|
|
|
|
|
'date_start': "{this_year}-01-01".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'recurring_next_date': "{this_year}-01-01".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'date_end': "{this_year}-01-28".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
'recurring_rule_type': "monthly", |
|
|
'recurring_rule_type': "monthly", |
|
|
'recurring_invoicing_type': 'pre-paid', |
|
|
'recurring_invoicing_type': 'pre-paid', |
|
|
} |
|
|
} |
|
@ -106,9 +115,12 @@ class TestContractLineForecastPeriod(TestContractBase): |
|
|
def test_forecast_period_on_contract_line_update_6(self): |
|
|
def test_forecast_period_on_contract_line_update_6(self): |
|
|
self.acct_line.write( |
|
|
self.acct_line.write( |
|
|
{ |
|
|
{ |
|
|
'date_start': "2019-01-01", |
|
|
|
|
|
'recurring_next_date': "2019-02-01", |
|
|
|
|
|
'date_end': "2019-01-28", |
|
|
|
|
|
|
|
|
'date_start': "{this_year}-01-01".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'recurring_next_date': "{this_year}-02-01".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'date_end': "{this_year}-01-28".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
'recurring_rule_type': "monthly", |
|
|
'recurring_rule_type': "monthly", |
|
|
'recurring_invoicing_type': 'post-paid', |
|
|
'recurring_invoicing_type': 'post-paid', |
|
|
} |
|
|
} |
|
@ -120,7 +132,7 @@ class TestContractLineForecastPeriod(TestContractBase): |
|
|
def test_forecast_period_on_contract_line_update_7(self): |
|
|
def test_forecast_period_on_contract_line_update_7(self): |
|
|
self.acct_line.write( |
|
|
self.acct_line.write( |
|
|
{ |
|
|
{ |
|
|
'date_end': "2019-6-05", |
|
|
|
|
|
|
|
|
'date_end': date.today() + relativedelta(months=3), |
|
|
'recurring_rule_type': "monthlylastday", |
|
|
'recurring_rule_type': "monthlylastday", |
|
|
'recurring_invoicing_type': 'pre-paid', |
|
|
'recurring_invoicing_type': 'pre-paid', |
|
|
'is_auto_renew': True, |
|
|
'is_auto_renew': True, |
|
@ -134,9 +146,12 @@ class TestContractLineForecastPeriod(TestContractBase): |
|
|
def test_forecast_period_on_contract_line_update_8(self): |
|
|
def test_forecast_period_on_contract_line_update_8(self): |
|
|
self.acct_line.write( |
|
|
self.acct_line.write( |
|
|
{ |
|
|
{ |
|
|
'date_start': "2019-01-14", |
|
|
|
|
|
'recurring_next_date': "2019-01-31", |
|
|
|
|
|
'date_end': "2019-01-14", |
|
|
|
|
|
|
|
|
'date_start': "{this_year}-01-14".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'recurring_next_date': "{this_year}-01-31".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
|
|
|
'date_end': "{this_year}-01-14".format( |
|
|
|
|
|
this_year=self.this_year), |
|
|
'recurring_rule_type': "monthlylastday", |
|
|
'recurring_rule_type': "monthlylastday", |
|
|
'recurring_invoicing_type': 'post-paid', |
|
|
'recurring_invoicing_type': 'post-paid', |
|
|
} |
|
|
} |
|
|