This question has been flagged
4 Replies
6350 Views

I want to add one field of the model purchase.oder.line in the tree view of purchase.order. How to do it? 
Thanks.

Avatar
Discard
Best Answer

if that  'Field' of all the purchase line of particuler purchase order contain same value, Then You can use related field type.

another Idea is to use Function filed. Add one function field in purchase order which calculte proper value form its purchase Line. 

Avatar
Discard
Best Answer

True, you cannot access child objects field...

However with help of some work around you can acheive it, again depending on your requirement, but keep it mind, you are trying to fetch values of muliple records (One2many) and dumping it in single record's field (parent), hence you can either have first/last of child records value, or concatenation of all child's records values as single value...

So all you need to do is First create a functional field in Purchase Order object, (Note: store is False)

case 1: Assume you are trying to fetch First Child records value, say "description", then evaluate your functional field to fetch only first records' "description" value

case 2: Assume you want to fetch all Child records value, say "description", then evaluate your functional field to fetch all records' "description" value, by concatenating with a comma(,) separator...

Now the same functional field can be used in Purchase Order Tree... And you will have to write a defined search view for it, use _fnct_search..

Hope this helps you, even i had the same requirement, so i acheived it with functional field and defined search view

 

Avatar
Discard
Author

thanks, can you help me about the method which can fetch the value in the purchase order line to store in the value of purchase order. Thanks

Best Answer

There is no way of acessing the purchase.order.line date.....u can add new field in purchase order model and call onchange method on order_line and pass same field as an argument.

<field name ='order_line' onchange= "getdate(order_line)"> 

by this way u can specify the defnition of getdate() to fetch the date of purchase order line and insert into purchase order model...

Avatar
Discard
Author

I try to do the function getdata() to fetch the date but i'm stuck. Can you help please. Thanks.

Best Answer

No, it is not posssible because of the convention of Openerp/Odoo, we can only have only one model in tree veiw. There is many way to get date from purches order line.  Add one function field in purchase order  which calculte  value form its purchase Line.  

Avatar
Discard
Author

Don't understand : I have purchase.order.tree purchase.order And I want to add the field "date" of purchase.order.line in this view.