Update rental_contract.py
This commit is contained in:
parent
264701223e
commit
2572db085b
|
|
@ -282,6 +282,7 @@ class RentalContract(models.Model):
|
|||
rec.insurance_paid = 0.0
|
||||
|
||||
def _prepare_invoice_values(self, contract, amount):
|
||||
self.partner_id.property_account_receivable_id = contract.debit_account_id.id
|
||||
invoice_vals = {
|
||||
'ref': _("Insurance payment for ") + contract.name,
|
||||
'move_type': 'out_invoice',
|
||||
|
|
@ -305,6 +306,10 @@ class RentalContract(models.Model):
|
|||
def action_confirm(self):
|
||||
invoice_vals = self._prepare_invoice_values(self, self.insurance_amount)
|
||||
invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid)
|
||||
# Get the ID of the second line
|
||||
if invoice.invoice_line_ids[1]:
|
||||
line_id = invoice.invoice_line_ids[1].id
|
||||
commands = [(2, line_id, 0)]
|
||||
self.insurance_invoice_id = invoice.id
|
||||
if self.rent_method != 'property':
|
||||
for unit in self.unit_ids:
|
||||
|
|
|
|||
Loading…
Reference in New Issue