Update rent_payment.py
This commit is contained in:
parent
fe118e4da4
commit
c91d10a2b0
|
|
@ -182,6 +182,24 @@ class RentPayment(models.Model):
|
|||
self.write(({'state': 'cancel'}))
|
||||
elif self.state == 'due':
|
||||
raise exceptions.ValidationError(_('Cannot Cancel This Payment Because it Due'))
|
||||
|
||||
def action_validate2(self):
|
||||
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"))
|
||||
|
||||
def action_validate(self):
|
||||
for record in self:
|
||||
|
|
|
|||
Loading…
Reference in New Issue