Hi everyone, I've been trying to point to specific index in the output of my browse method.
this is my code:
def unir_facturas_boton(self, vals):
active_invoices = self.env['account.move']._context.get('active_ids', [])
active_records = self.env['account.move'].browse(active_invoices)
# source = active_records[--1]
# source_2 = active_records[0]
for items in active_records:
print(items)
# if items[-1].partner_id != items[0].partner_id:
# raise ValidationError('No es posible unir facturas con clientes diferentes')
# else:
# invoice = self.env['account.move'].create(
# {
# 'company_id': items[-1].company_id,
# 'type': items[-1].type,
# 'invoice_date': items[-1].invoice_date,
# 'partner_id': items[-1].partner_id.id,
# 'currency_id': items[-1].currency_id.id,
# 'journal_id': 11
# })
# for lines in items[-1].invoice_line_ids:
# invoice.write({
# "invoice_line_ids": items[0].invoice_line_ids.append(lines)
# })
the commented part is giving me erros since I cant catch the index.
this the output of the browse method:
account.move(2,)
account.move(1,)
how can I point to an specific one of these two?