Odoo Help


How do I get the account.invoice associated to a sales.order?

on 1/10/16, 7:44 AM 726 views

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:


payment_method = fields.Char(compute='_get_payment_terms',string='Payment Method',readonly=True)



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?


Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
On 1/10/16, 8:27 AM

Hello E.M.,

There is a m2m field called "invoice_ids" in Sale Order which contains all the Invoices related to the SO.

I don't see "payment_method_id" field in account.invoice. Make sure you are using right field. I guess you want to show "Payment  Terms". For this you have to use "payment_term" field which is in "account.invoice".

Hope this will resolve your issue.


In the GUI, if you select an invoice and go to "Other information" tab, you will find there: payment_method. That is what I am trying to recover.

on 1/10/16, 8:45 AM

Yes, you are right. But you are using wrong field in your code. You should use "payment_term" instead of "payment_method_id".

Sudhir Arya (ERP Harbor Consulting Services)
on 1/10/16, 8:54 AM

i finally found that I just had to use payment_method, not payment_method_id. However, if I do that I just got "bank_transfer", how can I get the descriptive text "Bank Transfer"

on 1/10/16, 9:16 AM

WOW I forgot payment_method was actually an extension I wrote a few months ago. Requesting support for your own custom module seems like kinda audacious.

on 1/10/16, 9:21 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/10/16, 7:44 AM
Seen: 726 times
Last updated: 1/10/16, 9:15 AM