i coded a method to post invoices like this:
`def print_invoice(self):
_logger.info('-#-#-#-#--#-#-#-in print_invoice')
line_array = []
for ar in self.ks_paketareale:
val = (0, None, {
'product_id': ar.ks_areal.id,
'name': ar.name,
'quantity': ar.ks_anzahl_behandlung,
'price_unit': ar.ks_areal.list_price,
'price_subtotal': ar.ks_areal.list_price * ar.ks_anzahl_behandlung,
})
line_array.append(val)
iid = self.env['account.move'].create({
'move_type': 'out_invoice',
'invoice_date': fields.Date.context_today(self),
'partner_id': self.partner_id.id,
#'currency_id': self.currency_id.id,
'amount_total': self.ks_rabattpreis,
'invoice_line_ids': line_array,
},
)
iid.action_post()
action = iid.action_invoice_print()
action.update({'close_on_report_download': True})`
creating the invoice works and the created invoice is posted.
but the call of iid.action_invoice_print() doesnt work. nothing happens. i was excpecting that the download of the invoice starts because in the method _print_document in accout_move the method action_invoice_print is called. whats going wrong? thx for any help
overriding action_post and action_print_invoice
Levizar’s comment was the crucial clue for solving my problem: