mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] - use terminate term instead of resiliate
This commit is contained in:
@@ -18,15 +18,15 @@ class SaleOrder(models.Model):
|
||||
)
|
||||
|
||||
@api.constrains('state')
|
||||
def check_contact_is_not_resiliated(self):
|
||||
def check_contact_is_not_terminated(self):
|
||||
for rec in self:
|
||||
if rec.state not in (
|
||||
'sale',
|
||||
'done',
|
||||
'cancel',
|
||||
) and rec.order_line.filtered('contract_id.is_resiliated'):
|
||||
) and rec.order_line.filtered('contract_id.is_terminated'):
|
||||
raise ValidationError(
|
||||
_("You can't upsell or downsell a resiliated contract")
|
||||
_("You can't upsell or downsell a terminated contract")
|
||||
)
|
||||
|
||||
@api.depends('order_line.contract_id', 'state')
|
||||
|
||||
@@ -68,14 +68,14 @@ class SaleOrderLine(models.Model):
|
||||
)
|
||||
|
||||
@api.constrains('contract_id')
|
||||
def check_contact_is_not_resiliated(self):
|
||||
def check_contact_is_not_terminated(self):
|
||||
for rec in self:
|
||||
if (
|
||||
rec.order_id.state not in ('sale', 'done', 'cancel')
|
||||
and rec.contract_id.is_resiliated
|
||||
and rec.contract_id.is_terminated
|
||||
):
|
||||
raise ValidationError(
|
||||
_("You can't upsell or downsell a resiliated contract")
|
||||
_("You can't upsell or downsell a terminated contract")
|
||||
)
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -343,17 +343,17 @@ class TestSaleOrder(TransactionCase):
|
||||
self.sale.order_line.mapped('contract_id'),
|
||||
)
|
||||
|
||||
def test_check_contact_is_not_resiliated(self):
|
||||
self.contract.is_resiliated = True
|
||||
def test_check_contact_is_not_terminated(self):
|
||||
self.contract.is_terminated = True
|
||||
with self.assertRaises(ValidationError):
|
||||
self.order_line1.contract_id = self.contract
|
||||
|
||||
def test_check_contact_is_not_resiliated(self):
|
||||
def test_check_contact_is_not_terminated(self):
|
||||
self.order_line1.contract_id = self.contract
|
||||
self.sale.action_confirm()
|
||||
self.contract.is_resiliated = True
|
||||
self.contract.is_terminated = True
|
||||
self.sale.action_cancel()
|
||||
with self.assertRaises(ValidationError):
|
||||
self.sale.action_draft()
|
||||
self.contract.is_resiliated = False
|
||||
self.contract.is_terminated = False
|
||||
self.sale.action_draft()
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
domain="['|',('contract_template_id','=',contract_template_id),
|
||||
('contract_template_id','=',False),
|
||||
('partner_id','=',parent.partner_id),
|
||||
('is_resiliated','=',False),
|
||||
('is_terminated','=',False),
|
||||
]"/>
|
||||
<field name="contract_line_id"
|
||||
attrs="{'invisible': [('is_contract', '=', False)]}"
|
||||
|
||||
Reference in New Issue
Block a user