Browse Source

[REF] contract: rename _get_recurring_next_date as get_next_invoice_date

It is easier to understand. Also make it public.
pull/434/head
Stéphane Bidoul (ACSONE) 5 years ago
parent
commit
8ba9033903
No known key found for this signature in database GPG Key ID: BCAB2555446B5B92
  1. 12
      contract/models/contract_line.py
  2. 4
      contract/tests/test_contract.py

12
contract/models/contract_line.py

@ -372,7 +372,7 @@ class ContractLine(models.Model):
recurring_interval recurring_interval
): ):
# deprecated method for backward compatibility # deprecated method for backward compatibility
return self._get_recurring_next_date(
return self.get_next_invoice_date(
date_start, date_start,
recurring_invoicing_type, recurring_invoicing_type,
self._get_default_recurring_invoicing_offset( self._get_default_recurring_invoicing_offset(
@ -384,7 +384,7 @@ class ContractLine(models.Model):
) )
@api.model @api.model
def _get_recurring_next_date(
def get_next_invoice_date(
self, self,
next_period_date_start, next_period_date_start,
recurring_invoicing_type, recurring_invoicing_type,
@ -539,7 +539,7 @@ class ContractLine(models.Model):
) )
def _onchange_date_start(self): def _onchange_date_start(self):
for rec in self.filtered('date_start'): for rec in self.filtered('date_start'):
rec.recurring_next_date = self._get_recurring_next_date(
rec.recurring_next_date = self.get_next_invoice_date(
rec.date_start, rec.date_start,
rec.recurring_invoicing_type, rec.recurring_invoicing_type,
rec.recurring_invoicing_offset, rec.recurring_invoicing_offset,
@ -705,7 +705,7 @@ class ContractLine(models.Model):
def _update_recurring_next_date(self): def _update_recurring_next_date(self):
for rec in self: for rec in self:
last_date_invoiced = rec.next_period_date_end last_date_invoiced = rec.next_period_date_end
recurring_next_date = rec._get_recurring_next_date(
recurring_next_date = rec.get_next_invoice_date(
last_date_invoiced + relativedelta(days=1), last_date_invoiced + relativedelta(days=1),
rec.recurring_invoicing_type, rec.recurring_invoicing_type,
rec.recurring_invoicing_offset, rec.recurring_invoicing_offset,
@ -782,7 +782,7 @@ class ContractLine(models.Model):
new_date_end = rec.date_end + delay_delta new_date_end = rec.date_end + delay_delta
else: else:
new_date_end = False new_date_end = False
new_recurring_next_date = self._get_recurring_next_date(
new_recurring_next_date = self.get_next_invoice_date(
new_date_start, new_date_start,
rec.recurring_invoicing_type, rec.recurring_invoicing_type,
rec.recurring_invoicing_offset, rec.recurring_invoicing_offset,
@ -847,7 +847,7 @@ class ContractLine(models.Model):
): ):
self.ensure_one() self.ensure_one()
if not recurring_next_date: if not recurring_next_date:
recurring_next_date = self._get_recurring_next_date(
recurring_next_date = self.get_next_invoice_date(
date_start, date_start,
self.recurring_invoicing_type, self.recurring_invoicing_type,
self.recurring_invoicing_offset, self.recurring_invoicing_offset,

4
contract/tests/test_contract.py

@ -564,7 +564,7 @@ class TestContract(TestContractBase):
0 0
) )
def test_get_recurring_next_date(self):
def test_get_next_invoice_date(self):
"""Test different combination to compute recurring_next_date """Test different combination to compute recurring_next_date
Combination format Combination format
{ {
@ -675,7 +675,7 @@ class TestContract(TestContractBase):
for recurring_next_date, combination in combinations: for recurring_next_date, combination in combinations:
self.assertEqual( self.assertEqual(
recurring_next_date, recurring_next_date,
contract_line_env._get_recurring_next_date(
contract_line_env.get_next_invoice_date(
*combination *combination
), ),
error_message(*combination), error_message(*combination),

Loading…
Cancel
Save