From sales.order object, how do I get the associated invoices?
I have tried to extend class stock.picking like this and added a function field:
#Field:
payment_method = fields.Char(compute='_get_payment_terms',string='Payment Method',readonly=True)
#Method:
@api.depends(''sale_id.invoice_ids','sale_id.invoice_ids.payment_method_id','sale_id.invoice_ids.payment_method_id.name')def _get_payment_terms(self):
self.payment_method = self.sale_id.invoice_ids and self.sale_id.invoice_ids[0].payment_method_id and self.sale_id.invoice_ids[0].payment_method_id.name or ''
When loading the module it says: fields = [model._fields[head]] KeyError: 'payment_method_id'
Is there anything obvious I could be missing?