mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] - don't allow to unlink uncnaceled contrac line
This commit is contained in:
committed by
Francisco Ivan Anton Prieto
parent
c83f3162a0
commit
d71261e919
@@ -946,3 +946,12 @@ class AccountAnalyticInvoiceLine(models.Model):
|
|||||||
return super(AccountAnalyticInvoiceLine, self).fields_view_get(
|
return super(AccountAnalyticInvoiceLine, self).fields_view_get(
|
||||||
view_id, view_type, toolbar, submenu
|
view_id, view_type, toolbar, submenu
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def unlink(self):
|
||||||
|
"""stop unlink uncnacled lines"""
|
||||||
|
if not all(self.mapped('is_canceled')):
|
||||||
|
raise ValidationError(
|
||||||
|
_("Contract line must be canceled before delete")
|
||||||
|
)
|
||||||
|
return super(AccountAnalyticInvoiceLine, self).unlink()
|
||||||
|
|||||||
@@ -431,7 +431,7 @@ class TestContract(TestContractBase):
|
|||||||
|
|
||||||
def test_onchange_contract_template_id_lines(self):
|
def test_onchange_contract_template_id_lines(self):
|
||||||
"""It should create invoice lines for the contract lines."""
|
"""It should create invoice lines for the contract lines."""
|
||||||
|
self.acct_line.cancel()
|
||||||
self.acct_line.unlink()
|
self.acct_line.unlink()
|
||||||
self.contract.contract_template_id = self.template
|
self.contract.contract_template_id = self.template
|
||||||
|
|
||||||
@@ -1370,3 +1370,7 @@ class TestContract(TestContractBase):
|
|||||||
first, last = self.acct_line._get_invoiced_period()
|
first, last = self.acct_line._get_invoiced_period()
|
||||||
self.assertEqual(first, to_date('2020-01-05'))
|
self.assertEqual(first, to_date('2020-01-05'))
|
||||||
self.assertEqual(last, to_date('2020-03-15'))
|
self.assertEqual(last, to_date('2020-03-15'))
|
||||||
|
|
||||||
|
def test_unlink(self):
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
self.acct_line.unlink()
|
||||||
|
|||||||
Reference in New Issue
Block a user