i am receiving this error while creating an invoice on a button click
psycopg2.ProgrammingError: can't adapt type 'file
Here's my python codedef create_invoice(self):
file = self.env['file'].browse(self._context['active_id'])for rec in self.invoice_line:
if not rec.is_fully_paid:
number_of_time = rec.no_of_installment
per_installment = rec.per_installment
for line in file.installment_plan_ids:
if number_of_time and line.installment_number == 1:
line.update({'amount': line.amount + per_installment})
number_of_time = number_of_time - 1
if 0 in self.invoice_line.mapped('total'):
raise ValidationError(_("Unit price of the products should be non zero number"))
prod = [(0, 0, {
'product_id': rec.product_id.id,
'name': rec.product_id.name,
'account_id': rec.product_id.property_account_income_id.id,
'price_unit': rec.initial_payment
}) for rec in self.invoice_line if rec.initial_payment]
has_initial = True if prod else False
if has_initial:
invoice = self.env['account.move'].create({
'file_ids': file.id,
# 'name': self.name,
'partner_id': self.membership_id.id,
'property_invoice_type': 'others',
'type': 'out_invoice',
'user_id': self.env['file'].browse(self._context['active_id']).user_id.id,
'invoice_date': self.date,
# 'invoice_date_due': self.date,
# 'account_id': self.membership_id.property_account_receivable_id.id,
'invoice_line_ids': prod
})
invoice.action_post()
for rec in file.installment_plan_ids:
if rec.installment_number == 0 and rec.invoice_created != True:
rec.write({
'invoice_created': True,
'invoice_id': invoice.id,
})
it doesn't pass this line 'invoice_line_ids': prod in debug mode.Any idea why this error is coming?