Update rent_payment.py
This commit is contained in:
parent
01f4841da3
commit
294a08c4f3
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Reference in New Issue