Odoo Help

Welcome!

This community 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.

1

Need help of OpenERP Developer to extend account.invoice.line

By
NSC
on 1/12/14, 9:38 AM 1,544 views

Inside model account.invoice.line, there is only available line.name, which joins product_id, product name and product description. These fields can not be accessed separately so far. I only want to display product.name_template at printed invoices. Product_ID and description should only be for internal purposes.

Could anybody give me any example code? I am familiar with developing, but unfortunately not with python and I do not have any practical experience with ORM either. I have already inherited some classes to add some custom fields, but up to now, I have never stepped over the horizon of the data model I want to extend. In this case, account.invoice.line "knows" her product_id, but I have no idea how to get from this to my desired field.

For example, I saw code like that:

self.pool.get('product_product').browse(cr, uid, id).name_template

Is this sufficient to fetch all name_templates for every invoice.line and then store it to the table? To see some code related to my problem in entire context would be very helpful to me...

Many views, but no answer so far... My question is rather a general one about data access within ORM models - maybe it is not described clear enough - so I will try once again:

If the data model I want to extend contains a column with the ids of another object I want to add additional fields from, how do I access these fields from the foreign model? Do I need to browse for this object's model/table first or do I get the information needed by simply calling <id>.<field_I_need>?

NSC
on 1/20/14, 6:07 AM

For my special case this means: I want to add further information from product.product to account.invoice.line model. The latter already contains a column with product.product.id - this means a relation to the model/table I want to add additional fields from is already there. But how to access fields of this foreign model from within python code now?

NSC
on 1/20/14, 6:08 AM

Now, I can answer this question myself: I the relation to another table is already there, from within python code, there is no need to browse for a special field of this table. Every field can simply be accessed by going over this foreign ID. For example for accessing product_product.name_template from account.invoice.line one has to do this: l.product_id.name_template.

NSC
on 2/8/14, 9:15 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 1/12/14, 9:38 AM
Seen: 1544 times
Last updated: 3/16/15, 8:10 AM