Update rent_payment.py
This commit is contained in:
parent
41e17d69e9
commit
d6803a723e
|
|
@ -184,21 +184,23 @@ class RentPayment(models.Model):
|
|||
raise exceptions.ValidationError(_('Cannot Cancel This Payment Because it Due'))
|
||||
|
||||
def action_validate(self):
|
||||
if self.contract_id.state == 'confirm':
|
||||
rent_payment = [line for line in self.contract_id.rent_payment_ids.filtered(
|
||||
lambda payment: payment.due_date < self.due_date and
|
||||
(not payment.invoice_id or
|
||||
all(invoice.state == 'draft' for invoice in payment.invoice_id))
|
||||
)]
|
||||
if len(rent_payment):
|
||||
raise exceptions.ValidationError(
|
||||
_("You must validate the previous rent payment and complete the process"))
|
||||
if self.code == '/' or not self.code:
|
||||
code = self.env['ir.sequence'].next_by_code('rent.payment') or '/'
|
||||
self.write({'code': code})
|
||||
self.write({"state": 'due'})
|
||||
else:
|
||||
raise exceptions.ValidationError(_("You Must Confirm Contract First"))
|
||||
for record in self:
|
||||
if record.contract_id.state == 'confirm':
|
||||
rent_payment = [line for line in record.contract_id.rent_payment_ids.filtered(
|
||||
lambda payment: payment.due_date < record.due_date and
|
||||
(not payment.invoice_id or
|
||||
all(invoice.state == 'draft' for invoice in payment.invoice_id))
|
||||
)]
|
||||
if len(rent_payment):
|
||||
raise exceptions.ValidationError(
|
||||
_("You must validate the previous rent payment and complete the process"))
|
||||
if record.code == '/' or not record.code:
|
||||
code = self.env['ir.sequence'].next_by_code('rent.payment') or '/'
|
||||
record.write({'code': code})
|
||||
record.write({"state": 'due'})
|
||||
else:
|
||||
raise exceptions.ValidationError(_("You Must Confirm Contract First"))
|
||||
|
||||
|
||||
# @api.depends('untaxed_amount', 'tax_id', 'tax_id.amount')
|
||||
# def get_tax_amount(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue