commit
cef8f3182a
|
|
@ -72,6 +72,7 @@ class RentPayment(models.Model):
|
|||
|
||||
|
||||
def _prepare_invoice_values(self, payment, amount):
|
||||
self.renter_id.property_account_receivable_id = payment.contract_id.debit_account_id.id
|
||||
invoice_vals = {
|
||||
'ref': payment.name,
|
||||
'move_type': 'out_invoice',
|
||||
|
|
@ -84,6 +85,10 @@ class RentPayment(models.Model):
|
|||
'price_unit': amount,
|
||||
'quantity': 1.0,
|
||||
'account_id': payment.contract_id.accrued_account_id.id,
|
||||
})],
|
||||
'line_ids': [ (0, 0, { 'account_id': payment.contract_id.accrued_account_id.id, 'debit': 0.0, 'credit': amount,'name': payment.contract_id.name + ' - ' + payment.contract_id.seq + ' - ' + str(payment.contract_id.date), 'quantity':1}),
|
||||
(0, 0, { 'account_id': payment.contract_id.debit_account_id.id, 'debit': amount, 'credit': 0.0, 'quantity':1}) ]
|
||||
|
||||
# 'tax_ids': [(6, 0, [payment.tax_id.id])],
|
||||
})],
|
||||
}
|
||||
|
|
@ -94,6 +99,12 @@ class RentPayment(models.Model):
|
|||
raise exceptions.ValidationError(_("Kindly, Contact Your Account Manager to set Income Account in contract account page"))
|
||||
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
|
||||
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'})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue