Browse Source

[IMP] - Should be able to stop a past contract line

13.0-mig-contract
sbejaoui 6 years ago
committed by Administrator
parent
commit
4e2da9906c
  1. 2
      contract/models/contract_line.py
  2. 4
      contract/models/contract_line_constraints.py
  3. 14
      contract/tests/test_contract.py

2
contract/models/contract_line.py

@ -999,7 +999,7 @@ class AccountAnalyticInvoiceLine(models.Model):
res = self.env['account.analytic.invoice.line'] res = self.env['account.analytic.invoice.line']
for rec in self: for rec in self:
is_auto_renew = rec.is_auto_renew is_auto_renew = rec.is_auto_renew
rec.is_auto_renew = False
rec.stop(rec.date_end, post_message=False)
date_start, date_end = rec._get_renewal_dates() date_start, date_end = rec._get_renewal_dates()
new_line = rec.plan_successor( new_line = rec.plan_successor(
date_start, date_end, is_auto_renew, post_message=False date_start, date_end, is_auto_renew, post_message=False

4
contract/models/contract_line_constraints.py

@ -303,7 +303,7 @@ CRITERIA_ALLOWED_DICT = {
): Allowed( ): Allowed(
plan_successor=False, plan_successor=False,
stop_plan_successor=False, stop_plan_successor=False,
stop=False,
stop=True,
cancel=False, cancel=False,
uncancel=False, uncancel=False,
), ),
@ -333,7 +333,7 @@ CRITERIA_ALLOWED_DICT = {
): Allowed( ): Allowed(
plan_successor=True, plan_successor=True,
stop_plan_successor=False, stop_plan_successor=False,
stop=False,
stop=True,
cancel=False, cancel=False,
uncancel=False, uncancel=False,
), ),

14
contract/tests/test_contract.py

@ -640,17 +640,13 @@ class TestContract(TestContractBase):
self.assertFalse(self.contract.date_end) self.assertFalse(self.contract.date_end)
def test_stop_contract_line(self): def test_stop_contract_line(self):
"""It should put end to the contract line"""
self.acct_line.write(
{
'date_start': self.today - relativedelta(months=7),
'recurring_next_date': self.today - relativedelta(months=7),
'date_end': self.today - relativedelta(months=5),
'is_auto_renew': False,
}
)
"""It should raise a validation error"""
self.acct_line.cancel()
with self.assertRaises(ValidationError): with self.assertRaises(ValidationError):
self.acct_line.stop(self.today) self.acct_line.stop(self.today)
def test_stop_contract_line(self):
"""It should put end to the contract line"""
self.acct_line.write( self.acct_line.write(
{ {
'date_start': self.today, 'date_start': self.today,

Loading…
Cancel
Save