From 50350e74270aa061e29cec74ef2eff53b1e086bd Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:52:53 +0300 Subject: [PATCH] Update rent_payment.py --- .../models/rent_payment.py | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) 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