mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[13.0][FIX] contract: Recompute recurring next date
After invoice creation, the recurring next date has to be recomputed in order to get good values
This commit is contained in:
committed by
Pedro M. Baeza
parent
cd086ddbb4
commit
3a5ec60fd4
@@ -465,7 +465,9 @@ class ContractContract(models.Model):
|
|||||||
|
|
||||||
def _recurring_create_invoice(self, date_ref=False):
|
def _recurring_create_invoice(self, date_ref=False):
|
||||||
invoices_values = self._prepare_recurring_invoices_values(date_ref)
|
invoices_values = self._prepare_recurring_invoices_values(date_ref)
|
||||||
return self.env["account.move"].create(invoices_values)
|
moves = self.env["account.move"].create(invoices_values)
|
||||||
|
self._compute_recurring_next_date()
|
||||||
|
return moves
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def cron_recurring_create_invoice(self, date_ref=None):
|
def cron_recurring_create_invoice(self, date_ref=None):
|
||||||
|
|||||||
@@ -123,6 +123,41 @@ class TestContractBase(common.SavepointCase):
|
|||||||
{"name": "terminate_reason"}
|
{"name": "terminate_reason"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cls.contract3 = cls.env["contract.contract"].create(
|
||||||
|
{
|
||||||
|
"name": "Test Contract 3",
|
||||||
|
"partner_id": cls.partner.id,
|
||||||
|
"pricelist_id": cls.partner.property_product_pricelist.id,
|
||||||
|
"line_recurrence": False,
|
||||||
|
"contract_type": "sale",
|
||||||
|
"recurring_interval": 1,
|
||||||
|
"recurring_rule_type": "monthly",
|
||||||
|
"date_start": "2018-02-15",
|
||||||
|
"contract_line_ids": [
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
"product_id": False,
|
||||||
|
"name": "Services from #START# to #END#",
|
||||||
|
"quantity": 1,
|
||||||
|
"price_unit": 100,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
"product_id": False,
|
||||||
|
"name": "Line",
|
||||||
|
"quantity": 1,
|
||||||
|
"price_unit": 120,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestContract(TestContractBase):
|
class TestContract(TestContractBase):
|
||||||
def _add_template_line(self, overrides=None):
|
def _add_template_line(self, overrides=None):
|
||||||
@@ -169,6 +204,10 @@ class TestContract(TestContractBase):
|
|||||||
self.assertAlmostEqual(self.inv_line.price_subtotal, 50.0)
|
self.assertAlmostEqual(self.inv_line.price_subtotal, 50.0)
|
||||||
self.assertEqual(self.contract.user_id, self.invoice_monthly.user_id)
|
self.assertEqual(self.contract.user_id, self.invoice_monthly.user_id)
|
||||||
|
|
||||||
|
def test_contract_level_recurrence(self):
|
||||||
|
self.contract3.recurring_create_invoice()
|
||||||
|
self.contract3.flush()
|
||||||
|
|
||||||
def test_contract_daily(self):
|
def test_contract_daily(self):
|
||||||
recurring_next_date = to_date("2018-02-23")
|
recurring_next_date = to_date("2018-02-23")
|
||||||
last_date_invoiced = to_date("2018-02-22")
|
last_date_invoiced = to_date("2018-02-22")
|
||||||
|
|||||||
Reference in New Issue
Block a user