diff --git a/odex25_realstate/property_management/models/rent_payment.py b/odex25_realstate/property_management/models/rent_payment.py index 8cb54dd3a..5a5355d70 100644 --- a/odex25_realstate/property_management/models/rent_payment.py +++ b/odex25_realstate/property_management/models/rent_payment.py @@ -215,21 +215,18 @@ class RentPayment(models.Model): if not vendor_id or not account_id: raise UserError(_("Vendor or Account not configured properly in settings.")) - # if payments_to_invoice: - vendor_bill = self.env['account.move'].create({ - 'move_type': 'in_invoice', - 'invoice_date': today_date, # Set the invoice date, - 'partner_id': vendor_id, - 'invoice_line_ids': [(0, 0, { - 'name': name+' - '+str(today_date), - 'quantity': 1, - 'price_unit': total_commission_amount, - 'account_id': account_id - })], - }) - # else: - # raise UserError(_("No eligible payments selected. there are payment not valid conditions")) - + if payments_to_invoice: + vendor_bill = self.env['account.move'].create({ + 'move_type': 'in_invoice', + 'invoice_date': today_date, # Set the invoice date, + 'partner_id': vendor_id, + 'invoice_line_ids': [(0, 0, { + 'name': name+' - '+str(today_date), + 'quantity': 1, + 'price_unit': total_commission_amount, + 'account_id': account_id + })], + }) for payment in payments_to_invoice: payment.invoice_commission_id = vendor_bill.id