Update rent_payment.py

This commit is contained in:
zainab2097 2024-09-08 14:11:19 +03:00 committed by GitHub
parent 01f4841da3
commit 294a08c4f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 5 deletions

View File

@ -112,8 +112,7 @@ class RentPayment(models.Model):
if payment.amount>0.00:
line_invoice.append((0, 0, {
'name':'قيمة الإيجار '+' - '+payment.contract_id.name+'- '+self.property_id.name+' - '+self.unit_ids[0].name+' - ' + self.name + ' - ' + payment.code + ' - ' + str(payment.due_date),
'price_unit': self.amount,
'name': 'قيمة الإيجار ' + ' - ' + str(payment.contract_id.name or '') + ' - ' + str(self.property_id.name or '') + ' - ' + unit_name + ' - ' + str(self.name or '') + ' - ' + str(payment.code or '') + ' - ' + str(payment.due_date or ''),
'quantity': 1.0,
'account_id': payment.contract_id.revenue_account_id.id,
'analytic_account_id': payment.property_id.account_analy_id.id if payment.property_id.account_analy_id else False,
@ -121,7 +120,7 @@ class RentPayment(models.Model):
}))
if payment.water_cost>0.00:
line_invoice.append((0, 0, {
'name': 'تكلفة المياه'+' -'+self.name + ' - '+payment.contract_id.name +' - ' +self.property_id.name+' - '+self.unit_ids[0].name+' - ' + payment.code + ' - ' + str(payment.due_date),
'name': 'قيمة الإيجار ' + ' - ' + str(payment.contract_id.name or '') + ' - ' + str(self.property_id.name or '') + ' - ' + unit_name + ' - ' + str(self.name or '') + ' - ' + str(payment.code or '') + ' - ' + str(payment.due_date or ''),
'price_unit':self.water_cost,
'quantity': 1.0,
'account_id': payment.contract_id.revenue_account_id.id,
@ -130,7 +129,7 @@ class RentPayment(models.Model):
}),)
if payment.service_cost>0.00:
line_invoice.append((0, 0, {
'name':'قيمة الخدمات'+' - '+ self.name+' - '+payment.contract_id.name + ' - '+self.property_id.name+' - '+self.unit_ids[0].name+' - ' + payment.code + ' - ' + str(payment.due_date),
'name': 'قيمة الإيجار ' + ' - ' + str(payment.contract_id.name or '') + ' - ' + str(self.property_id.name or '') + ' - ' + unit_name + ' - ' + str(self.name or '') + ' - ' + str(payment.code or '') + ' - ' + str(payment.due_date or ''),
'price_unit': self.service_cost,
'quantity': 1.0,
'analytic_account_id': payment.property_id.account_analy_id.id if payment.property_id.account_analy_id else False,
@ -139,7 +138,7 @@ class RentPayment(models.Model):
}))
if payment.amount==0.00 and payment.service_cost==0.00 and payment.water_cost==0.00:
line_invoice.append((0, 0, {
'name':self.name + ' - ' +payment.contract_id.name + ' - '+self.property_id.name+' - '+self.unit_ids[0].name+' - '+payment.code + ' - ' + str(payment.due_date),
'name': 'قيمة الإيجار ' + ' - ' + str(payment.contract_id.name or '') + ' - ' + str(self.property_id.name or '') + ' - ' + unit_name + ' - ' + str(self.name or '') + ' - ' + str(payment.code or '') + ' - ' + str(payment.due_date or ''),
'price_unit':self.total_amount,
'quantity': 1.0,
'analytic_account_id': payment.property_id.account_analy_id.id if payment.property_id.account_analy_id else False,
@ -212,11 +211,16 @@ class RentPayment(models.Model):
today_date = datetime.today().strftime('%Y-%m-%d')
name = (_('Commission for selected payments'))
# Ensure vendor and account are valid
if not vendor_id or not account_id:
raise UserError(_("Vendor or Account not configured properly in settings."))
if not payments_to_invoice:
raise UserError(_("No eligible payments selected. there are payment not valid conditions"))
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),