mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[FIX+IMP] contract: Fix tests + Batch modifications
This commit is contained in:
committed by
Pedro M. Baeza
parent
c09c93cda6
commit
6daf88a437
@@ -135,6 +135,16 @@ class ContractContract(models.Model):
|
||||
records._set_start_contract_modification()
|
||||
return records
|
||||
|
||||
def write(self, vals):
|
||||
if 'modification_ids' in vals:
|
||||
res = super(ContractContract, self.with_context(
|
||||
bypass_modification_send=True
|
||||
)).write(vals)
|
||||
self._modification_mail_send()
|
||||
else:
|
||||
res = super(ContractContract, self).write(vals)
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _set_start_contract_modification(self):
|
||||
for record in self:
|
||||
|
||||
@@ -33,15 +33,15 @@ class ContractModification(models.Model):
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super().create(vals_list)
|
||||
records.check_modification_ids_need_sent()
|
||||
if not self.env.context.get('bypass_modification_send'):
|
||||
records.check_modification_ids_need_sent()
|
||||
return records
|
||||
|
||||
def write(self, vals):
|
||||
res = super().write(vals)
|
||||
self.check_modification_ids_need_sent()
|
||||
if not self.env.context.get('bypass_modification_send'):
|
||||
self.check_modification_ids_need_sent()
|
||||
return res
|
||||
|
||||
def check_modification_ids_need_sent(self):
|
||||
records_not_sent = self.filtered(lambda x: not x.sent)
|
||||
if records_not_sent:
|
||||
records_not_sent.mapped('contract_id')._modification_mail_send()
|
||||
self.mapped('contract_id')._modification_mail_send()
|
||||
|
||||
@@ -168,7 +168,7 @@ class TestContract(TestContractBase):
|
||||
("model", "=", "contract.contract"),
|
||||
("res_id", "=", self.contract.id),
|
||||
])
|
||||
self.assertGreaterEqual(len(mail_messages), 3)
|
||||
self.assertGreaterEqual(len(mail_messages), 2)
|
||||
|
||||
def test_check_discount(self):
|
||||
with self.assertRaises(ValidationError):
|
||||
|
||||
Reference in New Issue
Block a user