Merge pull request #521 from expsa/real_test

Update rent_payment.py
This commit is contained in:
zainab2097 2024-08-05 14:10:20 +03:00 committed by GitHub
commit 9326fb100e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 21 deletions

View File

@ -57,7 +57,7 @@ class RentPayment(models.Model):
for rec in self:
if rec.invoice_id.payment_state in ['paid', 'in_payment']:
rec.write({'state': 'paid'})
payment_obj = self.env['account.payment'].search([('ref','=',rec.invoice_id.name)],limit=1)
rec.paid_date=payment_obj.date
return res
@ -81,32 +81,32 @@ class RentPayment(models.Model):
line_invoice=[]
if amount>=0.00:
line_invoice.append((0, 0, {
'name':'قيمة الإيجار '+'- '+ payment.name + ' - ' + payment.code + ' - ' + str(payment.due_date),
'price_unit': amount,
'quantity': 1.0,
'account_id': payment.contract_id.accrued_account_id.id,
}))
'name':'قيمة الإيجار '+'- '+ payment.name + ' - ' + payment.code + ' - ' + str(payment.due_date),
'price_unit': amount,
'quantity': 1.0,
'account_id': payment.contract_id.accrued_account_id.id,
}))
if payment.water_cost>0.00:
line_invoice.append((0, 0, {
'name': 'تكلفة المياه'+' -'+payment.name + ' - ' + payment.code + ' - ' + str(payment.due_date),
'price_unit': payment.water_cost,
'quantity': 1.0,
'account_id': payment.contract_id.accrued_account_id.id,
}),)
'name': 'تكلفة المياه'+' -'+payment.name + ' - ' + payment.code + ' - ' + str(payment.due_date),
'price_unit': payment.water_cost,
'quantity': 1.0,
'account_id': payment.contract_id.accrued_account_id.id,
}),)
if payment.service_cost>0.00:
line_invoice.append((0, 0, {
'name':'قيمة الخدمات'+' - '+ payment.name + ' - ' + payment.code + ' - ' + str(payment.due_date),
'price_unit': payment.service_cost,
'quantity': 1.0,
'account_id': payment.contract_id.accrued_account_id.id,
}))
'name':'قيمة الخدمات'+' - '+ payment.name + ' - ' + payment.code + ' - ' + str(payment.due_date),
'price_unit': payment.service_cost,
'quantity': 1.0,
'account_id': payment.contract_id.accrued_account_id.id,
}))
invoice_vals = {
'ref': payment.name,
'move_type': 'out_invoice',
'invoice_origin': payment.code,
'invoice_user_id': payment.user_id.id,
'narration': payment.note,
'partner_id': payment.contract_id.partner_id.id or payment.contract_id.renter_id.id
'partner_id': payment.contract_id.partner_id.id or payment.contract_id.renter_id.id,
invoice_line_ids : line_invoice,
'line_ids': [
(0, 0, {
@ -134,11 +134,11 @@ class RentPayment(models.Model):
invoice_vals = self._prepare_invoice_values(self, self.total_amount)
invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid)
# Get the ID of the second line
# Get the ID of the second line
line_id = invoice.invoice_line_ids[1].id
commands = [(2, line_id, 0)]
invoice.write({'invoice_line_ids': commands})
self.invoice_id = invoice.id
self.write({'state': 'invoice'})
@ -176,10 +176,11 @@ class RentPayment(models.Model):
# tax_value = rec.tax_id.amount / 100
# rec.tax_amount = rec.untaxed_amount * tax_value
@api.depends('amount', 'water_cost', '')
@api.depends('amount', 'water_cost', 'service_cost')
def get_untaxed_amount(self):
for rec in self:
rec.untaxed_amount = rec.amount + rec.water_cost + rec.
rec.untaxed_amount = rec.amount + rec.water_cost + rec.service_cost
@api.depends('amount', 'water_cost', '')
def get_total_amount(self):