Odoo Help


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.


How to populate default rows in one2many's treeview?

Hammad hussain qureshi
on 11/8/15, 8:49 AM 674 views


I want to alter the functionality of sale order form, what I want to do is whenever a new sale order is to be create the one2many order_lines treeview should contains some default field rows as shown in linked figure, which are then inserted into the relation model on save.



Hammad hussain qureshi
On 11/10/15, 12:06 AM

I came across to handle this by inheriting default_get method of the sale order that contains the one2many order_lines field in which I return the values to this field

def default_get(self, cr, uid, fields_list, context=None):
res = super(sale_order, self).default_get(cr, uid, fields_list, context)
res['order_lines'] = (0, 0, { 'here_the_field_name_of_order_lines_comodel': 'values_goes_here' })
return res

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

1 follower(s)


Asked: 11/8/15, 8:49 AM
Seen: 674 times
Last updated: 11/10/15, 12:07 AM